diff --git a/src/common/Vec2.h b/src/common/Vec2.h index 7bbf896d1..c0ad17c5f 100644 --- a/src/common/Vec2.h +++ b/src/common/Vec2.h @@ -368,10 +368,17 @@ public: // Return the intersection of two rectangles (possibly empty) Rect operator&(Rect other) const { - return Rect( + auto rect = Rect( Vec2(std::max(TopLeft.X, other.TopLeft.X), std::max(TopLeft.Y, other.TopLeft.Y)), Vec2(std::min(BottomRight.X, other.BottomRight.X), std::min(BottomRight.Y, other.BottomRight.Y)) ); + return Rect( + rect.TopLeft, + Vec2( + std::max(rect.TopLeft.X - 1, rect.BottomRight.X), + std::max(rect.TopLeft.Y - 1, rect.BottomRight.Y) + ) + ); } inline Rect &operator|=(Rect other)