diff options
author | Gilles Roudière <gilles.roudiere@gmail.com> | 2019-06-04 21:58:21 +0200 |
---|---|---|
committer | Gilles Roudière <gilles.roudiere@gmail.com> | 2019-06-04 21:58:21 +0200 |
commit | df0a69bbaca690e1954d5048cc238acc8adeddb8 (patch) | |
tree | 83577e88fd126805e93a3e0425f075a6645320ac /scene/gui | |
parent | 42569f566f7750e355bf07f15008b54677043536 (diff) |
Fixes NaN errors with anchors mode
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/control.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 76275c2420..8cbd6480fb 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -1749,6 +1749,9 @@ Rect2 Control::_compute_child_rect(const float p_anchors[4], const float p_margi void Control::_compute_anchors(Rect2 p_rect, const float p_margins[4], float (&r_anchors)[4]) { Size2 parent_rect_size = get_parent_anchorable_rect().size; + ERR_FAIL_COND(parent_rect_size.x == 0.0); + ERR_FAIL_COND(parent_rect_size.y == 0.0); + r_anchors[0] = (p_rect.position.x - p_margins[0]) / parent_rect_size.x; r_anchors[1] = (p_rect.position.y - p_margins[1]) / parent_rect_size.y; r_anchors[2] = (p_rect.position.x + p_rect.size.x - p_margins[2]) / parent_rect_size.x; |