MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / BoundingRect

Function BoundingRect

src/core/geometry_func.cpp:36–50  ·  view source on GitHub ↗

* Compute the bounding rectangle around two rectangles. * @param r1 First rectangle. * @param r2 Second rectangle. * @return The bounding rectangle, the smallest rectangle that contains both arguments. */

Source from the content-addressed store, hash-verified

34 * @return The bounding rectangle, the smallest rectangle that contains both arguments.
35 */
36Rect BoundingRect(const Rect &r1, const Rect &r2)
37{
38 /* If either the first or the second is empty, return the other. */
39 if (IsEmptyRect(r1)) return r2;
40 if (IsEmptyRect(r2)) return r1;
41
42 Rect r;
43
44 r.top = std::min(r1.top, r2.top);
45 r.bottom = std::max(r1.bottom, r2.bottom);
46 r.left = std::min(r1.left, r2.left);
47 r.right = std::max(r1.right, r2.right);
48
49 return r;
50}

Callers 2

MakeDirtyMethod · 0.85
MakeDirtyMethod · 0.85

Calls 1

IsEmptyRectFunction · 0.85

Tested by

no test coverage detected