Fixed compiler warnings in sf::Rect (#458)

This commit is contained in:
Laurent Gomila 2013-10-02 22:39:57 +02:00
parent 980477c1f1
commit 4dcd1f9c75

View File

@ -78,10 +78,10 @@ bool Rect<T>::contains(T x, T y) const
// Rectangles with negative dimensions are allowed, so we must handle them correctly // Rectangles with negative dimensions are allowed, so we must handle them correctly
// Compute the real min and max of the rectangle on both axes // Compute the real min and max of the rectangle on both axes
T minX = std::min(left, left + width); T minX = std::min(left, static_cast<T>(left + width));
T maxX = std::max(left, left + width); T maxX = std::max(left, static_cast<T>(left + width));
T minY = std::min(top, top + height); T minY = std::min(top, static_cast<T>(top + height));
T maxY = std::max(top, top + height); T maxY = std::max(top, static_cast<T>(top + height));
return (x >= minX) && (x < maxX) && (y >= minY) && (y < maxY); return (x >= minX) && (x < maxX) && (y >= minY) && (y < maxY);
} }
@ -111,16 +111,16 @@ bool Rect<T>::intersects(const Rect<T>& rectangle, Rect<T>& intersection) const
// Rectangles with negative dimensions are allowed, so we must handle them correctly // Rectangles with negative dimensions are allowed, so we must handle them correctly
// Compute the min and max of the first rectangle on both axes // Compute the min and max of the first rectangle on both axes
T r1MinX = std::min(left, left + width); T r1MinX = std::min(left, static_cast<T>(left + width));
T r1MaxX = std::max(left, left + width); T r1MaxX = std::max(left, static_cast<T>(left + width));
T r1MinY = std::min(top, top + height); T r1MinY = std::min(top, static_cast<T>(top + height));
T r1MaxY = std::max(top, top + height); T r1MaxY = std::max(top, static_cast<T>(top + height));
// Compute the min and max of the second rectangle on both axes // Compute the min and max of the second rectangle on both axes
T r2MinX = std::min(rectangle.left, rectangle.left + rectangle.width); T r2MinX = std::min(rectangle.left, static_cast<T>(rectangle.left + rectangle.width));
T r2MaxX = std::max(rectangle.left, rectangle.left + rectangle.width); T r2MaxX = std::max(rectangle.left, static_cast<T>(rectangle.left + rectangle.width));
T r2MinY = std::min(rectangle.top, rectangle.top + rectangle.height); T r2MinY = std::min(rectangle.top, static_cast<T>(rectangle.top + rectangle.height));
T r2MaxY = std::max(rectangle.top, rectangle.top + rectangle.height); T r2MaxY = std::max(rectangle.top, static_cast<T>(rectangle.top + rectangle.height));
// Compute the intersection boundaries // Compute the intersection boundaries
T interLeft = std::max(r1MinX, r2MinX); T interLeft = std::max(r1MinX, r2MinX);