Skip to content
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

Arc-d assets #15813

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
e6330d2
Remove all the `get_mut` functions from `Assets`.
andriyDev Oct 8, 2024
6fe8cc1
Make `Assets` store assets as `Arc<A>` instead of just `A`.
andriyDev Oct 8, 2024
b24e050
Separate out inserting/adding an owned asset from the arc version.
andriyDev Oct 9, 2024
ea5703a
Implement `get_cloned_mut`.
andriyDev Oct 8, 2024
8858784
Implement `get_inplace_mut`.
andriyDev Oct 8, 2024
adab62e
Implement `get_reflect_cloned_mut`.
andriyDev Oct 9, 2024
8a65303
Update most calls in bevy_asset to either use a `.into()` or one of t…
andriyDev Oct 9, 2024
6e6de65
Make RenderAssets take an `Arc` to the source asset and extract sourc…
andriyDev Oct 9, 2024
8c016a1
Make all the crates use the new `get_*_mut` variants, or use `Arc<Sou…
andriyDev Oct 9, 2024
3c66b59
Update the examples to use the `get_*_mut` variants or otherwise deal…
andriyDev Oct 9, 2024
2314f79
Create an example for the use of asset arcing.
andriyDev Sep 27, 2024
1ee7217
Add a nice big warning on `get_arc` about holding the `Arc` for long …
andriyDev Oct 10, 2024
961fc14
Rewrite any "Arc-ed" to "Arc-d" to make it consistent with other uses.
andriyDev Nov 1, 2024
a26d49f
Improve the MutableAssetError messages to match Rust guidelines.
andriyDev Nov 1, 2024
1f9d313
Rename `get_inplace_mut` to `get_in_place_mut`.
andriyDev Nov 1, 2024
5611e11
Fix the example using bad wording.
andriyDev Nov 1, 2024
d51a0b2
Switch MutableAssetError to use thiserror instead of derive_more.
andriyDev Dec 11, 2024
e40384e
Fix the `asset_changed` test by using `get_inplace_mut`.
andriyDev Dec 29, 2024
2ed2094
Make the docs for `AssetChanged` reference `get_cloned_mut` instead o…
andriyDev Dec 29, 2024
9289a07
Fix the `mixed_lighting` example to use `get_cloned_mut`.
andriyDev Dec 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,17 @@ description = "Demonstrates various methods to load assets"
category = "Assets"
wasm = false

[[example]]
name = "arc_asset"
path = "examples/asset/arc_asset.rs"
doc-scrape-examples = true

[package.metadata.example.arc_asset]
name = "Arc'd Assets"
description = "Demonstrates how to acquire Arc'd assets and use them in an async context"
category = "Assets"
wasm = false

[[example]]
name = "asset_settings"
path = "examples/asset/asset_settings.rs"
Expand Down
10 changes: 5 additions & 5 deletions crates/bevy_asset/src/asset_changed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ impl<'w, A: AsAssetId> AssetChangeCheck<'w, A> {
///
/// Unlike `Changed<A>`, this is true whenever the asset for the `A`
/// in `ResMut<Assets<A>>` changed. For example, when a mesh changed through the
/// [`Assets<Mesh>::get_mut`] method, `AssetChanged<Mesh>` will iterate over all
/// entities with the `Handle<Mesh>` for that mesh. Meanwhile, `Changed<Handle<Mesh>>`
/// will iterate over no entities.
/// [`Assets<Mesh>::get_cloned_mut`] method, `AssetChanged<Mesh>` will iterate
/// over all entities with the `Handle<Mesh>` for that mesh. Meanwhile,
/// `Changed<Handle<Mesh>>` will iterate over no entities.
///
/// Swapping the actual `A` component is a common pattern. So you
/// should check for _both_ `AssetChanged<A>` and `Changed<A>` with
Expand All @@ -121,7 +121,7 @@ impl<'w, A: AsAssetId> AssetChangeCheck<'w, A> {
/// If no `A` asset updated since the last time the system ran, then no lookups occur.
///
/// [`AssetEvents`]: crate::AssetEvents
/// [`Assets<Mesh>::get_mut`]: crate::Assets::get_mut
/// [`Assets<Mesh>::get_cloned_mut`]: crate::Assets::get_cloned_mut
pub struct AssetChanged<A: AsAssetId>(PhantomData<A>);

/// [`WorldQuery`] fetch for [`AssetChanged`].
Expand Down Expand Up @@ -362,7 +362,7 @@ mod tests {
.iter()
.find_map(|(h, a)| (a.0 == i).then_some(h))
.unwrap();
let asset = assets.get_mut(id).unwrap();
let asset = assets.get_in_place_mut(id).unwrap();
println!("setting new value for {}", asset.0);
asset.1 = "new_value";
};
Expand Down
Loading
Loading