summaryrefslogtreecommitdiff
path: root/editor/plugins/node_3d_editor_plugin.cpp
diff options
context:
space:
mode:
authorMarcus Brummer <mbrlabs7@gmail.com>2020-06-07 22:09:41 +0200
committerMarcus Brummer <mbrlabs7@gmail.com>2020-06-07 22:09:41 +0200
commit41af859c68d03486a9efbdd4bb4399133b3c6974 (patch)
treea0fb6efec36164007d4c946ec0d2c81a3e34e942 /editor/plugins/node_3d_editor_plugin.cpp
parentec1bf96e412b7a207ffb55d6acd56b25eb25845f (diff)
Re-apply basis of newly added node (via drag-n-drop) in editor viewport
Diffstat (limited to 'editor/plugins/node_3d_editor_plugin.cpp')
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index f59b4171b4..2dd29f7046 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -3658,15 +3658,19 @@ bool Node3DEditorViewport::_create_instance(Node *parent, String &path, const Po
editor_data->get_undo_redo().add_do_method(ed, "live_debug_instance_node", editor->get_edited_scene()->get_path_to(parent), path, new_name);
editor_data->get_undo_redo().add_undo_method(ed, "live_debug_remove_node", NodePath(String(editor->get_edited_scene()->get_path_to(parent)) + "/" + new_name));
- Transform global_transform;
- Node3D *parent_spatial = Object::cast_to<Node3D>(parent);
- if (parent_spatial) {
- global_transform = parent_spatial->get_global_gizmo_transform();
- }
+ Node3D *node3d = Object::cast_to<Node3D>(instanced_scene);
+ if (node3d) {
+ Transform global_transform;
+ Node3D *parent_node3d = Object::cast_to<Node3D>(parent);
+ if (parent_node3d) {
+ global_transform = parent_node3d->get_global_gizmo_transform();
+ }
- global_transform.origin = spatial_editor->snap_point(_get_instance_position(p_point));
+ global_transform.origin = spatial_editor->snap_point(_get_instance_position(p_point));
+ global_transform.basis *= node3d->get_transform().basis;
- editor_data->get_undo_redo().add_do_method(instanced_scene, "set_global_transform", global_transform);
+ editor_data->get_undo_redo().add_do_method(instanced_scene, "set_global_transform", global_transform);
+ }
return true;
}