summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornathanwfranke <nathanwfranke@gmail.com>2020-02-07 14:43:27 -0600
committernathanwfranke <nathanwfranke@gmail.com>2020-02-07 14:43:27 -0600
commite5cb557b73d804b59a5eda30b4b09d3d18ea91ad (patch)
tree648dccafa12d7a8cd256f95b8d9e98f46e84c2dd
parent3c3ed67c3944a555d18fa8b68603f3a68416e27e (diff)
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
-rw-r--r--core/math/rect2.h13
-rw-r--r--servers/visual/visual_server_canvas.cpp2
2 files changed, 14 insertions, 1 deletions
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;
diff --git a/servers/visual/visual_server_canvas.cpp b/servers/visual/visual_server_canvas.cpp
index e07e188ec6..c90e061eb7 100644
--- a/servers/visual/visual_server_canvas.cpp
+++ b/servers/visual/visual_server_canvas.cpp
@@ -168,7 +168,7 @@ void VisualServerCanvas::_render_canvas_item(Item *p_canvas_item, const Transfor
VisualServerRaster::redraw_request();
}
- if ((!ci->commands.empty() && p_clip_rect.intersects(global_rect)) || ci->vp_render || ci->copy_back_buffer) {
+ if ((!ci->commands.empty() && p_clip_rect.intersects_touch(global_rect)) || ci->vp_render || ci->copy_back_buffer) {
//something to draw?
ci->final_transform = xform;
ci->final_modulate = Color(modulate.r * ci->self_modulate.r, modulate.g * ci->self_modulate.g, modulate.b * ci->self_modulate.b, modulate.a * ci->self_modulate.a);