From 8c8c48a7adb27f1563e8ec7d3c756ce08ffbdf5c Mon Sep 17 00:00:00 2001 From: Michael Alexsander Date: Sat, 8 Feb 2020 14:43:08 -0300 Subject: Turn Rect2's 'intersects_touch()' into an extra argument of 'intersects()' --- core/math/rect2.h | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) (limited to 'core/math/rect2.h') diff --git a/core/math/rect2.h b/core/math/rect2.h index e4ea615c22..3b9660e2f0 100644 --- a/core/math/rect2.h +++ b/core/math/rect2.h @@ -47,28 +47,26 @@ struct Rect2 { real_t get_area() const { return size.width * size.height; } - inline bool intersects(const Rect2 &p_rect) const { - if (position.x >= (p_rect.position.x + p_rect.size.width)) - return false; - if ((position.x + size.width) <= p_rect.position.x) - return false; - if (position.y >= (p_rect.position.y + p_rect.size.height)) - return false; - if ((position.y + size.height) <= p_rect.position.y) - return false; - - return true; - } - - inline bool intersects_touch(const Rect2 &p_rect) const { - if (position.x > (p_rect.position.x + p_rect.size.width)) - return false; - if ((position.x + size.width) < p_rect.position.x) - return false; - if (position.y > (p_rect.position.y + p_rect.size.height)) - return false; - if ((position.y + size.height) < p_rect.position.y) - return false; + inline bool intersects(const Rect2 &p_rect, const bool p_include_borders = false) const { + if (p_include_borders) { + if (position.x > (p_rect.position.x + p_rect.size.width)) + return false; + if ((position.x + size.width) < p_rect.position.x) + return false; + if (position.y > (p_rect.position.y + p_rect.size.height)) + return false; + if ((position.y + size.height) < p_rect.position.y) + return false; + } else { + if (position.x >= (p_rect.position.x + p_rect.size.width)) + return false; + if ((position.x + size.width) <= p_rect.position.x) + return false; + if (position.y >= (p_rect.position.y + p_rect.size.height)) + return false; + if ((position.y + size.height) <= p_rect.position.y) + return false; + } return true; } -- cgit v1.2.3