GLTFLoader: Fix missing associations #22583
Merged
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.
Resolve an issue where association mappings are missing for meshes when several glTF node definitions reference the same mesh-group, and the mesh-group has multiple primitives.
Continued from PR: #22544
Repro this issue:
Load the 2CylinderEngine gltf-sample model.
Walk the node hierarchy and check that each node/mesh has an association.
You will find several objects that do not have associations.
Explanation: Nodes that refer to the same Mesh/Group get cloned, if a Group gets cloned then the association map will not a have record of the clone and needs to be updated, in addition the child meshes of the group also get cloned and those child clones also need to be updated in the association map.
Additional fix:
As a side effect of the cloning there can be several 'source' nodes (the ones getting cloned) that have association mappings but are not actually in the node hierarchy (leaking memory in other words), this PR removes the extraneous mappings.