-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NodePath properly updated in the editor in more cases when nodes are moved or renamed #49812
NodePath properly updated in the editor in more cases when nodes are moved or renamed #49812
Conversation
f053721
to
9827a3c
Compare
Pushed a fix for errors in |
Fix more cases of node path needing an update when nodes are renamed or moved in the editor. Built-in node properties: Before, node paths were checked only for script export variables. Now all properties are checked from the node, which includes built-in node properties. Allows proper node path updates for nodes like remote transform, physics joints, etc. Arrays and dictionaries: Node paths nested in array and dictionary properties are now also updated in the editor. Also update the documentation to be clear about node path update in the editor and at runtime. Co-authored-by: latorril <latorril@gmail.com>
9827a3c
to
3e4e530
Compare
|
||
// Update the node itself if it has a valid node path and has not been deleted. | ||
if (p_root_path == F->get().first && p_node_path != NodePath() && F->get().second != NodePath()) { | ||
NodePath abs_path = NodePath(String(root_path_new).plus_file(p_node_path)).simplified(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just pushed an extra fix here that fixes errors when moving a Skeleton node with BoneAttachment nodes as its children.
Building the new path now uses root_path_new
instead of p_root_path
, otherwise in cases where the root path and the child path change, this code would generate a buggy node path relative to the old root.
Thanks! |
static bool _update_node_path(const NodePath &p_root_path, NodePath &p_node_path, List<Pair<NodePath, NodePath>> *p_renames); | ||
static bool _check_node_path_recursive(const NodePath &p_root_path, Variant &p_variant, List<Pair<NodePath, NodePath>> *p_renames); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just wondering, do those actually need to be static
?
Also, since p_node_path
and p_variant
are used to return new values, they should probably be named with a r_
prefix instead (our convention for a mutable reference that will get changed by the method).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They don't have to be static
but they can. I generally set methods as static
when possible to make it clear they don't use anything from the class. Do we have a different rule about when to use static
?
Makes sense for the missing r_
, prefix, I can make a fixup PR to change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They don't have to be
static
but they can. I generally set methods asstatic
when possible to make it clear they don't use anything from the class. Do we have a different rule about when to usestatic
?
I don't think we have a specific rule, I'm just asking out of curiosity (and lack of expertise on the actual impact of making things static in C++). If it doesn't hurt and makes the code clearer, that's fine with me :)
Cherry-picked for 3.4. |
Does this fix InstancePlaceHolders too by any chance (#44720 (comment))? |
@Flavelius I don't know much about instance placeholders, but it looks like it's a different issue. What this PR fixes is |
This feature is great, but there is one problematic use case, which could however be solved with something like: BackgroundIn my case the problem occurs due to a custom "compiling" system, where the source scene contains extra nodes and setup, which is then "compiled" into a game-ready scene including various optimizations. One of the optimizations is storing all node paths within the compiled scene as node paths from the root node of baking, so there's no need to get them many times and again when reused. (On the uncompiled source side, things function like Godot expects: each path starts from the node it's stored in.) ProblemDue to the new auto correction feature (which I really like otherwise), I'm getting errors / warnings in the editor whenever the tree is changed (about paths not being found) - and even worse, Godot might in certain cases do the auto-correction which messes up the functioning of the compiled scene. Solutions
|
Fix more cases of node path needing an update when nodes are renamed or moved in the editor.
Built-in node properties:
Before, node paths were checked only for script export variables. Now all properties are checked from the node, which includes built-in node properties.
Allows proper node path updates for nodes like remote transform, physics joints, etc.
Arrays and dictionaries:
Node paths nested in array and dictionary properties are now also updated in the editor.
Also update the documentation to be clear about node path update in the editor and at runtime.
Fixes #49810
Fixes #49811
Credits to @latorril for finding the issue and investigating the cause.