Merge pull request #39378 from mbrlabs/basis-fix-master

Re-apply basis of newly added node (via drag-n-drop) in editor viewport
This commit is contained in:
Rémi Verschelde 2020-06-08 08:23:44 +02:00 committed by GitHub
commit ba4ae6225b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 8 deletions

View File

@ -3658,16 +3658,20 @@ 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_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)); 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 *node3d = Object::cast_to<Node3D>(instanced_scene);
Node3D *parent_spatial = Object::cast_to<Node3D>(parent); if (node3d) {
if (parent_spatial) { Transform global_transform;
global_transform = parent_spatial->get_global_gizmo_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.basis *= node3d->get_transform().basis;
editor_data->get_undo_redo().add_do_method(instanced_scene, "set_global_transform", global_transform);
} }
global_transform.origin = spatial_editor->snap_point(_get_instance_position(p_point));
editor_data->get_undo_redo().add_do_method(instanced_scene, "set_global_transform", global_transform);
return true; return true;
} }