|
|
@@ -95,12 +95,12 @@ bool Rectangle::contains(const Rectangle& r) const
|
|
|
|
|
|
bool Rectangle::intersects(float x, float y, float width, float height) const
|
|
|
{
|
|
|
- const float left = max(this->x, x);
|
|
|
- const float top = max(this->y, y);
|
|
|
- const float right = min(x + width, x + width);
|
|
|
- const float bottom = min(y + height, y + height);
|
|
|
-
|
|
|
- return (right > left && bottom > top);
|
|
|
+ float t;
|
|
|
+ if ((t = x - this->x) > this->width || -t > width)
|
|
|
+ return false;
|
|
|
+ if ((t = y - this->y) > this->height || -t > height)
|
|
|
+ return false;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
bool Rectangle::intersects(const Rectangle& r) const
|