-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Fix Make Unique (Recursive) failing with AnimationNode
s
#89410
base: master
Are you sure you want to change the base?
Fix Make Unique (Recursive) failing with AnimationNode
s
#89410
Conversation
5ac4127
to
d9b3774
Compare
I'm wondering how #77855 caused the regression and why the fix is in the affected resource... Did it expose some hidden bug? |
This comment was marked as outdated.
This comment was marked as outdated.
The standard |
OK, so after some time to think, I realize I jumped the gun when it came to figuring the problem. My previous post had some baseless assumptions and misunderstandings that I didn't realize until later. Fairly confidant this one is more accurate. A big thing I found out when stepping through is that deep duplicate calls void EditorResourcePicker::_duplicate_selected_resources() {
for (TreeItem *item = duplicate_resources_tree->get_root(); item; item = item->get_next_in_tree()) {
[...]
if (meta.size() == 1) { // Root.
edited_resource = unique_resource;
emit_signal(SNAME("resource_changed"), edited_resource);
_update_resource();
} else {
Array parent_meta = item->get_parent()->get_metadata(0);
Ref<Resource> parent = parent_meta[0];
parent->set(meta[1], unique_resource);
}
}
} Due to a better understanding, I can simplify my bandaid solution to just an if check of bool AnimationNodeBlendTree::_set(const StringName &p_name, const Variant &p_value) {
[...]
if (what == "node") {
Ref<AnimationNode> anode = p_value;
if (anode.is_valid() /*->*/&& !has_node(node_name)/*<-*/) {
add_node(node_name, p_value);
}
return true;
} [...] Or that's what I would say, but it solves nothing, it isn't fully duplicating. It works in that it will no longer update position/name changes simultaneously between copied AnimationTrees, but the animation in a The above description actually matches the outcome of using no fix... which makes sense. It's effectively the same as with the error, since it disregards the second set of nodes being sent to From brief testing with print in Summary:
That's my best estimation, for now. I'll probably prod it some more later, when I have time. |
I found out why the resource is set twice. This is the old behavior: New Behavior: The steps of setting and duplicating sub-resources while Resource's And animation blend tree does not like if you set the same property again, even if to another value. This is problem with |
Fixes #87766
Issue(regression from 93d180b) is caused by Make Unique (Recursive) eventually calling
AnimationNodeBlendTree::add_node()
andAnimationNodeStateMachine::add_node()
, which will throw an error if the new node(AnimationNode
) shares the name of any in-use node. On top of that, even if it doesn't err, it will reset the position(BlendTree
,StateMachine
) and connections(BlendTree
) in the AnimationTree bottom panel. My naïve solution was to add if checks, to know when it's trying to replace a node with a duplicate.There is probably a better solution by intercepting earlier, i.e. as seen in the below code snippet. However, I do not know enough, so I would only be fumbling if I tried it myself.
Note: The way it worked before the regression, it would do a deep duplication (
res->duplicate(true)
) of the root node and replace it(doesn't cause errors for some reason). Maybe that info helps in finding a better solution.