Skip to content

Load each glTF skin at most once. #18026

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

Merged
merged 1 commit into from
Feb 25, 2025

Conversation

pcwalton
Copy link
Contributor

Currently, we reload a glTF skin each time we encounter a node that references it. By checking for duplicates, PR #18013 turned this into a fatal error. But this was always wasteful. This commit fixes the issue by caching each skin by its index as we load it.

The Maya babylon.js export plugin likes to emit glTFs with multiple nodes that reference the same skin, so this effectively unbreaks Maya rigs.

Currently, we reload a glTF skin each time we encounter a node that
references it. By checking for duplicates, PR bevyengine#18013 turned this into a
fatal error. But this was always wasteful. This commit fixes the issue
by caching each skin by its index as we load it.

The Maya babylon.js export plugin likes to emit glTFs with multiple
nodes that reference the same skin, so this effectively unbreaks Maya
rigs.
@pcwalton pcwalton added A-glTF Related to the glTF 3D scene/model format S-Needs-Review Needs reviewer attention (from anyone!) to move forward C-Bug An unexpected or incorrect behavior P-Regression Functionality that used to work but no longer does. Add a test for this! P-Crash A sudden unexpected crash labels Feb 25, 2025
@@ -801,7 +801,7 @@ async fn load_gltf<'a, 'b, 'c>(

let mut nodes = HashMap::<usize, Handle<GltfNode>>::default();
let mut named_nodes = <HashMap<_, _>>::default();
let mut skins = vec![];
let mut skins = <HashMap<_, _>>::default();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This syntax is crazy. We can't just do HashMap::default() here?

@alice-i-cecile alice-i-cecile added this to the 0.16 milestone Feb 25, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Feb 25, 2025
@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Feb 25, 2025
Merged via the queue into bevyengine:main with commit df5e3a7 Feb 25, 2025
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-glTF Related to the glTF 3D scene/model format C-Bug An unexpected or incorrect behavior P-Crash A sudden unexpected crash P-Regression Functionality that used to work but no longer does. Add a test for this! S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants