From e5cb557b73d804b59a5eda30b4b09d3d18ea91ad Mon Sep 17 00:00:00 2001 From: nathanwfranke Date: Fri, 7 Feb 2020 14:43:27 -0600 Subject: Fix bug where Control at origin with 0 size not rendered Make a new method instead to make the code more elegant Move Function down a bit --- core/math/rect2.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'core') diff --git a/core/math/rect2.h b/core/math/rect2.h index 9017377770..0d2e7eb6e5 100644 --- a/core/math/rect2.h +++ b/core/math/rect2.h @@ -60,6 +60,19 @@ struct Rect2 { 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; + + return true; + } + inline real_t distance_to(const Vector2 &p_point) const { real_t dist = 0.0; -- cgit v1.2.3