-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Need some way to nest labeled assets #18010
Comments
I took a stab at fixing this but looks like it's not so trivial. Or rather, there's a deeper bug lurking. Turns out I think we need to propagate the path into these subassets. We treat the "root" subasset of "b.ron" as a regular subasset of "a.txt", so we need to somehow set the path of its subassets to be "a.txt". |
…ate label. (#18013) # Objective - Makes #18010 more easily debuggable. This doesn't solve that issue, but protects us from it in the future. ## Solution - Make `LoadContext::add_labeled_asset` and friends return an error if it finds a duplicate asset. ## Testing - Added a test - it fails before the fix. --- ## Migration Guide - `AssetLoader`s must now handle the case of a duplicate subasset label when using `LoadContext::add_labeled_asset` and its variants. If you know your subasset labels are unique by construction (e.g., they include an index number), you can simply unwrap this result.
Ok I've figured out more of the problem. Here's a diagram I came up with:
In essence, the handles we store in the "nested" asset (in the nested loader) correspond to a different path than "root". That means when we look up the handles of assets in "nested", those assets will never get loaded, since they were loaded as subassets of "root". I don't understand yet how #15481 broke this. It seems to me like this problem should have been just the same in that situation... |
Now I think I understand the full scope of the issue. Nested asset loading is weird... (Also to be clear, this is all addressing that "deeper bug" I mentioned above). The problem is that before #15481,
This means
#15481 (my PR) assumed we were only holding the first kind of asset. However this is a problem for the second kind of asset. The nested asset loaded the asset assuming the path was for the nested asset. That means the handles are all related to the path "nested#subasset_name". After #15481, when we merge the We could prevent registering nested-loaded assets as subassets, but then any handles you get from that nested load are useless. Unless we register these nested-loaded assets as such in Nested asset loading is very weird. It's not just parsing bytes - it can load another actual asset. I think we need to take a more general look and redesign nested asset loading. I have a feeling we can consolidate a lot of the loading stuff. But I digress. |
There's another issue creeping up that I'm not sure how to handle. AFAICT, nested-loading an asset path with a label is broken. Unless I'm missing something, it will give you the root asset when you requested the labeled asset. Unfortunately, we're in a bind to fix this. If we properly return the labeled asset, we won't know which subassets are relevant to that subasset (since we remove that information when we merge subassets of subassets). So any handles in that subasset can't be found, so we can't package them up into CompleteLoadedAsset, and we can't register them in the root loader. Before #15481, this was more likely to work correctly (since we could register subassets to their "parent" subasset), though it still wasn't guaranteed. One immediate solution: we could just panic if you pass a label when doing a nested asset load. At least this would prevent erroneous requests. |
Bevy version
0.16-dev after #15481
Overview
If you have an asset that loads nested glTFs, for example my
bevy-glxf-loader
, then if you have more than one glTF in that asset the names likeScene0
,Mesh0
, etc. will collide. What I'd like is to be able to namespace those loaded assets with a prefix of some kind.The text was updated successfully, but these errors were encountered: