-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Fix handles being split by asset_server_managed.
#22261
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
base: main
Are you sure you want to change the base?
Conversation
4e1973e to
dd9e260
Compare
…hould not remove the asset.
dd9e260 to
d54f347
Compare
kristoff3r
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, the logic in track_assets felt a bit complicated but I couldn't find a way to simplify it.
| /// Returns true if the asset's entry was removed. This is not the same as removing the asset | ||
| /// itself - an asset which has not been inserted may still have its entry removed. | ||
| pub(crate) fn try_remove_dropped(&mut self, index: AssetIndex) -> bool { | ||
| use bevy_platform::collections::hash_map::Entry; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why this import needs to be inside this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file defines a type Entry, so the hashmap Entry collides with it. Scoping it here sidesteps that issue.
Objective
Assets::get_strong_handlehas different behaviour to one fromAssetServer::load. #20651.Asset<A>/AssetServerhandles (#20651, #20776) #20874.Solution
Assets::track_assetsnow increments when a "new" message is received, and decrements when a "drop" message is received. The asset entry is dropped if the counter is at 0 after processing all messages.asset_server_managedflag, since we can just lookup the index to see if it's present.handle_drops_to_skipcounter since now we count all new handles, not just those inget_strong_handle.Testing