summaryrefslogtreecommitdiffstats
path: root/scene/debugger
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-02-12 13:33:35 +0100
committerRémi Verschelde <rverschelde@gmail.com>2024-02-12 13:33:35 +0100
commit966a3ffbba5244fb86d63cf366475fba58574e4f (patch)
treeaa4a7f1026db5cbb3b674a302b21c4c87fe982bd /scene/debugger
parent860dbdfaedaafe6223206650c89fa6bd5c9b5cec (diff)
parent97f9dbda8100751729cbda96e4b7ec2f791a0a2c (diff)
downloadredot-engine-966a3ffbba5244fb86d63cf366475fba58574e4f.tar.gz
Merge pull request #86659 from MajorMcDoom/live-debug-local-transform
Improved synchronization of Transforms during live debug sessions
Diffstat (limited to 'scene/debugger')
-rw-r--r--scene/debugger/scene_debugger.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/scene/debugger/scene_debugger.cpp b/scene/debugger/scene_debugger.cpp
index fb7d01f115..d539f45d31 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);
+ }
+ }
+ }
}
}