diff options
author | Zi Ye <major.mcdoom@gmail.com> | 2023-12-30 20:00:41 -0600 |
---|---|---|
committer | Zi Ye <major.mcdoom@gmail.com> | 2024-01-05 17:07:20 -0600 |
commit | 97f9dbda8100751729cbda96e4b7ec2f791a0a2c (patch) | |
tree | ed5493040c9f24e988c5c32086f7668c1ef3312c /scene/debugger | |
parent | 89cc635c0554cb2e518c830969ca4c5eedda0f4e (diff) | |
download | redot-engine-97f9dbda8100751729cbda96e4b7ec2f791a0a2c.tar.gz |
Changed various editor transform operations to be committed in local instead of global space. Fixed a couple of bugs when syncing transforms to debug instance.
Diffstat (limited to 'scene/debugger')
-rw-r--r-- | scene/debugger/scene_debugger.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/scene/debugger/scene_debugger.cpp b/scene/debugger/scene_debugger.cpp index 5603b2dbe4..3b5644af4a 100644 --- a/scene/debugger/scene_debugger.cpp +++ b/scene/debugger/scene_debugger.cpp @@ -630,7 +630,34 @@ void LiveEditor::_node_set_func(int p_id, const StringName &p_prop, const Varian } Node *n2 = n->get_node(np); + // Do not change transform of edited scene root, unless it's the scene being played. + // See GH-86659 for additional context. + bool keep_transform = (n2 == n) && (n2->get_parent() != scene_tree->root); + Variant orig_tf; + + if (keep_transform) { + if (n2->is_class("Node3D")) { + orig_tf = n2->call("get_transform"); + } else if (n2->is_class("CanvasItem")) { + orig_tf = n2->call("_edit_get_state"); + } + } + n2->set(p_prop, p_value); + + if (keep_transform) { + if (n2->is_class("Node3D")) { + Variant new_tf = n2->call("get_transform"); + if (new_tf != orig_tf) { + n2->call("set_transform", orig_tf); + } + } else if (n2->is_class("CanvasItem")) { + Variant new_tf = n2->call("_edit_get_state"); + if (new_tf != orig_tf) { + n2->call("_edit_set_state", orig_tf); + } + } + } } } @@ -674,8 +701,35 @@ void LiveEditor::_node_call_func(int p_id, const StringName &p_method, const Var } Node *n2 = n->get_node(np); + // Do not change transform of edited scene root, unless it's the scene being played. + // See GH-86659 for additional context. + bool keep_transform = (n2 == n) && (n2->get_parent() != scene_tree->root); + Variant orig_tf; + + if (keep_transform) { + if (n2->is_class("Node3D")) { + orig_tf = n2->call("get_transform"); + } else if (n2->is_class("CanvasItem")) { + orig_tf = n2->call("_edit_get_state"); + } + } + Callable::CallError ce; n2->callp(p_method, p_args, p_argcount, ce); + + if (keep_transform) { + if (n2->is_class("Node3D")) { + Variant new_tf = n2->call("get_transform"); + if (new_tf != orig_tf) { + n2->call("set_transform", orig_tf); + } + } else if (n2->is_class("CanvasItem")) { + Variant new_tf = n2->call("_edit_get_state"); + if (new_tf != orig_tf) { + n2->call("_edit_set_state", orig_tf); + } + } + } } } |