bevy/crates
charlotte df14443db9
Add AssetChanged query filter (#16810)
# Objective

Implement a new `AssetChanged` query filter that allows users to query
for entities whose related assets may have changed.

- Closes https://github.com/bevyengine/bevy/issues/5069
- Unblocks #16420. Currently, `cold-specialization`, a key rendering
optimization for unlocking ancillary benefits of the retained render
world, is blocked on being unable detect all scenarios in which an
entity's mesh/material changes using events and observers. An
`AssetChanged` filter will drastically simplify our implementation and
be more robust to future changes.

Originally implemented by @nicopap in #5080.

## Solution

- Adds a new `AssetChanged` query filter that initializes a
`AssetChanges<A>` resource that tracks changed assets and ticks in
`asset_events`.
- ~Reverts #13343 and changes the api of `get_state` to accept `impl
Into<UnsafeWorldCell<'w>>` to allow accessing the `AssetChanges<A>`
resource.~
- Adds a `AsAssetId` trait used for newtype handle wrappers (e.g.
`Mesh3d`) that allows associating a component with the underlying
`Asset` it represents.

## Testing

- Tests are added for `AssetChanged`.
- TBD on performance. We are going to add this `Mesh3d` and
`MeshMaterial3d` (etc) in the renderer. Long term wins in render
performance this unblocks should swamp tracking overhead for any
realistic workload.

## Migration Guide

- The `asset_events` system is no longer public. Users should order
their systems relative to the `AssetEvents` system set.

---------

Co-authored-by: Nicola Papale <nico@nicopap.ch>
Co-authored-by: Patrick Walton <pcwalton@mimiga.net>
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: Chris Russell <8494645+chescock@users.noreply.github.com>
2024-12-17 18:57:08 +00:00
..
bevy_a11y
bevy_animation Support tuple structs in AnimatedField (#16747) 2024-12-11 17:06:08 +00:00
bevy_app Rust 1.83, allow -> expect (missing_docs) (#16561) 2024-12-16 23:27:57 +00:00
bevy_asset Add AssetChanged query filter (#16810) 2024-12-17 18:57:08 +00:00
bevy_audio Move Volume and GlobalVolume to own file (#16838) 2024-12-16 19:28:30 +00:00
bevy_color Deny derive_more error feature and replace it with thiserror (#16684) 2024-12-06 17:03:55 +00:00
bevy_core Update hashbrown to 0.15 (#15801) 2024-12-10 19:45:50 +00:00
bevy_core_pipeline Implement bindless lightmaps. (#16653) 2024-12-16 23:37:06 +00:00
bevy_derive Rust 1.83, allow -> expect (missing_docs) (#16561) 2024-12-16 23:27:57 +00:00
bevy_dev_tools Draw the UI debug overlay using the UI renderer (#16693) 2024-12-11 00:49:47 +00:00
bevy_diagnostic Update sysinfo requirement from 0.32.0 to 0.33.0 (#16851) 2024-12-17 05:06:50 +00:00
bevy_dylib
bevy_ecs Remove deprecated ECS items (#16853) 2024-12-17 05:43:05 +00:00
bevy_encase_derive Rust 1.83, allow -> expect (missing_docs) (#16561) 2024-12-16 23:27:57 +00:00
bevy_gilrs Deny derive_more error feature and replace it with thiserror (#16684) 2024-12-06 17:03:55 +00:00
bevy_gizmos Fix registering all reflection types that are components as reflection components (#16800) 2024-12-16 19:16:43 +00:00
bevy_gltf Remove the meta field from LoadedAsset and ErasedLoadedAsset. (#15487) 2024-12-13 20:40:02 +00:00
bevy_hierarchy rename enqueue_command to queue_command for consistency (#16753) 2024-12-11 00:53:54 +00:00
bevy_image Rust 1.83, allow -> expect (missing_docs) (#16561) 2024-12-16 23:27:57 +00:00
bevy_input Fix registering all reflection types that are components as reflection components (#16800) 2024-12-16 19:16:43 +00:00
bevy_input_focus Tab navigation framework for bevy_input_focus. (#16795) 2024-12-16 23:54:53 +00:00
bevy_internal Draw the UI debug overlay using the UI renderer (#16693) 2024-12-11 00:49:47 +00:00
bevy_log
bevy_macro_utils Use one BevyManifest instance in proc macros (#16766) 2024-12-15 15:00:05 +00:00
bevy_math f32 -> Rot2 in bounding volume docs (#16848) 2024-12-17 00:12:49 +00:00
bevy_mesh Rust 1.83, allow -> expect (missing_docs) (#16561) 2024-12-16 23:27:57 +00:00
bevy_mikktspace Rust 1.83, allow -> expect (missing_docs) (#16561) 2024-12-16 23:27:57 +00:00
bevy_pbr Allow extract_meshes_for_gpu_building and extract_mesh_materials to run in parallel. (#16799) 2024-12-17 04:45:00 +00:00
bevy_picking Rust 1.83, allow -> expect (missing_docs) (#16561) 2024-12-16 23:27:57 +00:00
bevy_ptr
bevy_reflect bevy_reflect: Remove PartialReflect::serializable (#16576) 2024-12-16 23:29:46 +00:00
bevy_remote BRP strict field in query (#16725) 2024-12-14 05:22:19 +00:00
bevy_render track_change_detection: Also track spawns/despawns (#16047) 2024-12-17 04:46:31 +00:00
bevy_scene Add missing #[reflect(Component, Default)] to SceneRoot and DynamicSceneRoot. (#16816) 2024-12-15 19:18:22 +00:00
bevy_sprite Remove the type parameter from check_visibility, and only invoke it once. (#16812) 2024-12-17 04:43:45 +00:00
bevy_state Rust 1.83, allow -> expect (missing_docs) (#16561) 2024-12-16 23:27:57 +00:00
bevy_tasks Add no_std support to bevy_tasks (#15464) 2024-12-06 02:14:54 +00:00
bevy_text fix tiny copy-paste mistake in bevy_text::font_atlas_set (#16667) 2024-12-10 03:17:09 +00:00
bevy_time
bevy_transform track_change_detection: Also track spawns/despawns (#16047) 2024-12-17 04:46:31 +00:00
bevy_ui Remove the type parameter from check_visibility, and only invoke it once. (#16812) 2024-12-17 04:43:45 +00:00
bevy_utils Update hashbrown to 0.15 (#15801) 2024-12-10 19:45:50 +00:00
bevy_window Rust 1.83, allow -> expect (missing_docs) (#16561) 2024-12-16 23:27:57 +00:00
bevy_winit Rename trigger.entity() to trigger.target() (#16716) 2024-12-08 21:55:09 +00:00