-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
[4.x] Sorts AnimationNodeBlendTree node connections for deterministic output #79530
Conversation
Can you read the https://docs.godotengine.org/en/stable/contributing/workflow/pr_workflow.html? In particular the squashed guideline. I'm interested in reviewing this. @TokageItLab too. |
…l be deterministic when saving blend trees. Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
69f2940
to
bc135bb
Compare
Done! Should be all squashed now on both PRs. |
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.
LGTM, haven't tested but makes sense
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.
This problem is caused by the fact that the HashMap nodes
do not have an order.
However, changing it to RBMap nodes
did not solve the problem. When I look at the RBMap nodes
when adding a node to add_node()
, it appears that the insertion into the RBMap is not done uniquely by key. @reduz Do you know anything about this?
So why is this problem not happening in other resources?
For example, VisualShader also uses GraphNode, but VisualShader's connections are stored for each node in a child of the "nodes/"
path.
On the other hand, the AnimationBlendTree stored it in an ordered array called "node_connections"
, even though the nodes are unordered. However, since the nodes are sorted and stored in .tres
, this problem can be solved by storeing "node_connections"
as children of "nodes"
means "nodes/XXX/connections"
. (Then, conversion code is needed for getter and setter for compatibility)
So, this PR's solution does not seem so smart, it may be applicable to 3.x, but at least, what needs to be sorted is the order of the nodes
, not the input_node
s. Also, it should only be needed when recording to .tres
so it needs to be in _get()
(this fix should not be necessary for BlendTreeEditor, etc.).
This isn't really a called for phrasing and isn't very constructive |
Let me rephrase. Sorting where it is not needed is not good for performance. Also, this fix does not address the fundamental problem and is just a stopgap, and the implementation is inconsistent when compared to other classes. |
I tried to store it in "nodes/XXX/connections". Indeed, it has unique order. However, the result seems to be that it has to be kept separately as "node_connections". This is because there is a restriction that "connections" must be loaded after all other nodes. Also, when I investigated again why I sent #79595 which can supersede this PR. |
Superseded by #79595. |
Thank you for your work, and hope to see other contributions from you going forward, even if this didn't pan out! |
This should resolve #42788.
Is there a way to pull off the sort without the temporary
String
copies? I wasn't sure howStringName
is set up but the==
and<
operators seem to be just comparing the inner_data
pointers, so unless I missed something, the pointers would have to be pre-sorted in memory for that to be used for comparison.Mirroring this in a 3.x PR as well.