diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-03-04 20:32:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-04 20:32:20 +0100 |
commit | e89754fa1f5ff3b11dddae399ac2838fd0f1acfe (patch) | |
tree | 39fa2bae93e54d0e3c246216730326241064a995 /core/math/rect2.h | |
parent | 398f714dfcb99c229c7ace06c906374a3fd93e3c (diff) | |
parent | 8c8c48a7adb27f1563e8ec7d3c756ce08ffbdf5c (diff) |
Merge pull request #36021 from YeldhamDev/intersects_touch_expose
Turn Rect2's 'intersects_touch()' into an extra argument of 'intersects()'
Diffstat (limited to 'core/math/rect2.h')
-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; } |