diff options
author | Michael Alexsander <michaelalexsander@protonmail.com> | 2020-02-08 14:43:08 -0300 |
---|---|---|
committer | Michael Alexsander <michaelalexsander@protonmail.com> | 2020-03-04 09:32:34 -0300 |
commit | 8c8c48a7adb27f1563e8ec7d3c756ce08ffbdf5c (patch) | |
tree | 93375a09a50da7f839050c81018b552ee7c8b0d5 /core/math | |
parent | f83f1d7c9b299f21f818e0ea28c27345f65bde4b (diff) |
Turn Rect2's 'intersects_touch()' into an extra argument of 'intersects()'
Diffstat (limited to 'core/math')
-rw-r--r-- | core/math/rect2.h | 42 |
1 files changed, 20 insertions, 22 deletions
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; } |