bevy/crates/bevy_asset/src
Carter Anderson 6d295036f2 Fix GLTF scene dependencies and make full scene renders predictable (#10745)
# Objective

Fixes #10688

There were a number of issues at play:

1. The GLTF loader was not registering Scene dependencies properly. They
were being registered at the root instead of on the scene assets. This
made `LoadedWithDependencies` fire immediately on load.
2. Recursive labeled assets _inside_ of labeled assets were not being
loaded. This only became relevant for scenes after fixing (1) because we
now add labeled assets to the nested scene `LoadContext` instead of the
root load context. I'm surprised nobody has hit this yet. I'm glad I
caught it before somebody hit it.
3. Accessing "loaded with dependencies" state on the Asset Server is
boilerplatey + error prone (because you need to manually query two
states).

## Solution

1. In GltfLoader, use a nested LoadContext for scenes and load
dependencies through that context.
2. In the `AssetServer`, load labeled assets recursively.
3. Added a simple `asset_server.is_loaded_with_dependencies(id)`

I also added some docs to `LoadContext` to help prevent this problem in
the future.

---

## Changelog

- Added `AssetServer::is_loaded_with_dependencies`
- Fixed GLTF Scene dependencies
- Fixed nested labeled assets not being loaded

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
2023-11-29 17:02:28 -08:00
..
io Do not panic when failing to create assets folder (#10613) (#10614) 2023-11-29 16:47:36 -08:00
processor AssetMetaMode (#10623) 2023-11-29 16:55:39 -08:00
server Fix GLTF scene dependencies and make full scene renders predictable (#10745) 2023-11-29 17:02:28 -08:00
assets.rs Non-blocking load_untyped using a wrapper asset (#10198) 2023-10-26 22:14:32 +00:00
event.rs Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
folder.rs Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
handle.rs Asset v2: Asset path serialization fix (#9756) 2023-09-13 05:43:01 +00:00
id.rs Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
lib.rs AssetMetaMode (#10623) 2023-11-29 16:55:39 -08:00
loader.rs Fix GLTF scene dependencies and make full scene renders predictable (#10745) 2023-11-29 17:02:28 -08:00
meta.rs assets: use blake3 instead of md5 (#10208) 2023-10-23 04:15:04 +00:00
path.rs Don't .unwrap() in AssetPath::try_parse (#10452) 2023-11-29 16:40:48 -08:00
reflect.rs Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
saver.rs Make AssetLoader/Saver Error type bounds compatible with anyhow::Error (#10493) 2023-11-29 16:41:48 -08:00