Merge pull request #88269 from MajorMcDoom/live-debug-local-transform

Fix an edge case bug in drag-and-drop Node3D spawning.
This commit is contained in:
Rémi Verschelde 2024-02-13 11:25:20 +01:00
commit fbe8a1dfa2
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 10 additions and 1 deletions

View File

@ -4364,7 +4364,16 @@ bool Node3DEditorViewport::_create_instance(Node *parent, String &path, const Po
Node3D *node3d = Object::cast_to<Node3D>(instantiated_scene);
if (node3d) {
undo_redo->add_do_method(instantiated_scene, "set_transform", node3d->get_transform());
Transform3D parent_tf;
Node3D *parent_node3d = Object::cast_to<Node3D>(parent);
if (parent_node3d) {
parent_tf = parent_node3d->get_global_gizmo_transform();
}
Transform3D new_tf = node3d->get_transform();
new_tf.origin = parent_tf.xform_inv(preview_node_pos);
undo_redo->add_do_method(instantiated_scene, "set_transform", new_tf);
}
return true;