-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Children in spawned gltf scenes are incorrectly ordered #17720
Comments
It seems that the order of the children within the spawned hierarchy has changed.
So the following from
So the following patch fixes the example: // First joint is the second child of the mesh node.
- let first_joint_entity = mesh_node_parent[1];
+ let first_joint_entity = mesh_node_parent[0];
// Get `Children` in the first joint.
let first_joint_children = parents.get(first_joint_entity).unwrap(); However, if I'm understanding the situation right, this may be pointing to some sort of bug in scene spawning or entity cloning that we want to fix. |
cc @cart |
Nice catch! This became visible in #17687 because that fixed the "duplicate entities on spawn" bug introduced in #17398. But the reordering was actually introduced in #17398. The problem is that we're spawning a flat (arbitrarily ordered) list of entities in the SceneSpawner (ex: iter archetypes, spawn each entity in the archetype). We ignore the The original RelationshipTarget is the only thing holding the order information. We cannot discard it. Some options:
I was leaning toward (3), as it seemed like our "least bad" option. It preserves order across all relationship types, doesn't introduce overhead (just one more branch ... and in fact it is actually faster because we're skipping the insert code), and it allows us to spawn/clone in arbitrary orders (including cache-efficient orders like iterating archetypes or tables). We can trust that the contents of the RelationshipTarget collections are valid, as they were generated via the normal hooks flows. Sadly it has a fatal flaw: cloning can trigger hooks/observers, which can trigger arbitrary spawns. In those cases, with a global flag the triggered spawns wouldn't properly maintain their relationships. This means we need this configuration to be properly scoped to the call (ex: add a new set of spawn / insert methods that pass the relevant information to the hook so it can skip only where relevant). So thats what I'm leaning toward now. If anyone has other ideas let me know. |
gltf_skinned_mesh
example panics# Objective Fix gltf validation errors in `Fox.glb`. Inspired by #8099, but that issue doesn't appear to describe a real bug to fix, as far as I can tell. ## Solution Use the latest version of the Fox from [glTF-Sample-Assets](https://github.com/KhronosGroup/glTF-Sample-Assets/blob/main/Models/Fox/glTF-Binary/Fox.glb). ## Testing Dropped both versions in https://github.khronos.org/glTF-Validator/ `cargo run --example animated_mesh` seems to still look fine. Before: ``` The asset contains errors. "numErrors": 126, "numWarnings": 4184, ``` After: ``` The asset is valid. "numErrors": 0, "numWarnings": 0, ``` ## Discussion The 3d testbed was panicking with ``` thread 'main' panicked at examples/testbed/3d.rs:288:60: called `Result::unwrap()` on an `Err` value: QueryDoesNotMatch(35v1 with components Transform, GlobalTransform, Visibility, InheritedVisibility, ViewVisibility, ChildOf, Children, Name) ``` Which is bizarre. I think this might be related to #17720, or maybe the structure of the gltf changed. I fixed it by using updating the testbed to use a more robust method of finding the correct entity as is done in `animated_mesh`.
Bevy version
main, bisected to #17687
Relevant system information
SystemInfo { os: "macOS 15.3 Sequoia", kernel: "24.3.0", cpu: "Apple M4 Max", core_count: "16", memory: "64.0 GiB" }
AdapterInfo { name: "Apple M4 Max", vendor: 0, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Metal }
Also failing on linux/mac in the example runner.
What you did
cargo run --example gltf_skinned_mesh
What went wrong
The text was updated successfully, but these errors were encountered: