From 97f9dbda8100751729cbda96e4b7ec2f791a0a2c Mon Sep 17 00:00:00 2001 From: Zi Ye Date: Sat, 30 Dec 2023 20:00:41 -0600 Subject: 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. --- scene/debugger/scene_debugger.cpp | 54 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'scene/debugger') 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); + } + } + } } } -- cgit v1.2.3