diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-02-21 08:39:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-21 08:39:37 +0100 |
commit | b829615150e9c242025dbe7a6d06844e1bbb133a (patch) | |
tree | a1e2ddf9b92058d5a04e1e7556755a8ae14dbac4 /editor | |
parent | cb27e3819bf680bc9064aafee6a9381b0ee89a25 (diff) | |
parent | 3a9fb3aff0d8f882c06826f5a7ca6d06a0a4fd34 (diff) |
Merge pull request #58372 from KoBeWi/orphan_ci
Fix 2D instance drop position
Diffstat (limited to 'editor')
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 76558eb946..7b79a8135f 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -5500,16 +5500,18 @@ bool CanvasItemEditorViewport::_create_instance(Node *parent, String &path, cons editor_data->get_undo_redo().add_do_method(ed, "live_debug_instance_node", edited_scene->get_path_to(parent), path, new_name); editor_data->get_undo_redo().add_undo_method(ed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(parent)) + "/" + new_name)); - CanvasItem *parent_ci = Object::cast_to<CanvasItem>(parent); - if (parent_ci) { + CanvasItem *instance_ci = Object::cast_to<CanvasItem>(instantiated_scene); + if (instance_ci) { Vector2 target_pos = canvas_item_editor->get_canvas_transform().affine_inverse().xform(p_point); target_pos = canvas_item_editor->snap_point(target_pos); - target_pos = parent_ci->get_global_transform_with_canvas().affine_inverse().xform(target_pos); - // Preserve instance position of the original scene. - CanvasItem *instance_ci = Object::cast_to<CanvasItem>(instantiated_scene); - if (instance_ci) { - target_pos += instance_ci->_edit_get_position(); + + CanvasItem *parent_ci = Object::cast_to<CanvasItem>(parent); + if (parent_ci) { + target_pos = parent_ci->get_global_transform_with_canvas().affine_inverse().xform(target_pos); } + // Preserve instance position of the original scene. + target_pos += instance_ci->_edit_get_position(); + editor_data->get_undo_redo().add_do_method(instantiated_scene, "set_position", target_pos); } |