diff options
author | Markus Sauermann <6299227+Sauermann@users.noreply.github.com> | 2022-01-31 17:55:48 +0100 |
---|---|---|
committer | Markus Sauermann <6299227+Sauermann@users.noreply.github.com> | 2022-01-31 19:03:57 +0100 |
commit | 23a4fe5b27c191eae1dde05aa522463e67b0766f (patch) | |
tree | 5985555fe3cbe32d42ec1955f638c615cb157d70 /core | |
parent | d7822cbf2136b5dcff899b498c80c139b7701c9e (diff) |
Fix incorrect Rect2i calculations: intersects and encloses
Clarify expand documentation
Diffstat (limited to 'core')
-rw-r--r-- | core/math/rect2.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/core/math/rect2.h b/core/math/rect2.h index 4ea24e8f88..b14c69302c 100644 --- a/core/math/rect2.h +++ b/core/math/rect2.h @@ -382,16 +382,16 @@ struct _NO_DISCARD_ Rect2i { ERR_PRINT("Rect2i size is negative, this is not supported. Use Rect2i.abs() to get a Rect2i with a positive size."); } #endif - if (position.x > (p_rect.position.x + p_rect.size.width)) { + if (position.x >= (p_rect.position.x + p_rect.size.width)) { return false; } - if ((position.x + size.width) < p_rect.position.x) { + if ((position.x + size.width) <= p_rect.position.x) { return false; } - if (position.y > (p_rect.position.y + p_rect.size.height)) { + if (position.y >= (p_rect.position.y + p_rect.size.height)) { return false; } - if ((position.y + size.height) < p_rect.position.y) { + if ((position.y + size.height) <= p_rect.position.y) { return false; } @@ -405,8 +405,8 @@ struct _NO_DISCARD_ Rect2i { } #endif return (p_rect.position.x >= position.x) && (p_rect.position.y >= position.y) && - ((p_rect.position.x + p_rect.size.x) < (position.x + size.x)) && - ((p_rect.position.y + p_rect.size.y) < (position.y + size.y)); + ((p_rect.position.x + p_rect.size.x) <= (position.x + size.x)) && + ((p_rect.position.y + p_rect.size.y) <= (position.y + size.y)); } _FORCE_INLINE_ bool has_no_area() const { |