mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-24 03:24:50 +00:00
COMMON: Add function to find the intersecting rectangle
This commit is contained in:
parent
da74436aa4
commit
3b9ab4f5cf
@ -169,6 +169,20 @@ struct Rect {
|
|||||||
return (left < r.right) && (r.left < right) && (top < r.bottom) && (r.top < bottom);
|
return (left < r.right) && (r.left < right) && (top < r.bottom) && (r.top < bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find the intersecting rectangle between this rectangle and the given rectangle
|
||||||
|
*
|
||||||
|
* @param r the intersecting rectangle
|
||||||
|
*
|
||||||
|
* @return the intersection of the rectangles or an empty rectangle if not intersecting
|
||||||
|
*/
|
||||||
|
Rect findIntersectingRect(const Rect &r) const {
|
||||||
|
if (!intersects(r))
|
||||||
|
return Rect();
|
||||||
|
|
||||||
|
return Rect(MAX(r.left, left), MAX(r.top, top), MIN(r.right, right), MIN(r.bottom, bottom));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extend this rectangle so that it contains r
|
* Extend this rectangle so that it contains r
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user