fix: Assimp skeleton/animation importer for models with duplicate node names#2444
Merged
Conversation
Eideren
reviewed
Sep 13, 2024
Eideren
left a comment
Collaborator
There was a problem hiding this comment.
Looks good, just one nitpick
| { | ||
| nodeIndices = new(); | ||
| duplicateNodeNameToNodeIndices[originalNodeName] = nodeIndices; | ||
| //Logger.Warning($"Duplicate node name found: {originalNodeName}. Animations may not play correctly if this node is used in an animation."); |
Collaborator
There was a problem hiding this comment.
Unrelated commented out line afaict ?
Contributor
Author
There was a problem hiding this comment.
I was hesitant on whether to log a warning here, because technically the whole point of the other code is to actually try to resolve the duplicate nodes.
But now I just realized I can just output this at Info level.
Contributor
Author
There was a problem hiding this comment.
Done. Changed to output at Info level, and rebased the commit to the latest.
…ect node when a model has duplicate node names
34268e7 to
32bde64
Compare
Collaborator
|
Thanks ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Details
See model in #2406 (be aware the second animation seems to play strangely, but this is consistent with how it plays in Blender 3.6 - it didn't import properly in a higher version of Blender)
Assimp has a generic 'Node' hierarchy structure and a 'Bone' list (per mesh).
Each Bone has a corresponding 'Node', however the link between the two is only done by name.
Unfortunately, this is a problem when a model has duplicate names, eg. the model's armature and bone, and Stride will more than likely link the 'Bone' to the non-Bone node.
This fix attempts to make an educated guess whenever duplicated names occurs.
If it fails to properly detect what should be linked, then it'll output a warning/error telling the end-user to make the name unique.
While
aiPostProcessSteps.aiProcess_PopulateArmatureDatadoes exist on the importer which is supposed to link the bone to the node, it does not make any effort to correctly link a bone to the bone node if duplicate names exist (it just searches for the first matching name), so this is not used.Related Issue
This is a fundamental flaw in Assimp, assimp/assimp#4064 may help if it gets resolved.
Fixes #2406
Types of changes
Checklist