Skip to content

Arc-d assets #15813

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

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
855753b
Remove all the `get_mut` functions from `Assets`.
andriyDev Oct 8, 2024
2263910
Make `Assets` store assets as `Arc<A>` instead of just `A`.
andriyDev Oct 8, 2024
68efabd
Separate out inserting/adding an owned asset from the arc version.
andriyDev Oct 9, 2024
d293199
Implement `get_cloned_mut`.
andriyDev Oct 8, 2024
b93a63d
Implement `get_inplace_mut`.
andriyDev Oct 8, 2024
8818bbb
Implement `get_reflect_cloned_mut`.
andriyDev Oct 9, 2024
d4b20c1
Update most calls in bevy_asset to either use a `.into()` or one of t…
andriyDev Oct 9, 2024
f4a1e27
Make RenderAssets take an `Arc` to the source asset and extract sourc…
andriyDev Oct 9, 2024
1480923
Make all the crates use the new `get_*_mut` variants, or use `Arc<Sou…
andriyDev Oct 9, 2024
901d843
Update the examples to use the `get_*_mut` variants or otherwise deal…
andriyDev Oct 9, 2024
603ea1b
Create an example for the use of asset arcing.
andriyDev Sep 27, 2024
4822dbc
Add a nice big warning on `get_arc` about holding the `Arc` for long …
andriyDev Oct 10, 2024
a9341f3
Rewrite any "Arc-ed" to "Arc-d" to make it consistent with other uses.
andriyDev Nov 1, 2024
add3c66
Improve the MutableAssetError messages to match Rust guidelines.
andriyDev Nov 1, 2024
f6a6505
Rename `get_inplace_mut` to `get_in_place_mut`.
andriyDev Nov 1, 2024
d13ca5f
Fix the example using bad wording.
andriyDev Nov 1, 2024
88098ce
Switch MutableAssetError to use thiserror instead of derive_more.
andriyDev Dec 11, 2024
e794441
Fix the `asset_changed` test by using `get_inplace_mut`.
andriyDev Dec 29, 2024
3dc1a8e
Make the docs for `AssetChanged` reference `get_cloned_mut` instead o…
andriyDev Dec 29, 2024
f02d558
Fix the `mixed_lighting` example to use `get_cloned_mut`.
andriyDev Dec 29, 2024
07931ad
Fix the `many_materials` and `edit_material_on_gltf` examples.
andriyDev Feb 6, 2025
7eca4aa
Fix the `specular_tint` example.
andriyDev Feb 6, 2025
9d4a394
Merge branch 'main' into arc-assets
mockersf Mar 2, 2025
bda9f50
Replace `gen` with `r#gen` to transition to edition 2024.
andriyDev Mar 2, 2025
b8a3e1f
Fix the many_cubes stress test to use Arc::make_mut for the materials.
andriyDev Mar 2, 2025
724cb25
Merge branch 'main' into arc-assets
andriyDev Mar 3, 2025
b332f7b
Rename `heights.li.ron` to `arc_asset_heights.li.ron`.
andriyDev Mar 3, 2025
338aa26
Rename `arc_asset` example to `access_asset_from_async`.
andriyDev Mar 4, 2025
da9f2a9
Merge branch 'main' into arc-assets
andriyDev Mar 4, 2025
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 @@ -1694,6 +1694,17 @@ description = "Demonstrates various methods to load assets"
category = "Assets"
wasm = false

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

[package.metadata.example.access_asset_from_async]
name = "Access Asset from Async"
description = "Demonstrates how to access and use assets 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 @@ -355,7 +355,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