summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-09-27 17:58:12 +0200
committerGitHub <noreply@github.com>2020-09-27 17:58:12 +0200
commit1a43f55c0763e7961902b21880f918b11e3091b9 (patch)
tree608fbb403ae97f1d55e009dd26eb5a0c222e2253
parent70e54e449909c2f2b08fb4bd23be41abebe82f64 (diff)
parent8e6da0b8082ef0a9ce7f1b53ca3857794582bf76 (diff)
Merge pull request #42371 from groud/fix_error_anchors_move
Fix error when dragging anchors with parent's size == 0
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 9427f82f9e..3e34d486d5 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -863,10 +863,11 @@ Vector2 CanvasItemEditor::_position_to_anchor(const Control *p_control, Vector2
ERR_FAIL_COND_V(!p_control, Vector2());
Rect2 parent_rect = p_control->get_parent_anchorable_rect();
- ERR_FAIL_COND_V(parent_rect.size.x == 0, Vector2());
- ERR_FAIL_COND_V(parent_rect.size.y == 0, Vector2());
- return (p_control->get_transform().xform(position) - parent_rect.position) / parent_rect.size;
+ Vector2 output = Vector2();
+ output.x = (parent_rect.size.x == 0) ? 0.0 : (p_control->get_transform().xform(position).x - parent_rect.position.x) / parent_rect.size.x;
+ output.y = (parent_rect.size.y == 0) ? 0.0 : (p_control->get_transform().xform(position).y - parent_rect.position.y) / parent_rect.size.y;
+ return output;
}
void CanvasItemEditor::_save_canvas_item_ik_chain(const CanvasItem *p_canvas_item, List<float> *p_bones_length, List<Dictionary> *p_bones_state) {