diff --git a/crates/bevy_core/src/name.rs b/crates/bevy_core/src/name.rs index a150b3f89f68c..7cae9c796dabd 100644 --- a/crates/bevy_core/src/name.rs +++ b/crates/bevy_core/src/name.rs @@ -1,4 +1,4 @@ -use bevy_ecs::query::WorldQueryData; +use bevy_ecs::query::QueryData; use bevy_ecs::{component::Component, entity::Entity, reflect::ReflectComponent}; use bevy_reflect::std_traits::ReflectDefault; @@ -102,7 +102,7 @@ impl std::fmt::Debug for Name { /// } /// # bevy_ecs::system::assert_is_system(increment_score); /// ``` -#[derive(WorldQueryData)] +#[derive(QueryData)] pub struct DebugName { /// A [`Name`] that the entity might have that is displayed if available. pub name: Option<&'static Name>, diff --git a/crates/bevy_core_pipeline/src/bloom/mod.rs b/crates/bevy_core_pipeline/src/bloom/mod.rs index 858a1af352e6e..b1a43e362a664 100644 --- a/crates/bevy_core_pipeline/src/bloom/mod.rs +++ b/crates/bevy_core_pipeline/src/bloom/mod.rs @@ -113,7 +113,7 @@ impl Plugin for BloomPlugin { #[derive(Default)] struct BloomNode; impl ViewNode for BloomNode { - type ViewQuery = ( + type ViewData = ( &'static ExtractedCamera, &'static ViewTarget, &'static BloomTexture, @@ -140,7 +140,7 @@ impl ViewNode for BloomNode { bloom_settings, upsampling_pipeline_ids, downsampling_pipeline_ids, - ): QueryItem, + ): QueryItem, world: &World, ) -> Result<(), NodeRunError> { let downsampling_pipeline_res = world.resource::(); diff --git a/crates/bevy_core_pipeline/src/bloom/settings.rs b/crates/bevy_core_pipeline/src/bloom/settings.rs index 778908765f881..b2bb1c6396801 100644 --- a/crates/bevy_core_pipeline/src/bloom/settings.rs +++ b/crates/bevy_core_pipeline/src/bloom/settings.rs @@ -182,12 +182,12 @@ pub enum BloomCompositeMode { } impl ExtractComponent for BloomSettings { - type Query = (&'static Self, &'static Camera); + type Data = (&'static Self, &'static Camera); type Filter = (); type Out = (Self, BloomUniforms); - fn extract_component((settings, camera): QueryItem<'_, Self::Query>) -> Option { + fn extract_component((settings, camera): QueryItem<'_, Self::Data>) -> Option { match ( camera.physical_viewport_rect(), camera.physical_viewport_size(), diff --git a/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs b/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs index f0f45f9876953..af51d695eafa2 100644 --- a/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs +++ b/crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs @@ -77,11 +77,11 @@ pub struct CASUniform { } impl ExtractComponent for ContrastAdaptiveSharpeningSettings { - type Query = &'static Self; + type Data = &'static Self; type Filter = With; type Out = (DenoiseCAS, CASUniform); - fn extract_component(item: QueryItem) -> Option { + fn extract_component(item: QueryItem) -> Option { if !item.enabled || item.sharpening_strength == 0.0 { return None; } diff --git a/crates/bevy_core_pipeline/src/core_3d/main_opaque_pass_3d_node.rs b/crates/bevy_core_pipeline/src/core_3d/main_opaque_pass_3d_node.rs index a64ed8f4c8bef..2fcba3c652361 100644 --- a/crates/bevy_core_pipeline/src/core_3d/main_opaque_pass_3d_node.rs +++ b/crates/bevy_core_pipeline/src/core_3d/main_opaque_pass_3d_node.rs @@ -24,7 +24,7 @@ use super::{AlphaMask3d, Camera3dDepthLoadOp}; #[derive(Default)] pub struct MainOpaquePass3dNode; impl ViewNode for MainOpaquePass3dNode { - type ViewQuery = ( + type ViewData = ( &'static ExtractedCamera, &'static RenderPhase, &'static RenderPhase, @@ -58,7 +58,7 @@ impl ViewNode for MainOpaquePass3dNode { skybox_pipeline, skybox_bind_group, view_uniform_offset, - ): QueryItem, + ): QueryItem, world: &World, ) -> Result<(), NodeRunError> { let load = if deferred_prepass.is_none() { diff --git a/crates/bevy_core_pipeline/src/core_3d/main_transmissive_pass_3d_node.rs b/crates/bevy_core_pipeline/src/core_3d/main_transmissive_pass_3d_node.rs index 18c04e0d5a828..f41a8c0cb2693 100644 --- a/crates/bevy_core_pipeline/src/core_3d/main_transmissive_pass_3d_node.rs +++ b/crates/bevy_core_pipeline/src/core_3d/main_transmissive_pass_3d_node.rs @@ -20,7 +20,7 @@ use std::ops::Range; pub struct MainTransmissivePass3dNode; impl ViewNode for MainTransmissivePass3dNode { - type ViewQuery = ( + type ViewData = ( &'static ExtractedCamera, &'static Camera3d, &'static RenderPhase, @@ -34,7 +34,7 @@ impl ViewNode for MainTransmissivePass3dNode { graph: &mut RenderGraphContext, render_context: &mut RenderContext, (camera, camera_3d, transmissive_phase, target, transmission, depth): QueryItem< - Self::ViewQuery, + Self::ViewData, >, world: &World, ) -> Result<(), NodeRunError> { diff --git a/crates/bevy_core_pipeline/src/core_3d/main_transparent_pass_3d_node.rs b/crates/bevy_core_pipeline/src/core_3d/main_transparent_pass_3d_node.rs index ce5a2127f1d44..9a8ba5a610262 100644 --- a/crates/bevy_core_pipeline/src/core_3d/main_transparent_pass_3d_node.rs +++ b/crates/bevy_core_pipeline/src/core_3d/main_transparent_pass_3d_node.rs @@ -16,7 +16,7 @@ use bevy_utils::tracing::info_span; pub struct MainTransparentPass3dNode; impl ViewNode for MainTransparentPass3dNode { - type ViewQuery = ( + type ViewData = ( &'static ExtractedCamera, &'static RenderPhase, &'static ViewTarget, @@ -26,7 +26,7 @@ impl ViewNode for MainTransparentPass3dNode { &self, graph: &mut RenderGraphContext, render_context: &mut RenderContext, - (camera, transparent_phase, target, depth): QueryItem, + (camera, transparent_phase, target, depth): QueryItem, world: &World, ) -> Result<(), NodeRunError> { let view_entity = graph.view_entity(); diff --git a/crates/bevy_core_pipeline/src/deferred/copy_lighting_id.rs b/crates/bevy_core_pipeline/src/deferred/copy_lighting_id.rs index 988d529d09c44..d1660ad73f6c1 100644 --- a/crates/bevy_core_pipeline/src/deferred/copy_lighting_id.rs +++ b/crates/bevy_core_pipeline/src/deferred/copy_lighting_id.rs @@ -61,7 +61,7 @@ impl CopyDeferredLightingIdNode { } impl ViewNode for CopyDeferredLightingIdNode { - type ViewQuery = ( + type ViewData = ( &'static ViewTarget, &'static ViewPrepassTextures, &'static DeferredLightingIdDepthTexture, @@ -72,7 +72,7 @@ impl ViewNode for CopyDeferredLightingIdNode { _graph: &mut RenderGraphContext, render_context: &mut RenderContext, (_view_target, view_prepass_textures, deferred_lighting_id_depth_texture): QueryItem< - Self::ViewQuery, + Self::ViewData, >, world: &World, ) -> Result<(), NodeRunError> { diff --git a/crates/bevy_core_pipeline/src/deferred/node.rs b/crates/bevy_core_pipeline/src/deferred/node.rs index f598e8393ea70..7741eb2dd6dfc 100644 --- a/crates/bevy_core_pipeline/src/deferred/node.rs +++ b/crates/bevy_core_pipeline/src/deferred/node.rs @@ -29,7 +29,7 @@ use super::{AlphaMask3dDeferred, Opaque3dDeferred}; pub struct DeferredGBufferPrepassNode; impl ViewNode for DeferredGBufferPrepassNode { - type ViewQuery = ( + type ViewData = ( &'static ExtractedCamera, &'static RenderPhase, &'static RenderPhase, @@ -55,7 +55,7 @@ impl ViewNode for DeferredGBufferPrepassNode { depth_prepass, normal_prepass, motion_vector_prepass, - ): QueryItem, + ): QueryItem, world: &World, ) -> Result<(), NodeRunError> { let view_entity = graph.view_entity(); diff --git a/crates/bevy_core_pipeline/src/fxaa/node.rs b/crates/bevy_core_pipeline/src/fxaa/node.rs index 7eaf4dce268ad..67752cf87d4f1 100644 --- a/crates/bevy_core_pipeline/src/fxaa/node.rs +++ b/crates/bevy_core_pipeline/src/fxaa/node.rs @@ -20,7 +20,7 @@ pub struct FxaaNode { } impl ViewNode for FxaaNode { - type ViewQuery = ( + type ViewData = ( &'static ViewTarget, &'static CameraFxaaPipeline, &'static Fxaa, @@ -30,7 +30,7 @@ impl ViewNode for FxaaNode { &self, _graph: &mut RenderGraphContext, render_context: &mut RenderContext, - (target, pipeline, fxaa): QueryItem, + (target, pipeline, fxaa): QueryItem, world: &World, ) -> Result<(), NodeRunError> { let pipeline_cache = world.resource::(); diff --git a/crates/bevy_core_pipeline/src/prepass/node.rs b/crates/bevy_core_pipeline/src/prepass/node.rs index 5b64ad7bf4284..5a8affe78fe26 100644 --- a/crates/bevy_core_pipeline/src/prepass/node.rs +++ b/crates/bevy_core_pipeline/src/prepass/node.rs @@ -25,7 +25,7 @@ use super::{AlphaMask3dPrepass, DeferredPrepass, Opaque3dPrepass, ViewPrepassTex pub struct PrepassNode; impl ViewNode for PrepassNode { - type ViewQuery = ( + type ViewData = ( &'static ExtractedCamera, &'static RenderPhase, &'static RenderPhase, @@ -45,7 +45,7 @@ impl ViewNode for PrepassNode { view_depth_texture, view_prepass_textures, deferred_prepass, - ): QueryItem, + ): QueryItem, world: &World, ) -> Result<(), NodeRunError> { let view_entity = graph.view_entity(); diff --git a/crates/bevy_core_pipeline/src/taa/mod.rs b/crates/bevy_core_pipeline/src/taa/mod.rs index dd0ecfdbdd63b..cbc20d17a9c2c 100644 --- a/crates/bevy_core_pipeline/src/taa/mod.rs +++ b/crates/bevy_core_pipeline/src/taa/mod.rs @@ -168,7 +168,7 @@ impl Default for TemporalAntiAliasSettings { pub struct TemporalAntiAliasNode; impl ViewNode for TemporalAntiAliasNode { - type ViewQuery = ( + type ViewData = ( &'static ExtractedCamera, &'static ViewTarget, &'static TemporalAntiAliasHistoryTextures, @@ -181,7 +181,7 @@ impl ViewNode for TemporalAntiAliasNode { _graph: &mut RenderGraphContext, render_context: &mut RenderContext, (camera, view_target, taa_history_textures, prepass_textures, taa_pipeline_id): QueryItem< - Self::ViewQuery, + Self::ViewData, >, world: &World, ) -> Result<(), NodeRunError> { diff --git a/crates/bevy_core_pipeline/src/tonemapping/node.rs b/crates/bevy_core_pipeline/src/tonemapping/node.rs index 6d97af876a690..1f3f2c1038d7d 100644 --- a/crates/bevy_core_pipeline/src/tonemapping/node.rs +++ b/crates/bevy_core_pipeline/src/tonemapping/node.rs @@ -24,7 +24,7 @@ pub struct TonemappingNode { } impl ViewNode for TonemappingNode { - type ViewQuery = ( + type ViewData = ( &'static ViewUniformOffset, &'static ViewTarget, &'static ViewTonemappingPipeline, @@ -36,7 +36,7 @@ impl ViewNode for TonemappingNode { _graph: &mut RenderGraphContext, render_context: &mut RenderContext, (view_uniform_offset, target, view_tonemapping_pipeline, tonemapping): QueryItem< - Self::ViewQuery, + Self::ViewData, >, world: &World, ) -> Result<(), NodeRunError> { diff --git a/crates/bevy_core_pipeline/src/upscaling/node.rs b/crates/bevy_core_pipeline/src/upscaling/node.rs index a81eb96de84b1..2876231d67f98 100644 --- a/crates/bevy_core_pipeline/src/upscaling/node.rs +++ b/crates/bevy_core_pipeline/src/upscaling/node.rs @@ -18,7 +18,7 @@ pub struct UpscalingNode { } impl ViewNode for UpscalingNode { - type ViewQuery = ( + type ViewData = ( &'static ViewTarget, &'static ViewUpscalingPipeline, Option<&'static ExtractedCamera>, @@ -28,7 +28,7 @@ impl ViewNode for UpscalingNode { &self, _graph: &mut RenderGraphContext, render_context: &mut RenderContext, - (target, upscaling_target, camera): QueryItem, + (target, upscaling_target, camera): QueryItem, world: &World, ) -> Result<(), NodeRunError> { let pipeline_cache = world.get_resource::().unwrap(); diff --git a/crates/bevy_ecs/macros/src/lib.rs b/crates/bevy_ecs/macros/src/lib.rs index a27480b5b1f47..5d96ee2b3a687 100644 --- a/crates/bevy_ecs/macros/src/lib.rs +++ b/crates/bevy_ecs/macros/src/lib.rs @@ -1,15 +1,12 @@ extern crate proc_macro; mod component; +mod query_data; +mod query_filter; mod states; mod world_query; -mod world_query_data; -mod world_query_filter; -use crate::{ - world_query_data::derive_world_query_data_impl, - world_query_filter::derive_world_query_filter_impl, -}; +use crate::{query_data::derive_query_data_impl, query_filter::derive_query_filter_impl}; use bevy_macro_utils::{derive_label, ensure_no_collision, get_struct_fields, BevyManifest}; use proc_macro::TokenStream; use proc_macro2::Span; @@ -450,16 +447,16 @@ pub fn derive_system_param(input: TokenStream) -> TokenStream { }) } -/// Implement `WorldQueryData` to use a struct as a data parameter in a query -#[proc_macro_derive(WorldQueryData, attributes(world_query_data))] -pub fn derive_world_query_data(input: TokenStream) -> TokenStream { - derive_world_query_data_impl(input) +/// Implement `QueryData` to use a struct as a data parameter in a query +#[proc_macro_derive(QueryData, attributes(query_data))] +pub fn derive_query_data(input: TokenStream) -> TokenStream { + derive_query_data_impl(input) } -/// Implement `WorldQueryFilter` to use a struct as a filter parameter in a query -#[proc_macro_derive(WorldQueryFilter, attributes(world_query_filter))] -pub fn derive_world_query_filter(input: TokenStream) -> TokenStream { - derive_world_query_filter_impl(input) +/// Implement `QueryFilter` to use a struct as a filter parameter in a query +#[proc_macro_derive(QueryFilter, attributes(query_filter))] +pub fn derive_query_filter(input: TokenStream) -> TokenStream { + derive_query_filter_impl(input) } /// Derive macro generating an impl of the trait `ScheduleLabel`. diff --git a/crates/bevy_ecs/macros/src/world_query_data.rs b/crates/bevy_ecs/macros/src/query_data.rs similarity index 88% rename from crates/bevy_ecs/macros/src/world_query_data.rs rename to crates/bevy_ecs/macros/src/query_data.rs index e2573ccd1d7ef..1c77fc974f99c 100644 --- a/crates/bevy_ecs/macros/src/world_query_data.rs +++ b/crates/bevy_ecs/macros/src/query_data.rs @@ -16,7 +16,7 @@ use crate::{ }; #[derive(Default)] -struct WorldQueryDataAttributes { +struct QueryDataAttributes { pub is_mutable: bool, pub derive_args: Punctuated, @@ -29,20 +29,20 @@ mod field_attr_keywords { syn::custom_keyword!(ignore); } -pub static WORLD_QUERY_DATA_ATTRIBUTE_NAME: &str = "world_query_data"; +pub static QUERY_DATA_ATTRIBUTE_NAME: &str = "query_data"; -pub fn derive_world_query_data_impl(input: TokenStream) -> TokenStream { +pub fn derive_query_data_impl(input: TokenStream) -> TokenStream { let tokens = input.clone(); let ast = parse_macro_input!(input as DeriveInput); let visibility = ast.vis; - let mut attributes = WorldQueryDataAttributes::default(); + let mut attributes = QueryDataAttributes::default(); for attr in &ast.attrs { if !attr .path() .get_ident() - .map_or(false, |ident| ident == WORLD_QUERY_DATA_ATTRIBUTE_NAME) + .map_or(false, |ident| ident == QUERY_DATA_ATTRIBUTE_NAME) { continue; } @@ -85,7 +85,7 @@ pub fn derive_world_query_data_impl(input: TokenStream) -> TokenStream { } Ok(()) }) - .unwrap_or_else(|_| panic!("Invalid `{WORLD_QUERY_DATA_ATTRIBUTE_NAME}` attribute format")); + .unwrap_or_else(|_| panic!("Invalid `{QUERY_DATA_ATTRIBUTE_NAME}` attribute format")); } let path = bevy_ecs_path(); @@ -137,7 +137,7 @@ pub fn derive_world_query_data_impl(input: TokenStream) -> TokenStream { let Data::Struct(DataStruct { fields, .. }) = &ast.data else { return syn::Error::new( Span::call_site(), - "#[derive(WorldQueryData)]` only supports structs", + "#[derive(QueryData)]` only supports structs", ) .into_compile_error() .into(); @@ -151,7 +151,7 @@ pub fn derive_world_query_data_impl(input: TokenStream) -> TokenStream { let mut read_only_field_types = Vec::new(); for (i, field) in fields.iter().enumerate() { let attrs = match read_world_query_field_info(field) { - Ok(WorldQueryDataFieldInfo { attrs }) => attrs, + Ok(QueryDataFieldInfo { attrs }) => attrs, Err(e) => return e.into_compile_error().into(), }; @@ -171,7 +171,7 @@ pub fn derive_world_query_data_impl(input: TokenStream) -> TokenStream { field_visibilities.push(field.vis.clone()); let field_ty = field.ty.clone(); field_types.push(quote!(#field_ty)); - read_only_field_types.push(quote!(<#field_ty as #path::query::WorldQueryData>::ReadOnly)); + read_only_field_types.push(quote!(<#field_ty as #path::query::QueryData>::ReadOnly)); } let derive_args = &attributes.derive_args; @@ -274,7 +274,7 @@ pub fn derive_world_query_data_impl(input: TokenStream) -> TokenStream { let read_only_data_impl = if attributes.is_mutable { quote! { /// SAFETY: we assert fields are readonly below - unsafe impl #user_impl_generics #path::query::WorldQueryData + unsafe impl #user_impl_generics #path::query::QueryData for #read_only_struct_name #user_ty_generics #user_where_clauses { type ReadOnly = #read_only_struct_name #user_ty_generics; } @@ -285,7 +285,7 @@ pub fn derive_world_query_data_impl(input: TokenStream) -> TokenStream { quote! { /// SAFETY: we assert fields are readonly below - unsafe impl #user_impl_generics #path::query::WorldQueryData + unsafe impl #user_impl_generics #path::query::QueryData for #struct_name #user_ty_generics #user_where_clauses { type ReadOnly = #read_only_struct_name #user_ty_generics; } @@ -296,24 +296,24 @@ pub fn derive_world_query_data_impl(input: TokenStream) -> TokenStream { let read_only_data_impl = quote! { /// SAFETY: we assert fields are readonly below - unsafe impl #user_impl_generics #path::query::ReadOnlyWorldQueryData + unsafe impl #user_impl_generics #path::query::ReadOnlyQueryData for #read_only_struct_name #user_ty_generics #user_where_clauses {} }; let read_only_asserts = if attributes.is_mutable { quote! { // Double-check that the data fetched by `<_ as WorldQuery>::ReadOnly` is read-only. - // This is technically unnecessary as `<_ as WorldQuery>::ReadOnly: ReadOnlyWorldQueryData` - // but to protect against future mistakes we assert the assoc type implements `ReadOnlyWorldQueryData` anyway + // This is technically unnecessary as `<_ as WorldQuery>::ReadOnly: ReadOnlyQueryData` + // but to protect against future mistakes we assert the assoc type implements `ReadOnlyQueryData` anyway #( assert_readonly::<#read_only_field_types>(); )* } } else { quote! { - // Statically checks that the safety guarantee of `ReadOnlyWorldQueryData` for `$fetch_struct_name` actually holds true. - // We need this to make sure that we don't compile `ReadOnlyWorldQueryData` if our struct contains nested `WorldQueryData` + // Statically checks that the safety guarantee of `ReadOnlyQueryData` for `$fetch_struct_name` actually holds true. + // We need this to make sure that we don't compile `ReadOnlyQueryData` if our struct contains nested `QueryData` // members that don't implement it. I.e.: // ``` - // #[derive(WorldQueryData)] + // #[derive(QueryData)] // pub struct Foo { a: &'static mut MyComponent } // ``` #( assert_readonly::<#field_types>(); )* @@ -352,13 +352,13 @@ pub fn derive_world_query_data_impl(input: TokenStream) -> TokenStream { const _: () = { fn assert_readonly() where - T: #path::query::ReadOnlyWorldQueryData, + T: #path::query::ReadOnlyQueryData, { } fn assert_data() where - T: #path::query::WorldQueryData, + T: #path::query::QueryData, { } @@ -385,26 +385,26 @@ pub fn derive_world_query_data_impl(input: TokenStream) -> TokenStream { }) } -struct WorldQueryDataFieldInfo { - /// All field attributes except for `world_query_data` ones. +struct QueryDataFieldInfo { + /// All field attributes except for `query_data` ones. attrs: Vec, } -fn read_world_query_field_info(field: &Field) -> syn::Result { +fn read_world_query_field_info(field: &Field) -> syn::Result { let mut attrs = Vec::new(); for attr in &field.attrs { if attr .path() .get_ident() - .map_or(false, |ident| ident == WORLD_QUERY_DATA_ATTRIBUTE_NAME) + .map_or(false, |ident| ident == QUERY_DATA_ATTRIBUTE_NAME) { return Err(syn::Error::new_spanned( attr, - "#[derive(WorldQueryData)] does not support field attributes.", + "#[derive(QueryData)] does not support field attributes.", )); } attrs.push(attr.clone()); } - Ok(WorldQueryDataFieldInfo { attrs }) + Ok(QueryDataFieldInfo { attrs }) } diff --git a/crates/bevy_ecs/macros/src/world_query_filter.rs b/crates/bevy_ecs/macros/src/query_filter.rs similarity index 96% rename from crates/bevy_ecs/macros/src/world_query_filter.rs rename to crates/bevy_ecs/macros/src/query_filter.rs index b10cac09a06c5..ff056857df41f 100644 --- a/crates/bevy_ecs/macros/src/world_query_filter.rs +++ b/crates/bevy_ecs/macros/src/query_filter.rs @@ -13,7 +13,7 @@ mod field_attr_keywords { syn::custom_keyword!(ignore); } -pub fn derive_world_query_filter_impl(input: TokenStream) -> TokenStream { +pub fn derive_query_filter_impl(input: TokenStream) -> TokenStream { let tokens = input.clone(); let ast = parse_macro_input!(input as DeriveInput); @@ -120,7 +120,7 @@ pub fn derive_world_query_filter_impl(input: TokenStream) -> TokenStream { ); let filter_impl = quote! { - impl #user_impl_generics #path::query::WorldQueryFilter + impl #user_impl_generics #path::query::QueryFilter for #struct_name #user_ty_generics #user_where_clauses { const IS_ARCHETYPAL: bool = true #(&& <#field_types>::IS_ARCHETYPAL)*; @@ -163,7 +163,7 @@ pub fn derive_world_query_filter_impl(input: TokenStream) -> TokenStream { fn assert_filter() where - T: #path::query::WorldQueryFilter, + T: #path::query::QueryFilter, { } diff --git a/crates/bevy_ecs/src/lib.rs b/crates/bevy_ecs/src/lib.rs index 69ce32e8a8806..5e00f1c1a8c7f 100644 --- a/crates/bevy_ecs/src/lib.rs +++ b/crates/bevy_ecs/src/lib.rs @@ -64,7 +64,7 @@ mod tests { change_detection::Ref, component::{Component, ComponentId}, entity::Entity, - query::{Added, Changed, FilteredAccess, With, Without, WorldQueryFilter}, + query::{Added, Changed, FilteredAccess, QueryFilter, With, Without}, system::Resource, world::{EntityRef, Mut, World}, }; @@ -903,7 +903,7 @@ mod tests { } } - fn get_filtered(world: &mut World) -> Vec { + fn get_filtered(world: &mut World) -> Vec { world .query_filtered::() .iter(world) @@ -986,7 +986,7 @@ mod tests { } } - fn get_filtered(world: &mut World) -> Vec { + fn get_filtered(world: &mut World) -> Vec { world .query_filtered::() .iter(world) diff --git a/crates/bevy_ecs/src/query/fetch.rs b/crates/bevy_ecs/src/query/fetch.rs index 00df1fe63e17c..126fe9a6c3632 100644 --- a/crates/bevy_ecs/src/query/fetch.rs +++ b/crates/bevy_ecs/src/query/fetch.rs @@ -17,8 +17,8 @@ use std::{cell::UnsafeCell, marker::PhantomData}; /// /// - **Component references.** /// Fetches a component by reference (immutably or mutably). -/// - **`WorldQueryData` tuples.** -/// If every element of a tuple implements `WorldQueryData`, then the tuple itself also implements the same trait. +/// - **`QueryData` tuples.** +/// If every element of a tuple implements `QueryData`, then the tuple itself also implements the same trait. /// This enables a single `Query` to access multiple components. /// Due to the current lack of variadic generics in Rust, the trait has been implemented for tuples from 0 to 15 elements, /// but nesting of tuples allows infinite `WorldQuery`s. @@ -39,8 +39,8 @@ use std::{cell::UnsafeCell, marker::PhantomData}; /// /// # Trait derivation /// -/// Query design can be easily structured by deriving `WorldQueryData` for custom types. -/// Despite the added complexity, this approach has several advantages over using `WorldQueryData` tuples. +/// Query design can be easily structured by deriving `QueryData` for custom types. +/// Despite the added complexity, this approach has several advantages over using `QueryData` tuples. /// The most relevant improvements are: /// /// - Reusability across multiple systems. @@ -49,18 +49,18 @@ use std::{cell::UnsafeCell, marker::PhantomData}; /// - Methods can be implemented for the query items. /// - There is no hardcoded limit on the number of elements. /// -/// This trait can only be derived for structs, if each field also implements `WorldQueryData`. +/// This trait can only be derived for structs, if each field also implements `QueryData`. /// /// ``` /// # use bevy_ecs::prelude::*; -/// use bevy_ecs::query::WorldQueryData; +/// use bevy_ecs::query::QueryData; /// # /// # #[derive(Component)] /// # struct ComponentA; /// # #[derive(Component)] /// # struct ComponentB; /// -/// #[derive(WorldQueryData)] +/// #[derive(QueryData)] /// struct MyQuery { /// entity: Entity, /// // It is required that all reference lifetimes are explicitly annotated, just like in any @@ -90,33 +90,33 @@ use std::{cell::UnsafeCell, marker::PhantomData}; /// /// ## Adding mutable references /// -/// Simply adding mutable references to a derived `WorldQueryData` will result in a compilation error: +/// Simply adding mutable references to a derived `QueryData` will result in a compilation error: /// /// ```compile_fail /// # use bevy_ecs::prelude::*; -/// # use bevy_ecs::query::WorldQueryData; +/// # use bevy_ecs::query::QueryData; /// # /// # #[derive(Component)] /// # struct ComponentA; /// # -/// #[derive(WorldQueryData)] +/// #[derive(QueryData)] /// struct CustomQuery { /// component_a: &'static mut ComponentA, /// } /// ``` /// -/// To grant mutable access to components, the struct must be marked with the `#[world_query_data(mutable)]` attribute. +/// To grant mutable access to components, the struct must be marked with the `#[query_data(mutable)]` attribute. /// This will also create three more structs that will be used for accessing the query immutably (see table above). /// /// ``` /// # use bevy_ecs::prelude::*; -/// # use bevy_ecs::query::WorldQueryData; +/// # use bevy_ecs::query::QueryData; /// # /// # #[derive(Component)] /// # struct ComponentA; /// # -/// #[derive(WorldQueryData)] -/// #[world_query_data(mutable)] +/// #[derive(QueryData)] +/// #[query_data(mutable)] /// struct CustomQuery { /// component_a: &'static mut ComponentA, /// } @@ -130,7 +130,7 @@ use std::{cell::UnsafeCell, marker::PhantomData}; /// /// ``` /// # use bevy_ecs::prelude::*; -/// # use bevy_ecs::query::WorldQueryData; +/// # use bevy_ecs::query::QueryData; /// # /// #[derive(Component)] /// struct Health(f32); @@ -138,8 +138,8 @@ use std::{cell::UnsafeCell, marker::PhantomData}; /// #[derive(Component)] /// struct Buff(f32); /// -/// #[derive(WorldQueryData)] -/// #[world_query_data(mutable)] +/// #[derive(QueryData)] +/// #[query_data(mutable)] /// struct HealthQuery { /// health: &'static mut Health, /// buff: Option<&'static mut Buff>, @@ -179,19 +179,19 @@ use std::{cell::UnsafeCell, marker::PhantomData}; /// /// ## Deriving traits for query items /// -/// The `WorldQueryData` derive macro does not automatically implement the traits of the struct to the query item types. -/// Something similar can be done by using the `#[world_query_data(derive(...))]` attribute. +/// The `QueryData` derive macro does not automatically implement the traits of the struct to the query item types. +/// Something similar can be done by using the `#[query_data(derive(...))]` attribute. /// This will apply the listed derivable traits to the query item structs. /// /// ``` /// # use bevy_ecs::prelude::*; -/// # use bevy_ecs::query::WorldQueryData; +/// # use bevy_ecs::query::QueryData; /// # /// # #[derive(Component, Debug)] /// # struct ComponentA; /// # -/// #[derive(WorldQueryData)] -/// #[world_query_data(mutable, derive(Debug))] +/// #[derive(QueryData)] +/// #[query_data(mutable, derive(Debug))] /// struct CustomQuery { /// component_a: &'static ComponentA, /// } @@ -205,12 +205,12 @@ use std::{cell::UnsafeCell, marker::PhantomData}; /// /// ## Query composition /// -/// It is possible to use any `WorldQueryData` as a field of another one. -/// This means that a `WorldQueryData` can also be used as a subquery, potentially in multiple places. +/// It is possible to use any `QueryData` as a field of another one. +/// This means that a `QueryData` can also be used as a subquery, potentially in multiple places. /// /// ``` /// # use bevy_ecs::prelude::*; -/// # use bevy_ecs::query::WorldQueryData; +/// # use bevy_ecs::query::QueryData; /// # /// # #[derive(Component)] /// # struct ComponentA; @@ -219,13 +219,13 @@ use std::{cell::UnsafeCell, marker::PhantomData}; /// # #[derive(Component)] /// # struct ComponentC; /// # -/// #[derive(WorldQueryData)] +/// #[derive(QueryData)] /// struct SubQuery { /// component_a: &'static ComponentA, /// component_b: &'static ComponentB, /// } /// -/// #[derive(WorldQueryData)] +/// #[derive(QueryData)] /// struct MyQuery { /// subquery: SubQuery, /// component_c: &'static ComponentC, @@ -235,13 +235,13 @@ use std::{cell::UnsafeCell, marker::PhantomData}; /// # Generic Queries /// /// When writing generic code, it is often necessary to use [`PhantomData`] -/// to constrain type parameters. Since `WorldQueryData` is implemented for all +/// to constrain type parameters. Since `QueryData` is implemented for all /// `PhantomData` types, this pattern can be used with this macro. /// /// ``` -/// # use bevy_ecs::{prelude::*, query::WorldQueryData}; +/// # use bevy_ecs::{prelude::*, query::QueryData}; /// # use std::marker::PhantomData; -/// #[derive(WorldQueryData)] +/// #[derive(QueryData)] /// pub struct GenericQuery { /// id: Entity, /// marker: PhantomData, @@ -257,22 +257,22 @@ use std::{cell::UnsafeCell, marker::PhantomData}; /// /// [`Query`]: crate::system::Query /// [`ReadOnly`]: Self::ReadOnly -pub unsafe trait WorldQueryData: WorldQuery { - /// The read-only variant of this [`WorldQueryData`], which satisfies the [`ReadOnlyWorldQueryData`] trait. - type ReadOnly: ReadOnlyWorldQueryData::State>; +pub unsafe trait QueryData: WorldQuery { + /// The read-only variant of this [`QueryData`], which satisfies the [`ReadOnlyQueryData`] trait. + type ReadOnly: ReadOnlyQueryData::State>; } -/// A [`WorldQueryData`] that is read only. +/// A [`QueryData`] that is read only. /// /// # Safety /// -/// This must only be implemented for read-only [`WorldQueryData`]'s. -pub unsafe trait ReadOnlyWorldQueryData: WorldQueryData {} +/// This must only be implemented for read-only [`QueryData`]'s. +pub unsafe trait ReadOnlyQueryData: QueryData {} /// The item type returned when a [`WorldQuery`] is iterated over pub type QueryItem<'w, Q> = ::Item<'w>; -/// The read-only variant of the item type returned when a [`WorldQueryData`] is iterated over immutably -pub type ROQueryItem<'w, Q> = QueryItem<'w, ::ReadOnly>; +/// The read-only variant of the item type returned when a [`QueryData`] is iterated over immutably +pub type ROQueryItem<'w, Q> = QueryItem<'w, ::ReadOnly>; /// SAFETY: /// `update_component_access` and `update_archetype_component_access` do nothing. @@ -338,12 +338,12 @@ unsafe impl WorldQuery for Entity { } /// SAFETY: `Self` is the same as `Self::ReadOnly` -unsafe impl WorldQueryData for Entity { +unsafe impl QueryData for Entity { type ReadOnly = Self; } /// SAFETY: access is read only -unsafe impl ReadOnlyWorldQueryData for Entity {} +unsafe impl ReadOnlyQueryData for Entity {} /// SAFETY: /// `fetch` accesses all components in a readonly way. @@ -423,12 +423,12 @@ unsafe impl<'a> WorldQuery for EntityRef<'a> { } /// SAFETY: `Self` is the same as `Self::ReadOnly` -unsafe impl<'a> WorldQueryData for EntityRef<'a> { +unsafe impl<'a> QueryData for EntityRef<'a> { type ReadOnly = Self; } /// SAFETY: access is read only -unsafe impl ReadOnlyWorldQueryData for EntityRef<'_> {} +unsafe impl ReadOnlyQueryData for EntityRef<'_> {} /// SAFETY: The accesses of `Self::ReadOnly` are a subset of the accesses of `Self` unsafe impl<'a> WorldQuery for EntityMut<'a> { @@ -505,7 +505,7 @@ unsafe impl<'a> WorldQuery for EntityMut<'a> { } /// SAFETY: access of `EntityRef` is a subset of `EntityMut` -unsafe impl<'a> WorldQueryData for EntityMut<'a> { +unsafe impl<'a> QueryData for EntityMut<'a> { type ReadOnly = EntityRef<'a>; } @@ -651,12 +651,12 @@ unsafe impl WorldQuery for &T { } /// SAFETY: `Self` is the same as `Self::ReadOnly` -unsafe impl WorldQueryData for &T { +unsafe impl QueryData for &T { type ReadOnly = Self; } /// SAFETY: access is read only -unsafe impl ReadOnlyWorldQueryData for &T {} +unsafe impl ReadOnlyQueryData for &T {} #[doc(hidden)] pub struct RefFetch<'w, T> { @@ -818,12 +818,12 @@ unsafe impl<'__w, T: Component> WorldQuery for Ref<'__w, T> { } /// SAFETY: `Self` is the same as `Self::ReadOnly` -unsafe impl<'__w, T: Component> WorldQueryData for Ref<'__w, T> { +unsafe impl<'__w, T: Component> QueryData for Ref<'__w, T> { type ReadOnly = Self; } /// SAFETY: access is read only -unsafe impl<'__w, T: Component> ReadOnlyWorldQueryData for Ref<'__w, T> {} +unsafe impl<'__w, T: Component> ReadOnlyQueryData for Ref<'__w, T> {} #[doc(hidden)] pub struct WriteFetch<'w, T> { @@ -985,7 +985,7 @@ unsafe impl<'__w, T: Component> WorldQuery for &'__w mut T { } /// SAFETY: access of `&T` is a subset of `&mut T` -unsafe impl<'__w, T: Component> WorldQueryData for &'__w mut T { +unsafe impl<'__w, T: Component> QueryData for &'__w mut T { type ReadOnly = &'__w T; } @@ -1102,12 +1102,12 @@ unsafe impl WorldQuery for Option { } // SAFETY: defers to soundness of `T: WorldQuery` impl -unsafe impl WorldQueryData for Option { +unsafe impl QueryData for Option { type ReadOnly = Option; } /// SAFETY: [`OptionFetch`] is read only because `T` is read only -unsafe impl ReadOnlyWorldQueryData for Option {} +unsafe impl ReadOnlyQueryData for Option {} /// Returns a bool that describes if an entity has the component `T`. /// @@ -1242,12 +1242,12 @@ unsafe impl WorldQuery for Has { } /// SAFETY: `Self` is the same as `Self::ReadOnly` -unsafe impl WorldQueryData for Has { +unsafe impl QueryData for Has { type ReadOnly = Self; } /// SAFETY: [`Has`] is read only -unsafe impl ReadOnlyWorldQueryData for Has {} +unsafe impl ReadOnlyQueryData for Has {} /// The `AnyOf` query parameter fetches entities with any of the component types included in T. /// @@ -1256,18 +1256,18 @@ unsafe impl ReadOnlyWorldQueryData for Has {} /// Entities are guaranteed to have at least one of the components in `T`. pub struct AnyOf(PhantomData); -macro_rules! impl_tuple_world_query_data { +macro_rules! impl_tuple_query_data { ($(($name: ident, $state: ident)),*) => { #[allow(non_snake_case)] #[allow(clippy::unused_unit)] // SAFETY: defers to soundness `$name: WorldQuery` impl - unsafe impl<$($name: WorldQueryData),*> WorldQueryData for ($($name,)*) { + unsafe impl<$($name: QueryData),*> QueryData for ($($name,)*) { type ReadOnly = ($($name::ReadOnly,)*); } /// SAFETY: each item in the tuple is read only - unsafe impl<$($name: ReadOnlyWorldQueryData),*> ReadOnlyWorldQueryData for ($($name,)*) {} + unsafe impl<$($name: ReadOnlyQueryData),*> ReadOnlyQueryData for ($($name,)*) {} }; } @@ -1387,27 +1387,27 @@ macro_rules! impl_anytuple_fetch { #[allow(non_snake_case)] #[allow(clippy::unused_unit)] // SAFETY: defers to soundness of `$name: WorldQuery` impl - unsafe impl<$($name: WorldQueryData),*> WorldQueryData for AnyOf<($($name,)*)> { + unsafe impl<$($name: QueryData),*> QueryData for AnyOf<($($name,)*)> { type ReadOnly = AnyOf<($($name::ReadOnly,)*)>; } /// SAFETY: each item in the tuple is read only - unsafe impl<$($name: ReadOnlyWorldQueryData),*> ReadOnlyWorldQueryData for AnyOf<($($name,)*)> {} + unsafe impl<$($name: ReadOnlyQueryData),*> ReadOnlyQueryData for AnyOf<($($name,)*)> {} }; } -all_tuples!(impl_tuple_world_query_data, 0, 15, F, S); +all_tuples!(impl_tuple_query_data, 0, 15, F, S); all_tuples!(impl_anytuple_fetch, 0, 15, F, S); /// [`WorldQuery`] used to nullify queries by turning `Query` into `Query>` /// /// This will rarely be useful to consumers of `bevy_ecs`. -pub struct NopWorldQuery(PhantomData); +pub struct NopWorldQuery(PhantomData); /// SAFETY: /// `update_component_access` and `update_archetype_component_access` do nothing. /// This is sound because `fetch` does not access components. -unsafe impl WorldQuery for NopWorldQuery { +unsafe impl WorldQuery for NopWorldQuery { type Fetch<'w> = (); type Item<'w> = (); type State = Q::State; @@ -1467,12 +1467,12 @@ unsafe impl WorldQuery for NopWorldQuery { } /// SAFETY: `Self::ReadOnly` is `Self` -unsafe impl WorldQueryData for NopWorldQuery { +unsafe impl QueryData for NopWorldQuery { type ReadOnly = Self; } /// SAFETY: `NopFetch` never accesses any data -unsafe impl ReadOnlyWorldQueryData for NopWorldQuery {} +unsafe impl ReadOnlyQueryData for NopWorldQuery {} /// SAFETY: /// `update_component_access` and `update_archetype_component_access` do nothing. @@ -1535,16 +1535,16 @@ unsafe impl WorldQuery for PhantomData { } /// SAFETY: `Self::ReadOnly` is `Self` -unsafe impl WorldQueryData for PhantomData { +unsafe impl QueryData for PhantomData { type ReadOnly = Self; } /// SAFETY: `PhantomData` never accesses any world data. -unsafe impl ReadOnlyWorldQueryData for PhantomData {} +unsafe impl ReadOnlyQueryData for PhantomData {} #[cfg(test)] mod tests { - use bevy_ecs_macros::WorldQueryData; + use bevy_ecs_macros::QueryData; use super::*; use crate::{ @@ -1561,16 +1561,16 @@ mod tests { // Tests that each variant of struct can be used as a `WorldQuery`. #[test] fn world_query_struct_variants() { - #[derive(WorldQueryData)] + #[derive(QueryData)] pub struct NamedQuery { id: Entity, a: &'static A, } - #[derive(WorldQueryData)] + #[derive(QueryData)] pub struct TupleQuery(&'static A, &'static B); - #[derive(WorldQueryData)] + #[derive(QueryData)] pub struct UnitQuery; fn my_system(_: Query<(NamedQuery, TupleQuery, UnitQuery)>) {} @@ -1581,7 +1581,7 @@ mod tests { // Compile test for https://github.com/bevyengine/bevy/pull/8030. #[test] fn world_query_phantom_data() { - #[derive(WorldQueryData)] + #[derive(QueryData)] pub struct IgnoredQuery { id: Entity, _marker: PhantomData, @@ -1599,8 +1599,8 @@ mod tests { mod private { use super::*; - #[derive(WorldQueryData)] - #[world_query_data(mutable)] + #[derive(QueryData)] + #[query_data(mutable)] pub struct Q { pub a: &'static mut A, } @@ -1624,7 +1624,7 @@ mod tests { fn world_query_metadata_collision() { // The metadata types generated would be named `ClientState` and `ClientFetch`, // but they should rename themselves to avoid conflicts. - #[derive(WorldQueryData)] + #[derive(QueryData)] pub struct Client { pub state: &'static S, pub fetch: &'static ClientFetch, diff --git a/crates/bevy_ecs/src/query/filter.rs b/crates/bevy_ecs/src/query/filter.rs index dcc2cedeea20b..89997dfd6f5e6 100644 --- a/crates/bevy_ecs/src/query/filter.rs +++ b/crates/bevy_ecs/src/query/filter.rs @@ -17,29 +17,29 @@ use std::{cell::UnsafeCell, marker::PhantomData}; /// [`With`] and [`Without`] filters can be applied to check if the queried entity does or does not contain a particular component. /// - **Change detection filters.** /// [`Added`] and [`Changed`] filters can be applied to detect component changes to an entity. -/// - **`WorldQueryFilter` tuples.** -/// If every element of a tuple implements `WorldQueryFilter`, then the tuple itself also implements the same trait. +/// - **`QueryFilter` tuples.** +/// If every element of a tuple implements `QueryFilter`, then the tuple itself also implements the same trait. /// This enables a single `Query` to filter over multiple conditions. /// Due to the current lack of variadic generics in Rust, the trait has been implemented for tuples from 0 to 15 elements, -/// but nesting of tuples allows infinite `WorldQueryFilter`s. +/// but nesting of tuples allows infinite `QueryFilter`s. /// - **Filter disjunction operator.** /// By default, tuples compose query filters in such a way that all conditions must be satisfied to generate a query item for a given entity. /// Wrapping a tuple inside an [`Or`] operator will relax the requirement to just one condition. /// /// Implementing the trait manually can allow for a fundamentally new type of behavior. /// -/// Query design can be easily structured by deriving `WorldQueryFilter` for custom types. -/// Despite the added complexity, this approach has several advantages over using `WorldQueryFilter` tuples. +/// Query design can be easily structured by deriving `QueryFilter` for custom types. +/// Despite the added complexity, this approach has several advantages over using `QueryFilter` tuples. /// The most relevant improvements are: /// /// - Reusability across multiple systems. /// - Filters can be composed together to create a more complex filter. /// -/// This trait can only be derived for structs if each field also implements `WorldQueryFilter`. +/// This trait can only be derived for structs if each field also implements `QueryFilter`. /// /// ``` /// # use bevy_ecs::prelude::*; -/// # use bevy_ecs::{query::WorldQueryFilter, component::Component}; +/// # use bevy_ecs::{query::QueryFilter, component::Component}; /// # /// # #[derive(Component)] /// # struct ComponentA; @@ -52,7 +52,7 @@ use std::{cell::UnsafeCell, marker::PhantomData}; /// # #[derive(Component)] /// # struct ComponentE; /// # -/// #[derive(WorldQueryFilter)] +/// #[derive(QueryFilter)] /// struct MyFilter { /// // Field names are not relevant, since they are never manually accessed. /// with_a: With, @@ -73,7 +73,7 @@ use std::{cell::UnsafeCell, marker::PhantomData}; /// [`update_archetype_component_access`]: Self::update_archetype_component_access /// [`update_component_access`]: Self::update_component_access -pub trait WorldQueryFilter: WorldQuery { +pub trait QueryFilter: WorldQuery { /// Returns true if (and only if) this Filter relies strictly on archetypes to limit which /// components are accessed by the Query. /// @@ -195,7 +195,7 @@ unsafe impl WorldQuery for With { } } -impl WorldQueryFilter for With { +impl QueryFilter for With { const IS_ARCHETYPAL: bool = true; #[inline(always)] @@ -307,7 +307,7 @@ unsafe impl WorldQuery for Without { } } -impl WorldQueryFilter for Without { +impl QueryFilter for Without { const IS_ARCHETYPAL: bool = true; #[inline(always)] @@ -377,7 +377,7 @@ macro_rules! impl_query_filter_tuple { /// This is sound because `update_component_access` and `update_archetype_component_access` adds accesses according to the implementations of all the subqueries. /// `update_component_access` replace the filters with a disjunction where every element is a conjunction of the previous filters and the filters of one of the subqueries. /// This is sound because `matches_component_set` returns a disjunction of the results of the subqueries' implementations. - unsafe impl<$($filter: WorldQueryFilter),*> WorldQuery for Or<($($filter,)*)> { + unsafe impl<$($filter: QueryFilter),*> WorldQuery for Or<($($filter,)*)> { type Fetch<'w> = ($(OrFetch<'w, $filter>,)*); type Item<'w> = bool; type State = ($($filter::State,)*); @@ -471,7 +471,7 @@ macro_rules! impl_query_filter_tuple { } } - impl<$($filter: WorldQueryFilter),*> WorldQueryFilter for Or<($($filter,)*)> { + impl<$($filter: QueryFilter),*> QueryFilter for Or<($($filter,)*)> { const IS_ARCHETYPAL: bool = true $(&& $filter::IS_ARCHETYPAL)*; #[inline(always)] @@ -486,13 +486,13 @@ macro_rules! impl_query_filter_tuple { }; } -macro_rules! impl_tuple_world_query_filter { +macro_rules! impl_tuple_query_filter { ($($name: ident),*) => { #[allow(unused_variables)] #[allow(non_snake_case)] #[allow(clippy::unused_unit)] - impl<$($name: WorldQueryFilter),*> WorldQueryFilter for ($($name,)*) { + impl<$($name: QueryFilter),*> QueryFilter for ($($name,)*) { const IS_ARCHETYPAL: bool = true $(&& $name::IS_ARCHETYPAL)*; #[inline(always)] @@ -509,7 +509,7 @@ macro_rules! impl_tuple_world_query_filter { }; } -all_tuples!(impl_tuple_world_query_filter, 0, 15, F); +all_tuples!(impl_tuple_query_filter, 0, 15, F); all_tuples!(impl_query_filter_tuple, 0, 15, F, S); /// A filter on a component that only retains results added after the system last ran. @@ -670,7 +670,7 @@ unsafe impl WorldQuery for Added { } } -impl WorldQueryFilter for Added { +impl QueryFilter for Added { const IS_ARCHETYPAL: bool = false; #[inline(always)] unsafe fn filter_fetch( @@ -846,7 +846,7 @@ unsafe impl WorldQuery for Changed { } } -impl WorldQueryFilter for Changed { +impl QueryFilter for Changed { const IS_ARCHETYPAL: bool = false; #[inline(always)] @@ -864,14 +864,14 @@ impl WorldQueryFilter for Changed { /// This is needed to implement [`ExactSizeIterator`] for /// [`QueryIter`](crate::query::QueryIter) that contains archetype-level filters. /// -/// The trait must only be implemented for filters where its corresponding [`WorldQueryFilter::IS_ARCHETYPAL`] +/// The trait must only be implemented for filters where its corresponding [`QueryFilter::IS_ARCHETYPAL`] /// is [`prim@true`]. As such, only the [`With`] and [`Without`] filters can implement the trait. /// [Tuples](prim@tuple) and [`Or`] filters are automatically implemented with the trait only if its containing types /// also implement the same trait. /// /// [`Added`] and [`Changed`] works with entities, and therefore are not archetypal. As such /// they do not implement [`ArchetypeFilter`]. -pub trait ArchetypeFilter: WorldQueryFilter {} +pub trait ArchetypeFilter: QueryFilter {} impl ArchetypeFilter for With {} impl ArchetypeFilter for Without {} diff --git a/crates/bevy_ecs/src/query/iter.rs b/crates/bevy_ecs/src/query/iter.rs index f5359a25fbf07..86f77f3fd493f 100644 --- a/crates/bevy_ecs/src/query/iter.rs +++ b/crates/bevy_ecs/src/query/iter.rs @@ -8,20 +8,20 @@ use crate::{ }; use std::{borrow::Borrow, iter::FusedIterator, mem::MaybeUninit}; -use super::{ReadOnlyWorldQueryData, WorldQueryData, WorldQueryFilter}; +use super::{QueryData, QueryFilter, ReadOnlyQueryData}; /// An [`Iterator`] over query results of a [`Query`](crate::system::Query). /// /// This struct is created by the [`Query::iter`](crate::system::Query::iter) and /// [`Query::iter_mut`](crate::system::Query::iter_mut) methods. -pub struct QueryIter<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> { +pub struct QueryIter<'w, 's, Q: QueryData, F: QueryFilter> { tables: &'w Tables, archetypes: &'w Archetypes, query_state: &'s QueryState, cursor: QueryIterationCursor<'w, 's, Q, F>, } -impl<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> QueryIter<'w, 's, Q, F> { +impl<'w, 's, Q: QueryData, F: QueryFilter> QueryIter<'w, 's, Q, F> { /// # Safety /// - `world` must have permission to access any of the components registered in `query_state`. /// - `world` must be the same one used to initialize `query_state`. @@ -41,7 +41,7 @@ impl<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> QueryIter<'w, 's, Q, F> { } } -impl<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> Iterator for QueryIter<'w, 's, Q, F> { +impl<'w, 's, Q: QueryData, F: QueryFilter> Iterator for QueryIter<'w, 's, Q, F> { type Item = Q::Item<'w>; #[inline(always)] @@ -64,7 +64,7 @@ impl<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> Iterator for QueryIter<'w, } // This is correct as [`QueryIter`] always returns `None` once exhausted. -impl<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> FusedIterator for QueryIter<'w, 's, Q, F> {} +impl<'w, 's, Q: QueryData, F: QueryFilter> FusedIterator for QueryIter<'w, 's, Q, F> {} /// An [`Iterator`] over the query items generated from an iterator of [`Entity`]s. /// @@ -72,7 +72,7 @@ impl<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> FusedIterator for QueryIter /// Entities that don't match the query are skipped. /// /// This struct is created by the [`Query::iter_many`](crate::system::Query::iter_many) and [`Query::iter_many_mut`](crate::system::Query::iter_many_mut) methods. -pub struct QueryManyIter<'w, 's, Q: WorldQueryData, F: WorldQueryFilter, I: Iterator> +pub struct QueryManyIter<'w, 's, Q: QueryData, F: QueryFilter, I: Iterator> where I::Item: Borrow, { @@ -85,7 +85,7 @@ where query_state: &'s QueryState, } -impl<'w, 's, Q: WorldQueryData, F: WorldQueryFilter, I: Iterator> QueryManyIter<'w, 's, Q, F, I> +impl<'w, 's, Q: QueryData, F: QueryFilter, I: Iterator> QueryManyIter<'w, 's, Q, F, I> where I::Item: Borrow, { @@ -181,7 +181,7 @@ where } } -impl<'w, 's, Q: ReadOnlyWorldQueryData, F: WorldQueryFilter, I: Iterator> Iterator +impl<'w, 's, Q: ReadOnlyQueryData, F: QueryFilter, I: Iterator> Iterator for QueryManyIter<'w, 's, Q, F, I> where I::Item: Borrow, @@ -201,7 +201,7 @@ where } // This is correct as [`QueryManyIter`] always returns `None` once exhausted. -impl<'w, 's, Q: ReadOnlyWorldQueryData, F: WorldQueryFilter, I: Iterator> FusedIterator +impl<'w, 's, Q: ReadOnlyQueryData, F: QueryFilter, I: Iterator> FusedIterator for QueryManyIter<'w, 's, Q, F, I> where I::Item: Borrow, @@ -271,16 +271,14 @@ where /// [`Query`]: crate::system::Query /// [`Query::iter_combinations`]: crate::system::Query::iter_combinations /// [`Query::iter_combinations_mut`]: crate::system::Query::iter_combinations_mut -pub struct QueryCombinationIter<'w, 's, Q: WorldQueryData, F: WorldQueryFilter, const K: usize> { +pub struct QueryCombinationIter<'w, 's, Q: QueryData, F: QueryFilter, const K: usize> { tables: &'w Tables, archetypes: &'w Archetypes, query_state: &'s QueryState, cursors: [QueryIterationCursor<'w, 's, Q, F>; K], } -impl<'w, 's, Q: WorldQueryData, F: WorldQueryFilter, const K: usize> - QueryCombinationIter<'w, 's, Q, F, K> -{ +impl<'w, 's, Q: QueryData, F: QueryFilter, const K: usize> QueryCombinationIter<'w, 's, Q, F, K> { /// # Safety /// - `world` must have permission to access any of the components registered in `query_state`. /// - `world` must be the same one used to initialize `query_state`. @@ -385,7 +383,7 @@ impl<'w, 's, Q: WorldQueryData, F: WorldQueryFilter, const K: usize> // Iterator type is intentionally implemented only for read-only access. // Doing so for mutable references would be unsound, because calling `next` // multiple times would allow multiple owned references to the same data to exist. -impl<'w, 's, Q: ReadOnlyWorldQueryData, F: WorldQueryFilter, const K: usize> Iterator +impl<'w, 's, Q: ReadOnlyQueryData, F: QueryFilter, const K: usize> Iterator for QueryCombinationIter<'w, 's, Q, F, K> { type Item = [Q::Item<'w>; K]; @@ -428,7 +426,7 @@ impl<'w, 's, Q: ReadOnlyWorldQueryData, F: WorldQueryFilter, const K: usize> Ite } } -impl<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> ExactSizeIterator for QueryIter<'w, 's, Q, F> +impl<'w, 's, Q: QueryData, F: QueryFilter> ExactSizeIterator for QueryIter<'w, 's, Q, F> where F: ArchetypeFilter, { @@ -438,12 +436,12 @@ where } // This is correct as [`QueryCombinationIter`] always returns `None` once exhausted. -impl<'w, 's, Q: ReadOnlyWorldQueryData, F: WorldQueryFilter, const K: usize> FusedIterator +impl<'w, 's, Q: ReadOnlyQueryData, F: QueryFilter, const K: usize> FusedIterator for QueryCombinationIter<'w, 's, Q, F, K> { } -struct QueryIterationCursor<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> { +struct QueryIterationCursor<'w, 's, Q: QueryData, F: QueryFilter> { table_id_iter: std::slice::Iter<'s, TableId>, archetype_id_iter: std::slice::Iter<'s, ArchetypeId>, table_entities: &'w [Entity], @@ -456,7 +454,7 @@ struct QueryIterationCursor<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> { current_row: usize, } -impl Clone for QueryIterationCursor<'_, '_, Q, F> { +impl Clone for QueryIterationCursor<'_, '_, Q, F> { fn clone(&self) -> Self { Self { table_id_iter: self.table_id_iter.clone(), @@ -471,7 +469,7 @@ impl Clone for QueryIterationCursor<'_, } } -impl<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> QueryIterationCursor<'w, 's, Q, F> { +impl<'w, 's, Q: QueryData, F: QueryFilter> QueryIterationCursor<'w, 's, Q, F> { const IS_DENSE: bool = Q::IS_DENSE && F::IS_DENSE; unsafe fn init_empty( diff --git a/crates/bevy_ecs/src/query/mod.rs b/crates/bevy_ecs/src/query/mod.rs index 2e6f4df187a40..7d7c74c2c6740 100644 --- a/crates/bevy_ecs/src/query/mod.rs +++ b/crates/bevy_ecs/src/query/mod.rs @@ -10,7 +10,7 @@ mod state; mod world_query; pub use access::*; -pub use bevy_ecs_macros::{WorldQueryData, WorldQueryFilter}; +pub use bevy_ecs_macros::{QueryData, QueryFilter}; pub use error::*; pub use fetch::*; pub use filter::*; @@ -67,10 +67,10 @@ impl DebugCheckedUnwrap for Option { #[cfg(test)] mod tests { - use bevy_ecs_macros::{WorldQueryData, WorldQueryFilter}; + use bevy_ecs_macros::{QueryData, QueryFilter}; use crate::prelude::{AnyOf, Changed, Entity, Or, QueryState, With, Without}; - use crate::query::{ArchetypeFilter, Has, QueryCombinationIter, ReadOnlyWorldQueryData}; + use crate::query::{ArchetypeFilter, Has, QueryCombinationIter, ReadOnlyQueryData}; use crate::schedule::{IntoSystemConfigs, Schedule}; use crate::system::{IntoSystem, Query, System, SystemState}; use crate::{self as bevy_ecs, component::Component, world::World}; @@ -117,7 +117,7 @@ mod tests { } fn assert_combination(world: &mut World, expected_size: usize) where - Q: ReadOnlyWorldQueryData, + Q: ReadOnlyQueryData, F: ArchetypeFilter, { let mut query = world.query_filtered::(); @@ -131,7 +131,7 @@ mod tests { } fn assert_all_sizes_equal(world: &mut World, expected_size: usize) where - Q: ReadOnlyWorldQueryData, + Q: ReadOnlyQueryData, F: ArchetypeFilter, { let mut query = world.query_filtered::(); @@ -501,8 +501,8 @@ mod tests { #[test] #[should_panic = "&mut bevy_ecs::query::tests::A conflicts with a previous access in this query."] fn self_conflicting_worldquery() { - #[derive(WorldQueryData)] - #[world_query_data(mutable)] + #[derive(QueryData)] + #[query_data(mutable)] struct SelfConflicting { a: &'static mut A, b: &'static mut A, @@ -538,7 +538,7 @@ mod tests { world.spawn_empty(); { - #[derive(WorldQueryData)] + #[derive(QueryData)] struct CustomAB { a: &'static A, b: &'static B, @@ -558,7 +558,7 @@ mod tests { } { - #[derive(WorldQueryData)] + #[derive(QueryData)] struct FancyParam { e: Entity, b: &'static B, @@ -579,11 +579,11 @@ mod tests { } { - #[derive(WorldQueryData)] + #[derive(QueryData)] struct MaybeBSparse { blah: Option<(&'static B, &'static Sparse)>, } - #[derive(WorldQueryData)] + #[derive(QueryData)] struct MatchEverything { abcs: AnyOf<(&'static A, &'static B, &'static C)>, opt_bsparse: MaybeBSparse, @@ -618,11 +618,11 @@ mod tests { } { - #[derive(WorldQueryFilter)] + #[derive(QueryFilter)] struct AOrBFilter { a: Or<(With, With)>, } - #[derive(WorldQueryFilter)] + #[derive(QueryFilter)] struct NoSparseThatsSlow { no: Without, } @@ -639,7 +639,7 @@ mod tests { } { - #[derive(WorldQueryFilter)] + #[derive(QueryFilter)] struct CSparseFilter { tuple_structs_pls: With, ugh: With, @@ -657,7 +657,7 @@ mod tests { } { - #[derive(WorldQueryFilter)] + #[derive(QueryFilter)] struct WithoutComps { _1: Without, _2: Without, @@ -676,7 +676,7 @@ mod tests { } { - #[derive(WorldQueryData)] + #[derive(QueryData)] struct IterCombAB { a: &'static A, b: &'static B, diff --git a/crates/bevy_ecs/src/query/par_iter.rs b/crates/bevy_ecs/src/query/par_iter.rs index c21931c27ebf3..05c76787b39b0 100644 --- a/crates/bevy_ecs/src/query/par_iter.rs +++ b/crates/bevy_ecs/src/query/par_iter.rs @@ -1,7 +1,7 @@ use crate::{component::Tick, world::unsafe_world_cell::UnsafeWorldCell}; use std::ops::Range; -use super::{QueryItem, QueryState, WorldQueryData, WorldQueryFilter}; +use super::{QueryData, QueryFilter, QueryItem, QueryState}; /// Dictates how a parallel query chunks up large tables/archetypes /// during iteration. @@ -82,7 +82,7 @@ impl BatchingStrategy { /// /// This struct is created by the [`Query::par_iter`](crate::system::Query::par_iter) and /// [`Query::par_iter_mut`](crate::system::Query::par_iter_mut) methods. -pub struct QueryParIter<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> { +pub struct QueryParIter<'w, 's, Q: QueryData, F: QueryFilter> { pub(crate) world: UnsafeWorldCell<'w>, pub(crate) state: &'s QueryState, pub(crate) last_run: Tick, @@ -90,7 +90,7 @@ pub struct QueryParIter<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> { pub(crate) batching_strategy: BatchingStrategy, } -impl<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> QueryParIter<'w, 's, Q, F> { +impl<'w, 's, Q: QueryData, F: QueryFilter> QueryParIter<'w, 's, Q, F> { /// Changes the batching strategy used when iterating. /// /// For more information on how this affects the resultant iteration, see diff --git a/crates/bevy_ecs/src/query/state.rs b/crates/bevy_ecs/src/query/state.rs index d4afbfe5ac9c0..e6e5d23da6627 100644 --- a/crates/bevy_ecs/src/query/state.rs +++ b/crates/bevy_ecs/src/query/state.rs @@ -17,16 +17,16 @@ use fixedbitset::FixedBitSet; use std::{any::TypeId, borrow::Borrow, fmt, mem::MaybeUninit}; use super::{ - NopWorldQuery, QueryComponentError, QueryEntityError, QueryManyIter, QuerySingleError, - ROQueryItem, WorldQueryData, WorldQueryFilter, + NopWorldQuery, QueryComponentError, QueryData, QueryEntityError, QueryFilter, QueryManyIter, + QuerySingleError, ROQueryItem, }; -/// Provides scoped access to a [`World`] state according to a given [`WorldQueryData`] and [`WorldQueryFilter`]. +/// Provides scoped access to a [`World`] state according to a given [`QueryData`] and [`QueryFilter`]. #[repr(C)] // SAFETY NOTE: // Do not add any new fields that use the `Q` or `F` generic parameters as this may // make `QueryState::as_transmuted_state` unsound if not done with care. -pub struct QueryState { +pub struct QueryState { world_id: WorldId, pub(crate) archetype_generation: ArchetypeGeneration, pub(crate) matched_tables: FixedBitSet, @@ -43,7 +43,7 @@ pub struct QueryState { par_iter_span: Span, } -impl fmt::Debug for QueryState { +impl fmt::Debug for QueryState { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("QueryState") .field("world_id", &self.world_id) @@ -53,13 +53,13 @@ impl fmt::Debug for QueryState { } } -impl FromWorld for QueryState { +impl FromWorld for QueryState { fn from_world(world: &mut World) -> Self { world.query_filtered() } } -impl QueryState { +impl QueryState { /// Converts this `QueryState` reference to a `QueryState` that does not access anything mutably. pub fn as_readonly(&self) -> &QueryState { // SAFETY: invariant on `WorldQuery` trait upholds that `Q::ReadOnly` and `F::ReadOnly` @@ -88,8 +88,8 @@ impl QueryState { /// `NewQ` must have a subset of the access that `Q` does and match the exact same archetypes/tables /// `NewF` must have a subset of the access that `F` does and match the exact same archetypes/tables pub(crate) unsafe fn as_transmuted_state< - NewQ: WorldQueryData, - NewF: WorldQueryFilter, + NewQ: QueryData, + NewF: QueryFilter, >( &self, ) -> &QueryState { @@ -97,7 +97,7 @@ impl QueryState { } } -impl QueryState { +impl QueryState { /// Creates a new [`QueryState`] from a given [`World`] and inherits the result of `world.id()`. pub fn new(world: &mut World) -> Self { let fetch_state = Q::init_state(world); @@ -162,7 +162,7 @@ impl QueryState { /// /// # Safety /// - /// - `world` must have permission to read any components required by this instance's `F` [`WorldQueryFilter`]. + /// - `world` must have permission to read any components required by this instance's `F` [`QueryFilter`]. /// - `world` must match the one used to create this [`QueryState`]. #[inline] pub(crate) unsafe fn is_empty_unsafe_world_cell( diff --git a/crates/bevy_ecs/src/query/world_query.rs b/crates/bevy_ecs/src/query/world_query.rs index 1641f5bed1bd2..758a3e56b0fe3 100644 --- a/crates/bevy_ecs/src/query/world_query.rs +++ b/crates/bevy_ecs/src/query/world_query.rs @@ -9,7 +9,7 @@ use crate::{ use bevy_utils::all_tuples; /// Types that can be used as parameters in a [`Query`]. -/// Types that implement this should also implement either [`WorldQueryData`] or [`WorldQueryFilter`] +/// Types that implement this should also implement either [`QueryData`] or [`QueryFilter`] /// /// # Safety /// @@ -36,12 +36,12 @@ use bevy_utils::all_tuples; /// [`Query`]: crate::system::Query /// [`update_archetype_component_access`]: Self::update_archetype_component_access /// [`update_component_access`]: Self::update_component_access -/// [`WorldQueryData`]: crate::query::WorldQueryData -/// [`WorldQueryFilter`]: crate::query::WorldQueryFilter +/// [`QueryData`]: crate::query::QueryData +/// [`QueryFilter`]: crate::query::QueryFilter pub unsafe trait WorldQuery { /// The item returned by this [`WorldQuery`] - /// For `WorldQueryData` this will be the item returned by the query. - /// For `WorldQueryFilter` this will be either `()`, or a `bool` indicating whether the entity should be included + /// For `QueryData` this will be the item returned by the query. + /// For `QueryFilter` this will be either `()`, or a `bool` indicating whether the entity should be included /// or a tuple of such things. type Item<'a>; diff --git a/crates/bevy_ecs/src/system/exclusive_system_param.rs b/crates/bevy_ecs/src/system/exclusive_system_param.rs index 64789f357a6b6..759c8ab547390 100644 --- a/crates/bevy_ecs/src/system/exclusive_system_param.rs +++ b/crates/bevy_ecs/src/system/exclusive_system_param.rs @@ -1,6 +1,6 @@ use crate::{ prelude::{FromWorld, QueryState}, - query::{WorldQueryData, WorldQueryFilter}, + query::{QueryData, QueryFilter}, system::{Local, SystemMeta, SystemParam, SystemState}, world::World, }; @@ -29,7 +29,7 @@ pub trait ExclusiveSystemParam: Sized { /// for a given [`ExclusiveSystemParam`]. pub type ExclusiveSystemParamItem<'s, P> =

::Item<'s>; -impl<'a, Q: WorldQueryData + 'static, F: WorldQueryFilter + 'static> ExclusiveSystemParam +impl<'a, Q: QueryData + 'static, F: QueryFilter + 'static> ExclusiveSystemParam for &'a mut QueryState { type State = QueryState; diff --git a/crates/bevy_ecs/src/system/query.rs b/crates/bevy_ecs/src/system/query.rs index 54f20848cbc99..dc752d87a45cb 100644 --- a/crates/bevy_ecs/src/system/query.rs +++ b/crates/bevy_ecs/src/system/query.rs @@ -2,9 +2,9 @@ use crate::{ component::{Component, Tick}, entity::Entity, query::{ - BatchingStrategy, QueryCombinationIter, QueryComponentError, QueryEntityError, QueryIter, - QueryManyIter, QueryParIter, QuerySingleError, QueryState, ROQueryItem, - ReadOnlyWorldQueryData, WorldQueryData, WorldQueryFilter, + BatchingStrategy, QueryCombinationIter, QueryComponentError, QueryData, QueryEntityError, + QueryFilter, QueryIter, QueryManyIter, QueryParIter, QuerySingleError, QueryState, + ROQueryItem, ReadOnlyQueryData, }, world::{unsafe_world_cell::UnsafeWorldCell, Mut}, }; @@ -21,10 +21,10 @@ use std::{any::TypeId, borrow::Borrow}; /// - **`Q` (query fetch).** /// The type of data contained in the query item. /// Only entities that match the requested data will generate an item. -/// Must implement the [`WorldQueryData`] trait. +/// Must implement the [`QueryData`] trait. /// - **`F` (query filter).** /// A set of conditions that determines whether query items should be kept or discarded. -/// Must implement the [`WorldQueryFilter`] trait. +/// Must implement the [`QueryFilter`] trait. /// This type parameter is optional. /// /// [`World`]: crate::world::World @@ -73,7 +73,7 @@ use std::{any::TypeId, borrow::Borrow}; /// # bevy_ecs::system::assert_is_system(system); /// ``` /// -/// ## `WorldQueryData` or `WorldQueryFilter` tuples +/// ## `QueryData` or `QueryFilter` tuples /// /// Using tuples, each `Query` type parameter can contain multiple elements. /// @@ -325,7 +325,7 @@ use std::{any::TypeId, borrow::Borrow}; /// [`Table`]: crate::storage::Table /// [`With`]: crate::query::With /// [`Without`]: crate::query::Without -pub struct Query<'world, 'state, Q: WorldQueryData, F: WorldQueryFilter = ()> { +pub struct Query<'world, 'state, Q: QueryData, F: QueryFilter = ()> { // SAFETY: Must have access to the components registered in `state`. world: UnsafeWorldCell<'world>, state: &'state QueryState, @@ -339,7 +339,7 @@ pub struct Query<'world, 'state, Q: WorldQueryData, F: WorldQueryFilter = ()> { force_read_only_component_access: bool, } -impl std::fmt::Debug for Query<'_, '_, Q, F> { +impl std::fmt::Debug for Query<'_, '_, Q, F> { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.debug_struct("Query") .field("matched_entities", &self.iter().count()) @@ -351,7 +351,7 @@ impl std::fmt::Debug for Query<'_, '_, Q } } -impl<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> Query<'w, 's, Q, F> { +impl<'w, 's, Q: QueryData, F: QueryFilter> Query<'w, 's, Q, F> { /// Creates a new query. /// /// # Panics @@ -1422,7 +1422,7 @@ impl<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> Query<'w, 's, Q, F> { } } -impl<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> IntoIterator for &'w Query<'_, 's, Q, F> { +impl<'w, 's, Q: QueryData, F: QueryFilter> IntoIterator for &'w Query<'_, 's, Q, F> { type Item = ROQueryItem<'w, Q>; type IntoIter = QueryIter<'w, 's, Q::ReadOnly, F>; @@ -1431,7 +1431,7 @@ impl<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> IntoIterator for &'w Query< } } -impl<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> IntoIterator for &'w mut Query<'_, 's, Q, F> { +impl<'w, 's, Q: QueryData, F: QueryFilter> IntoIterator for &'w mut Query<'_, 's, Q, F> { type Item = Q::Item<'w>; type IntoIter = QueryIter<'w, 's, Q, F>; @@ -1440,7 +1440,7 @@ impl<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> IntoIterator for &'w mut Qu } } -impl<'w, 's, Q: ReadOnlyWorldQueryData, F: WorldQueryFilter> Query<'w, 's, Q, F> { +impl<'w, 's, Q: ReadOnlyQueryData, F: QueryFilter> Query<'w, 's, Q, F> { /// Returns the query item for the given [`Entity`], with the actual "inner" world lifetime. /// /// In case of a nonexisting entity or mismatched component, a [`QueryEntityError`] is diff --git a/crates/bevy_ecs/src/system/system_param.rs b/crates/bevy_ecs/src/system/system_param.rs index 183368a4e1b35..f138ff6229b3b 100644 --- a/crates/bevy_ecs/src/system/system_param.rs +++ b/crates/bevy_ecs/src/system/system_param.rs @@ -6,8 +6,8 @@ use crate::{ component::{ComponentId, ComponentTicks, Components, Tick}, entity::Entities, query::{ - Access, FilteredAccess, FilteredAccessSet, QueryState, ReadOnlyWorldQueryData, - WorldQueryData, WorldQueryFilter, + Access, FilteredAccess, FilteredAccessSet, QueryData, QueryFilter, QueryState, + ReadOnlyQueryData, }, system::{Query, SystemMeta}, world::{unsafe_world_cell::UnsafeWorldCell, FromWorld, World}, @@ -153,16 +153,14 @@ pub unsafe trait ReadOnlySystemParam: SystemParam {} pub type SystemParamItem<'w, 's, P> =

::Item<'w, 's>; // SAFETY: QueryState is constrained to read-only fetches, so it only reads World. -unsafe impl<'w, 's, Q: ReadOnlyWorldQueryData + 'static, F: WorldQueryFilter + 'static> - ReadOnlySystemParam for Query<'w, 's, Q, F> +unsafe impl<'w, 's, Q: ReadOnlyQueryData + 'static, F: QueryFilter + 'static> ReadOnlySystemParam + for Query<'w, 's, Q, F> { } // SAFETY: Relevant query ComponentId and ArchetypeComponentId access is applied to SystemMeta. If // this Query conflicts with any prior access, a panic will occur. -unsafe impl SystemParam - for Query<'_, '_, Q, F> -{ +unsafe impl SystemParam for Query<'_, '_, Q, F> { type State = QueryState; type Item<'w, 's> = Query<'w, 's, Q, F>; @@ -1568,8 +1566,8 @@ mod tests { pub struct SpecialQuery< 'w, 's, - Q: WorldQueryData + Send + Sync + 'static, - F: WorldQueryFilter + Send + Sync + 'static = (), + Q: QueryData + Send + Sync + 'static, + F: QueryFilter + Send + Sync + 'static = (), > { _query: Query<'w, 's, Q, F>, } @@ -1690,7 +1688,7 @@ mod tests { #[derive(SystemParam)] pub struct WhereParam<'w, 's, Q> where - Q: 'static + WorldQueryData, + Q: 'static + QueryData, { _q: Query<'w, 's, Q, ()>, } diff --git a/crates/bevy_ecs/src/world/mod.rs b/crates/bevy_ecs/src/world/mod.rs index 397f38bc795f3..9fb9d1fa7fc88 100644 --- a/crates/bevy_ecs/src/world/mod.rs +++ b/crates/bevy_ecs/src/world/mod.rs @@ -18,7 +18,7 @@ use crate::{ component::{Component, ComponentDescriptor, ComponentId, ComponentInfo, Components, Tick}, entity::{AllocAtWithoutReplacement, Entities, Entity, EntityLocation}, event::{Event, EventId, Events, SendBatchIds}, - query::{DebugCheckedUnwrap, QueryEntityError, QueryState, WorldQueryData, WorldQueryFilter}, + query::{DebugCheckedUnwrap, QueryData, QueryEntityError, QueryFilter, QueryState}, removal_detection::RemovedComponentEvents, schedule::{Schedule, ScheduleLabel, Schedules}, storage::{ResourceData, Storages}, @@ -922,7 +922,7 @@ impl World { self.last_change_tick = self.increment_change_tick(); } - /// Returns [`QueryState`] for the given [`WorldQueryData`], which is used to efficiently + /// Returns [`QueryState`] for the given [`QueryData`], which is used to efficiently /// run queries on the [`World`] by storing and reusing the [`QueryState`]. /// ``` /// use bevy_ecs::{component::Component, entity::Entity, world::World}; @@ -985,11 +985,11 @@ impl World { /// ]); /// ``` #[inline] - pub fn query(&mut self) -> QueryState { + pub fn query(&mut self) -> QueryState { self.query_filtered::() } - /// Returns [`QueryState`] for the given filtered [`WorldQueryData`], which is used to efficiently + /// Returns [`QueryState`] for the given filtered [`QueryData`], which is used to efficiently /// run queries on the [`World`] by storing and reusing the [`QueryState`]. /// ``` /// use bevy_ecs::{component::Component, entity::Entity, world::World, query::With}; @@ -1009,7 +1009,7 @@ impl World { /// assert_eq!(matching_entities, vec![e2]); /// ``` #[inline] - pub fn query_filtered(&mut self) -> QueryState { + pub fn query_filtered(&mut self) -> QueryState { QueryState::new(self) } diff --git a/crates/bevy_ecs_compile_fail_tests/tests/ui/query_iter_combinations_mut_iterator_safety.stderr b/crates/bevy_ecs_compile_fail_tests/tests/ui/query_iter_combinations_mut_iterator_safety.stderr index 7129822002049..a2059f29b57ce 100644 --- a/crates/bevy_ecs_compile_fail_tests/tests/ui/query_iter_combinations_mut_iterator_safety.stderr +++ b/crates/bevy_ecs_compile_fail_tests/tests/ui/query_iter_combinations_mut_iterator_safety.stderr @@ -1,12 +1,12 @@ -error[E0277]: the trait bound `&mut A: ReadOnlyWorldQueryData` is not satisfied +error[E0277]: the trait bound `&mut A: ReadOnlyQueryData` is not satisfied --> tests/ui/query_iter_combinations_mut_iterator_safety.rs:10:17 | 10 | is_iterator(iter) - | ----------- ^^^^ the trait `ReadOnlyWorldQueryData` is not implemented for `&mut A` + | ----------- ^^^^ the trait `ReadOnlyQueryData` is not implemented for `&mut A` | | | required by a bound introduced by this call | - = help: the following other types implement trait `ReadOnlyWorldQueryData`: + = help: the following other types implement trait `ReadOnlyQueryData`: bevy_ecs::change_detection::Ref<'__w, T> Has AnyOf<()> @@ -16,7 +16,7 @@ error[E0277]: the trait bound `&mut A: ReadOnlyWorldQueryData` is not satisfied AnyOf<(F0, F1, F2, F3)> AnyOf<(F0, F1, F2, F3, F4)> and $N others - = note: `ReadOnlyWorldQueryData` is implemented for `&A`, but not for `&mut A` + = note: `ReadOnlyQueryData` is implemented for `&A`, but not for `&mut A` = note: required for `QueryCombinationIter<'_, '_, &mut A, (), _>` to implement `Iterator` note: required by a bound in `is_iterator` --> tests/ui/query_iter_combinations_mut_iterator_safety.rs:13:19 diff --git a/crates/bevy_ecs_compile_fail_tests/tests/ui/query_iter_many_mut_iterator_safety.stderr b/crates/bevy_ecs_compile_fail_tests/tests/ui/query_iter_many_mut_iterator_safety.stderr index 9083289fe4881..959e4d126eedd 100644 --- a/crates/bevy_ecs_compile_fail_tests/tests/ui/query_iter_many_mut_iterator_safety.stderr +++ b/crates/bevy_ecs_compile_fail_tests/tests/ui/query_iter_many_mut_iterator_safety.stderr @@ -1,12 +1,12 @@ -error[E0277]: the trait bound `&mut A: ReadOnlyWorldQueryData` is not satisfied +error[E0277]: the trait bound `&mut A: ReadOnlyQueryData` is not satisfied --> tests/ui/query_iter_many_mut_iterator_safety.rs:10:17 | 10 | is_iterator(iter) - | ----------- ^^^^ the trait `ReadOnlyWorldQueryData` is not implemented for `&mut A` + | ----------- ^^^^ the trait `ReadOnlyQueryData` is not implemented for `&mut A` | | | required by a bound introduced by this call | - = help: the following other types implement trait `ReadOnlyWorldQueryData`: + = help: the following other types implement trait `ReadOnlyQueryData`: bevy_ecs::change_detection::Ref<'__w, T> Has AnyOf<()> @@ -16,7 +16,7 @@ error[E0277]: the trait bound `&mut A: ReadOnlyWorldQueryData` is not satisfied AnyOf<(F0, F1, F2, F3)> AnyOf<(F0, F1, F2, F3, F4)> and $N others - = note: `ReadOnlyWorldQueryData` is implemented for `&A`, but not for `&mut A` + = note: `ReadOnlyQueryData` is implemented for `&A`, but not for `&mut A` = note: required for `QueryManyIter<'_, '_, &mut A, (), std::array::IntoIter>` to implement `Iterator` note: required by a bound in `is_iterator` --> tests/ui/query_iter_many_mut_iterator_safety.rs:13:19 diff --git a/crates/bevy_ecs_compile_fail_tests/tests/ui/system_param_derive_readonly.stderr b/crates/bevy_ecs_compile_fail_tests/tests/ui/system_param_derive_readonly.stderr index 49e2eae85b99a..49120c73bb565 100644 --- a/crates/bevy_ecs_compile_fail_tests/tests/ui/system_param_derive_readonly.stderr +++ b/crates/bevy_ecs_compile_fail_tests/tests/ui/system_param_derive_readonly.stderr @@ -6,13 +6,13 @@ warning: unused import: `SystemState` | = note: `#[warn(unused_imports)]` on by default -error[E0277]: the trait bound `&'static mut Foo: ReadOnlyWorldQueryData` is not satisfied +error[E0277]: the trait bound `&'static mut Foo: ReadOnlyQueryData` is not satisfied --> tests/ui/system_param_derive_readonly.rs:18:23 | 18 | assert_readonly::(); - | ^^^^^^^ the trait `ReadOnlyWorldQueryData` is not implemented for `&'static mut Foo` + | ^^^^^^^ the trait `ReadOnlyQueryData` is not implemented for `&'static mut Foo` | - = help: the following other types implement trait `ReadOnlyWorldQueryData`: + = help: the following other types implement trait `ReadOnlyQueryData`: bevy_ecs::change_detection::Ref<'__w, T> Has AnyOf<()> @@ -22,7 +22,7 @@ error[E0277]: the trait bound `&'static mut Foo: ReadOnlyWorldQueryData` is not AnyOf<(F0, F1, F2, F3)> AnyOf<(F0, F1, F2, F3, F4)> and $N others - = note: `ReadOnlyWorldQueryData` is implemented for `&'static Foo`, but not for `&'static mut Foo` + = note: `ReadOnlyQueryData` is implemented for `&'static Foo`, but not for `&'static mut Foo` = note: required for `bevy_ecs::system::Query<'_, '_, &'static mut Foo>` to implement `ReadOnlySystemParam` = note: 1 redundant requirement hidden = note: required for `Mutable<'_, '_>` to implement `ReadOnlySystemParam` diff --git a/crates/bevy_ecs_compile_fail_tests/tests/ui/world_query_derive.rs b/crates/bevy_ecs_compile_fail_tests/tests/ui/world_query_derive.rs index 64ccd386daac5..0012aa69ded34 100644 --- a/crates/bevy_ecs_compile_fail_tests/tests/ui/world_query_derive.rs +++ b/crates/bevy_ecs_compile_fail_tests/tests/ui/world_query_derive.rs @@ -1,21 +1,21 @@ use bevy_ecs::prelude::*; -use bevy_ecs::query::WorldQueryData; +use bevy_ecs::query::QueryData; #[derive(Component)] struct Foo; -#[derive(WorldQueryData)] +#[derive(QueryData)] struct MutableUnmarked { a: &'static mut Foo, } -#[derive(WorldQueryData)] -#[world_query_data(mutable)] +#[derive(QueryData)] +#[query_data(mutable)] struct MutableMarked { a: &'static mut Foo, } -#[derive(WorldQueryData)] +#[derive(QueryData)] struct NestedMutableUnmarked { a: MutableMarked, } diff --git a/crates/bevy_ecs_compile_fail_tests/tests/ui/world_query_derive.stderr b/crates/bevy_ecs_compile_fail_tests/tests/ui/world_query_derive.stderr index 8942271b197af..34d72b1dc5b72 100644 --- a/crates/bevy_ecs_compile_fail_tests/tests/ui/world_query_derive.stderr +++ b/crates/bevy_ecs_compile_fail_tests/tests/ui/world_query_derive.stderr @@ -1,10 +1,10 @@ -error[E0277]: the trait bound `&'static mut Foo: ReadOnlyWorldQueryData` is not satisfied +error[E0277]: the trait bound `&'static mut Foo: ReadOnlyQueryData` is not satisfied --> tests/ui/world_query_derive.rs:9:8 | 9 | a: &'static mut Foo, - | ^^^^^^^^^^^^^^^^ the trait `ReadOnlyWorldQueryData` is not implemented for `&'static mut Foo` + | ^^^^^^^^^^^^^^^^ the trait `ReadOnlyQueryData` is not implemented for `&'static mut Foo` | - = help: the following other types implement trait `ReadOnlyWorldQueryData`: + = help: the following other types implement trait `ReadOnlyQueryData`: MutableUnmarked MutableMarkedReadOnly NestedMutableUnmarked @@ -17,17 +17,17 @@ error[E0277]: the trait bound `&'static mut Foo: ReadOnlyWorldQueryData` is not note: required by a bound in `_::assert_readonly` --> tests/ui/world_query_derive.rs:7:10 | -7 | #[derive(WorldQueryData)] - | ^^^^^^^^^^^^^^ required by this bound in `assert_readonly` - = note: this error originates in the derive macro `WorldQueryData` (in Nightly builds, run with -Z macro-backtrace for more info) +7 | #[derive(QueryData)] + | ^^^^^^^^^ required by this bound in `assert_readonly` + = note: this error originates in the derive macro `QueryData` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `MutableMarked: ReadOnlyWorldQueryData` is not satisfied +error[E0277]: the trait bound `MutableMarked: ReadOnlyQueryData` is not satisfied --> tests/ui/world_query_derive.rs:20:8 | 20 | a: MutableMarked, - | ^^^^^^^^^^^^^ the trait `ReadOnlyWorldQueryData` is not implemented for `MutableMarked` + | ^^^^^^^^^^^^^ the trait `ReadOnlyQueryData` is not implemented for `MutableMarked` | - = help: the following other types implement trait `ReadOnlyWorldQueryData`: + = help: the following other types implement trait `ReadOnlyQueryData`: MutableUnmarked MutableMarkedReadOnly NestedMutableUnmarked @@ -40,6 +40,6 @@ error[E0277]: the trait bound `MutableMarked: ReadOnlyWorldQueryData` is not sat note: required by a bound in `_::assert_readonly` --> tests/ui/world_query_derive.rs:18:10 | -18 | #[derive(WorldQueryData)] - | ^^^^^^^^^^^^^^ required by this bound in `assert_readonly` - = note: this error originates in the derive macro `WorldQueryData` (in Nightly builds, run with -Z macro-backtrace for more info) +18 | #[derive(QueryData)] + | ^^^^^^^^^ required by this bound in `assert_readonly` + = note: this error originates in the derive macro `QueryData` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/crates/bevy_gizmos/src/lib.rs b/crates/bevy_gizmos/src/lib.rs index 2b8a3df7d2e0a..26864664adc3a 100644 --- a/crates/bevy_gizmos/src/lib.rs +++ b/crates/bevy_gizmos/src/lib.rs @@ -431,15 +431,15 @@ fn prepare_line_gizmo_bind_group( struct SetLineGizmoBindGroup; impl RenderCommand

for SetLineGizmoBindGroup { - type ViewWorldQuery = (); - type ItemWorldQuery = Read>; + type ViewData = (); + type ItemData = Read>; type Param = SRes; #[inline] fn render<'w>( _item: &P, - _view: ROQueryItem<'w, Self::ViewWorldQuery>, - uniform_index: ROQueryItem<'w, Self::ItemWorldQuery>, + _view: ROQueryItem<'w, Self::ViewData>, + uniform_index: ROQueryItem<'w, Self::ItemData>, bind_group: SystemParamItem<'w, '_, Self::Param>, pass: &mut TrackedRenderPass<'w>, ) -> RenderCommandResult { @@ -454,15 +454,15 @@ impl RenderCommand

for SetLineGizmoBindGroup struct DrawLineGizmo; impl RenderCommand

for DrawLineGizmo { - type ViewWorldQuery = (); - type ItemWorldQuery = Read>; + type ViewData = (); + type ItemData = Read>; type Param = SRes>; #[inline] fn render<'w>( _item: &P, - _view: ROQueryItem<'w, Self::ViewWorldQuery>, - handle: ROQueryItem<'w, Self::ItemWorldQuery>, + _view: ROQueryItem<'w, Self::ViewData>, + handle: ROQueryItem<'w, Self::ItemData>, line_gizmos: SystemParamItem<'w, '_, Self::Param>, pass: &mut TrackedRenderPass<'w>, ) -> RenderCommandResult { diff --git a/crates/bevy_hierarchy/src/query_extension.rs b/crates/bevy_hierarchy/src/query_extension.rs index edb70bf425522..fdf8cd4e7936b 100644 --- a/crates/bevy_hierarchy/src/query_extension.rs +++ b/crates/bevy_hierarchy/src/query_extension.rs @@ -2,14 +2,14 @@ use std::collections::VecDeque; use bevy_ecs::{ entity::Entity, - query::{WorldQuery, WorldQueryData, WorldQueryFilter}, + query::{QueryData, QueryFilter, WorldQuery}, system::Query, }; use crate::{Children, Parent}; /// An extension trait for [`Query`] that adds hierarchy related methods. -pub trait HierarchyQueryExt<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> { +pub trait HierarchyQueryExt<'w, 's, Q: QueryData, F: QueryFilter> { /// Returns an [`Iterator`] of [`Entity`]s over all of `entity`s descendants. /// /// Can only be called on a [`Query`] of [`Children`] (i.e. `Query<&Children>`). @@ -57,9 +57,7 @@ pub trait HierarchyQueryExt<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> { Q::ReadOnly: WorldQuery = &'w Parent>; } -impl<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> HierarchyQueryExt<'w, 's, Q, F> - for Query<'w, 's, Q, F> -{ +impl<'w, 's, Q: QueryData, F: QueryFilter> HierarchyQueryExt<'w, 's, Q, F> for Query<'w, 's, Q, F> { fn iter_descendants(&'w self, entity: Entity) -> DescendantIter<'w, 's, Q, F> where Q::ReadOnly: WorldQuery = &'w Children>, @@ -78,7 +76,7 @@ impl<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> HierarchyQueryExt<'w, 's, Q /// An [`Iterator`] of [`Entity`]s over the descendants of an [`Entity`]. /// /// Traverses the hierarchy breadth-first. -pub struct DescendantIter<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> +pub struct DescendantIter<'w, 's, Q: QueryData, F: QueryFilter> where Q::ReadOnly: WorldQuery = &'w Children>, { @@ -86,7 +84,7 @@ where vecdeque: VecDeque, } -impl<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> DescendantIter<'w, 's, Q, F> +impl<'w, 's, Q: QueryData, F: QueryFilter> DescendantIter<'w, 's, Q, F> where Q::ReadOnly: WorldQuery = &'w Children>, { @@ -104,7 +102,7 @@ where } } -impl<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> Iterator for DescendantIter<'w, 's, Q, F> +impl<'w, 's, Q: QueryData, F: QueryFilter> Iterator for DescendantIter<'w, 's, Q, F> where Q::ReadOnly: WorldQuery = &'w Children>, { @@ -122,7 +120,7 @@ where } /// An [`Iterator`] of [`Entity`]s over the ancestors of an [`Entity`]. -pub struct AncestorIter<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> +pub struct AncestorIter<'w, 's, Q: QueryData, F: QueryFilter> where Q::ReadOnly: WorldQuery = &'w Parent>, { @@ -130,7 +128,7 @@ where next: Option, } -impl<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> AncestorIter<'w, 's, Q, F> +impl<'w, 's, Q: QueryData, F: QueryFilter> AncestorIter<'w, 's, Q, F> where Q::ReadOnly: WorldQuery = &'w Parent>, { @@ -143,7 +141,7 @@ where } } -impl<'w, 's, Q: WorldQueryData, F: WorldQueryFilter> Iterator for AncestorIter<'w, 's, Q, F> +impl<'w, 's, Q: QueryData, F: QueryFilter> Iterator for AncestorIter<'w, 's, Q, F> where Q::ReadOnly: WorldQuery = &'w Parent>, { diff --git a/crates/bevy_pbr/src/deferred/mod.rs b/crates/bevy_pbr/src/deferred/mod.rs index 5de8f327f8d72..f32ca014fbc4a 100644 --- a/crates/bevy_pbr/src/deferred/mod.rs +++ b/crates/bevy_pbr/src/deferred/mod.rs @@ -149,7 +149,7 @@ pub const DEFERRED_LIGHTING_PASS: &str = "deferred_opaque_pbr_lighting_pass_3d"; pub struct DeferredOpaquePass3dPbrLightingNode; impl ViewNode for DeferredOpaquePass3dPbrLightingNode { - type ViewQuery = ( + type ViewData = ( &'static ViewUniformOffset, &'static ViewLightsUniformOffset, &'static ViewFogUniformOffset, @@ -173,7 +173,7 @@ impl ViewNode for DeferredOpaquePass3dPbrLightingNode { deferred_lighting_id_depth_texture, camera_3d, deferred_lighting_pipeline, - ): QueryItem, + ): QueryItem, world: &World, ) -> Result<(), NodeRunError> { let pipeline_cache = world.resource::(); diff --git a/crates/bevy_pbr/src/material.rs b/crates/bevy_pbr/src/material.rs index 9c67625721cc1..d1c521724269c 100644 --- a/crates/bevy_pbr/src/material.rs +++ b/crates/bevy_pbr/src/material.rs @@ -377,8 +377,8 @@ type DrawMaterial = ( pub struct SetMaterialBindGroup(PhantomData); impl RenderCommand

for SetMaterialBindGroup { type Param = (SRes>, SRes>); - type ViewWorldQuery = (); - type ItemWorldQuery = (); + type ViewData = (); + type ItemData = (); #[inline] fn render<'w>( diff --git a/crates/bevy_pbr/src/prepass/mod.rs b/crates/bevy_pbr/src/prepass/mod.rs index f6f018bef11aa..827f458982f7e 100644 --- a/crates/bevy_pbr/src/prepass/mod.rs +++ b/crates/bevy_pbr/src/prepass/mod.rs @@ -874,11 +874,11 @@ pub fn queue_prepass_material_meshes( pub struct SetPrepassViewBindGroup; impl RenderCommand

for SetPrepassViewBindGroup { type Param = SRes; - type ViewWorldQuery = ( + type ViewData = ( Read, Option>, ); - type ItemWorldQuery = (); + type ItemData = (); #[inline] fn render<'w>( diff --git a/crates/bevy_pbr/src/render/mesh.rs b/crates/bevy_pbr/src/render/mesh.rs index de327f7e29286..b9bb6195ad9c9 100644 --- a/crates/bevy_pbr/src/render/mesh.rs +++ b/crates/bevy_pbr/src/render/mesh.rs @@ -448,14 +448,14 @@ impl MeshPipeline { impl GetBatchData for MeshPipeline { type Param = SRes; - type Query = Entity; - type QueryFilter = With; + type Data = Entity; + type Filter = With; type CompareData = (MaterialBindGroupId, AssetId); type BufferData = MeshUniform; fn get_batch_data( mesh_instances: &SystemParamItem, - entity: &QueryItem, + entity: &QueryItem, ) -> (Self::BufferData, Option) { let mesh_instance = mesh_instances .get(entity) @@ -981,20 +981,20 @@ pub fn prepare_mesh_bind_group( pub struct SetMeshViewBindGroup; impl RenderCommand

for SetMeshViewBindGroup { type Param = (); - type ViewWorldQuery = ( + type ViewData = ( Read, Read, Read, Read, ); - type ItemWorldQuery = (); + type ItemData = (); #[inline] fn render<'w>( _item: &P, (view_uniform, view_lights, view_fog, mesh_view_bind_group): ROQueryItem< 'w, - Self::ViewWorldQuery, + Self::ViewData, >, _entity: (), _: SystemParamItem<'w, '_, Self::Param>, @@ -1018,8 +1018,8 @@ impl RenderCommand

for SetMeshBindGroup { SRes, SRes, ); - type ViewWorldQuery = (); - type ItemWorldQuery = (); + type ViewData = (); + type ItemData = (); #[inline] fn render<'w>( @@ -1081,8 +1081,8 @@ impl RenderCommand

for SetMeshBindGroup { pub struct DrawMesh; impl RenderCommand

{ /// Compared to the draw function the required ECS data is fetched automatically /// (by the [`RenderCommandState`]) from the render world. /// Therefore the three types [`Param`](RenderCommand::Param), -/// [`ViewWorldQuery`](RenderCommand::ViewWorldQuery) and -/// [`ItemWorldQuery`](RenderCommand::ItemWorldQuery) are used. +/// [`ViewData`](RenderCommand::ViewData) and +/// [`ItemData`](RenderCommand::ItemData) are used. /// They specify which information is required to execute the render command. /// /// Multiple render commands can be combined together by wrapping them in a tuple. @@ -179,19 +179,19 @@ pub trait RenderCommand { /// The view entity refers to the camera, or shadow-casting light, etc. from which the phase /// item will be rendered from. /// All components have to be accessed read only. - type ViewWorldQuery: ReadOnlyWorldQueryData; + type ViewData: ReadOnlyQueryData; /// Specifies the ECS data of the item entity required by [`RenderCommand::render`]. /// /// The item is the entity that will be rendered for the corresponding view. /// All components have to be accessed read only. - type ItemWorldQuery: ReadOnlyWorldQueryData; + type ItemData: ReadOnlyQueryData; /// Renders a [`PhaseItem`] by recording commands (e.g. setting pipelines, binding bind groups, /// issuing draw calls, etc.) via the [`TrackedRenderPass`]. fn render<'w>( item: &P, - view: ROQueryItem<'w, Self::ViewWorldQuery>, - entity: ROQueryItem<'w, Self::ItemWorldQuery>, + view: ROQueryItem<'w, Self::ViewData>, + entity: ROQueryItem<'w, Self::ItemData>, param: SystemParamItem<'w, '_, Self::Param>, pass: &mut TrackedRenderPass<'w>, ) -> RenderCommandResult; @@ -207,14 +207,14 @@ macro_rules! render_command_tuple_impl { ($(($name: ident, $view: ident, $entity: ident)),*) => { impl),*> RenderCommand

for ($($name,)*) { type Param = ($($name::Param,)*); - type ViewWorldQuery = ($($name::ViewWorldQuery,)*); - type ItemWorldQuery = ($($name::ItemWorldQuery,)*); + type ViewData = ($($name::ViewData,)*); + type ItemData = ($($name::ItemData,)*); #[allow(non_snake_case)] fn render<'w>( _item: &P, - ($($view,)*): ROQueryItem<'w, Self::ViewWorldQuery>, - ($($entity,)*): ROQueryItem<'w, Self::ItemWorldQuery>, + ($($view,)*): ROQueryItem<'w, Self::ViewData>, + ($($entity,)*): ROQueryItem<'w, Self::ItemData>, ($($name,)*): SystemParamItem<'w, '_, Self::Param>, _pass: &mut TrackedRenderPass<'w>, ) -> RenderCommandResult { @@ -231,12 +231,12 @@ all_tuples!(render_command_tuple_impl, 0, 15, C, V, E); /// Wraps a [`RenderCommand`] into a state so that it can be used as a [`Draw`] function. /// -/// The [`RenderCommand::Param`], [`RenderCommand::ViewWorldQuery`] and -/// [`RenderCommand::ItemWorldQuery`] are fetched from the ECS and passed to the command. +/// The [`RenderCommand::Param`], [`RenderCommand::ViewData`] and +/// [`RenderCommand::ItemData`] are fetched from the ECS and passed to the command. pub struct RenderCommandState> { state: SystemState, - view: QueryState, - entity: QueryState, + view: QueryState, + entity: QueryState, } impl> RenderCommandState { diff --git a/crates/bevy_render/src/render_phase/mod.rs b/crates/bevy_render/src/render_phase/mod.rs index e7926848f63ec..5cf9976ec4d93 100644 --- a/crates/bevy_render/src/render_phase/mod.rs +++ b/crates/bevy_render/src/render_phase/mod.rs @@ -196,8 +196,8 @@ pub struct SetItemPipeline; impl RenderCommand

for SetItemPipeline { type Param = SRes; - type ViewWorldQuery = (); - type ItemWorldQuery = (); + type ViewData = (); + type ItemData = (); #[inline] fn render<'w>( item: &P, diff --git a/crates/bevy_sprite/src/mesh2d/material.rs b/crates/bevy_sprite/src/mesh2d/material.rs index f1e23415d06fe..8fcb83bb3f92a 100644 --- a/crates/bevy_sprite/src/mesh2d/material.rs +++ b/crates/bevy_sprite/src/mesh2d/material.rs @@ -330,8 +330,8 @@ impl RenderCommand

SRes>, SRes>, ); - type ViewWorldQuery = (); - type ItemWorldQuery = (); + type ViewData = (); + type ItemData = (); #[inline] fn render<'w>( diff --git a/crates/bevy_sprite/src/mesh2d/mesh.rs b/crates/bevy_sprite/src/mesh2d/mesh.rs index 7f1bb40b81914..03c856068f0fb 100644 --- a/crates/bevy_sprite/src/mesh2d/mesh.rs +++ b/crates/bevy_sprite/src/mesh2d/mesh.rs @@ -339,14 +339,14 @@ impl Mesh2dPipeline { impl GetBatchData for Mesh2dPipeline { type Param = SRes; - type Query = Entity; - type QueryFilter = With; + type Data = Entity; + type Filter = With; type CompareData = (Material2dBindGroupId, AssetId); type BufferData = Mesh2dUniform; fn get_batch_data( mesh_instances: &SystemParamItem, - entity: &QueryItem, + entity: &QueryItem, ) -> (Self::BufferData, Option) { let mesh_instance = mesh_instances .get(entity) @@ -617,13 +617,13 @@ pub fn prepare_mesh2d_view_bind_groups( pub struct SetMesh2dViewBindGroup; impl RenderCommand

for SetMesh2dViewBindGroup { type Param = (); - type ViewWorldQuery = (Read, Read); - type ItemWorldQuery = (); + type ViewData = (Read, Read); + type ItemData = (); #[inline] fn render<'w>( _item: &P, - (view_uniform, mesh2d_view_bind_group): ROQueryItem<'w, Self::ViewWorldQuery>, + (view_uniform, mesh2d_view_bind_group): ROQueryItem<'w, Self::ViewData>, _view: (), _param: SystemParamItem<'w, '_, Self::Param>, pass: &mut TrackedRenderPass<'w>, @@ -637,8 +637,8 @@ impl RenderCommand

for SetMesh2dViewBindGroup; impl RenderCommand

for SetMesh2dBindGroup { type Param = SRes; - type ViewWorldQuery = (); - type ItemWorldQuery = (); + type ViewData = (); + type ItemData = (); #[inline] fn render<'w>( @@ -666,8 +666,8 @@ impl RenderCommand

for SetMesh2dBindGroup { pub struct DrawMesh2d; impl RenderCommand

for DrawMesh2d { type Param = (SRes>, SRes); - type ViewWorldQuery = (); - type ItemWorldQuery = (); + type ViewData = (); + type ItemData = (); #[inline] fn render<'w>( diff --git a/crates/bevy_sprite/src/render/mod.rs b/crates/bevy_sprite/src/render/mod.rs index e2bf321fd746e..fa8b256e2aa1d 100644 --- a/crates/bevy_sprite/src/render/mod.rs +++ b/crates/bevy_sprite/src/render/mod.rs @@ -766,8 +766,8 @@ pub type DrawSprite = ( pub struct SetSpriteViewBindGroup; impl RenderCommand

for SetSpriteViewBindGroup { type Param = SRes; - type ViewWorldQuery = Read; - type ItemWorldQuery = (); + type ViewData = Read; + type ItemData = (); fn render<'w>( _item: &P, @@ -787,8 +787,8 @@ impl RenderCommand

for SetSpriteViewBindGroup; impl RenderCommand

for SetSpriteTextureBindGroup { type Param = SRes; - type ViewWorldQuery = (); - type ItemWorldQuery = Read; + type ViewData = (); + type ItemData = Read; fn render<'w>( _item: &P, @@ -814,8 +814,8 @@ impl RenderCommand

for SetSpriteTextureBindGrou pub struct DrawSpriteBatch; impl RenderCommand

for DrawSpriteBatch { type Param = SRes; - type ViewWorldQuery = (); - type ItemWorldQuery = Read; + type ViewData = (); + type ItemData = Read; fn render<'w>( _item: &P, diff --git a/crates/bevy_ui/src/focus.rs b/crates/bevy_ui/src/focus.rs index 7302fdfc3e943..1ba662dc29e38 100644 --- a/crates/bevy_ui/src/focus.rs +++ b/crates/bevy_ui/src/focus.rs @@ -3,7 +3,7 @@ use bevy_ecs::{ change_detection::DetectChangesMut, entity::Entity, prelude::{Component, With}, - query::WorldQueryData, + query::QueryData, reflect::ReflectComponent, system::{Local, Query, Res}, }; @@ -105,8 +105,8 @@ pub struct State { } /// Main query for [`ui_focus_system`] -#[derive(WorldQueryData)] -#[world_query_data(mutable)] +#[derive(QueryData)] +#[query_data(mutable)] pub struct NodeQuery { entity: Entity, node: &'static Node, diff --git a/crates/bevy_ui/src/render/render_pass.rs b/crates/bevy_ui/src/render/render_pass.rs index bde2898534cac..c7c5c5644b81d 100644 --- a/crates/bevy_ui/src/render/render_pass.rs +++ b/crates/bevy_ui/src/render/render_pass.rs @@ -157,8 +157,8 @@ pub type DrawUi = ( pub struct SetUiViewBindGroup; impl RenderCommand

for SetUiViewBindGroup { type Param = SRes; - type ViewWorldQuery = Read; - type ItemWorldQuery = (); + type ViewData = Read; + type ItemData = (); fn render<'w>( _item: &P, @@ -178,8 +178,8 @@ impl RenderCommand

for SetUiViewBindGroup { pub struct SetUiTextureBindGroup; impl RenderCommand

for SetUiTextureBindGroup { type Param = SRes; - type ViewWorldQuery = (); - type ItemWorldQuery = Read; + type ViewData = (); + type ItemData = Read; #[inline] fn render<'w>( @@ -197,8 +197,8 @@ impl RenderCommand

for SetUiTextureBindGroup pub struct DrawUiNode; impl RenderCommand

for DrawUiNode { type Param = SRes; - type ViewWorldQuery = (); - type ItemWorldQuery = Read; + type ViewData = (); + type ItemData = Read; #[inline] fn render<'w>( diff --git a/crates/bevy_ui/src/render/ui_material_pipeline.rs b/crates/bevy_ui/src/render/ui_material_pipeline.rs index b383c26f86f22..90cd3ef7fde96 100644 --- a/crates/bevy_ui/src/render/ui_material_pipeline.rs +++ b/crates/bevy_ui/src/render/ui_material_pipeline.rs @@ -263,8 +263,8 @@ pub type DrawUiMaterial = ( pub struct SetMatUiViewBindGroup(PhantomData); impl RenderCommand

for SetMatUiViewBindGroup { type Param = SRes>; - type ViewWorldQuery = Read; - type ItemWorldQuery = (); + type ViewData = Read; + type ItemData = (); fn render<'w>( _item: &P, @@ -287,13 +287,13 @@ impl RenderCommand

for SetUiMaterialBindGroup { type Param = SRes>; - type ViewWorldQuery = (); - type ItemWorldQuery = Read>; + type ViewData = (); + type ItemData = Read>; fn render<'w>( _item: &P, _view: (), - material_handle: ROQueryItem<'_, Self::ItemWorldQuery>, + material_handle: ROQueryItem<'_, Self::ItemData>, materials: SystemParamItem<'w, '_, Self::Param>, pass: &mut TrackedRenderPass<'w>, ) -> RenderCommandResult { @@ -308,8 +308,8 @@ impl RenderCommand

pub struct DrawUiMaterialNode(PhantomData); impl RenderCommand

for DrawUiMaterialNode { type Param = SRes>; - type ViewWorldQuery = (); - type ItemWorldQuery = Read>; + type ViewData = (); + type ItemData = Read>; #[inline] fn render<'w>( diff --git a/examples/ecs/custom_query_param.rs b/examples/ecs/custom_query_param.rs index b53db4c399191..4df666bf337e5 100644 --- a/examples/ecs/custom_query_param.rs +++ b/examples/ecs/custom_query_param.rs @@ -13,7 +13,7 @@ //! For more details on the `WorldQuery` derive macro, see the trait documentation. use bevy::{ - ecs::query::{WorldQueryData, WorldQueryFilter}, + ecs::query::{QueryData, QueryFilter}, prelude::*, }; use std::fmt::Debug; @@ -45,8 +45,8 @@ struct ComponentD; #[derive(Component, Debug)] struct ComponentZ; -#[derive(WorldQueryData)] -#[world_query_data(derive(Debug))] +#[derive(QueryData)] +#[query_data(derive(Debug))] struct ReadOnlyCustomQuery { entity: Entity, a: &'static ComponentA, @@ -59,7 +59,10 @@ struct ReadOnlyCustomQuery { } fn print_components_read_only( - query: Query, QueryFilter>, + query: Query< + ReadOnlyCustomQuery, + CustomQueryFilter, + >, ) { println!("Print components (read_only):"); for e in &query { @@ -79,8 +82,8 @@ fn print_components_read_only( // suffix. // Note: if you want to use derive macros with read-only query variants, you need to pass them with // using the `derive` attribute. -#[derive(WorldQueryData)] -#[world_query_data(mutable, derive(Debug))] +#[derive(QueryData)] +#[query_data(mutable, derive(Debug))] struct CustomQuery { entity: Entity, a: &'static mut ComponentA, @@ -93,27 +96,27 @@ struct CustomQuery { } // This is a valid query as well, which would iterate over every entity. -#[derive(WorldQueryData)] -#[world_query_data(derive(Debug))] +#[derive(QueryData)] +#[query_data(derive(Debug))] struct EmptyQuery { empty: (), } -#[derive(WorldQueryData)] -#[world_query_data(derive(Debug))] +#[derive(QueryData)] +#[query_data(derive(Debug))] struct NestedQuery { c: &'static ComponentC, d: Option<&'static ComponentD>, } -#[derive(WorldQueryData)] -#[world_query_data(derive(Debug))] +#[derive(QueryData)] +#[query_data(derive(Debug))] struct GenericQuery { generic: (&'static T, &'static P), } -#[derive(WorldQueryFilter)] -struct QueryFilter { +#[derive(QueryFilter)] +struct CustomQueryFilter { _c: With, _d: With, _or: Or<(Added, Changed, Without)>, @@ -125,7 +128,10 @@ fn spawn(mut commands: Commands) { } fn print_components_iter_mut( - mut query: Query, QueryFilter>, + mut query: Query< + CustomQuery, + CustomQueryFilter, + >, ) { println!("Print components (iter_mut):"); for e in &mut query { @@ -143,7 +149,7 @@ fn print_components_iter_mut( } fn print_components_iter( - query: Query, QueryFilter>, + query: Query, CustomQueryFilter>, ) { println!("Print components (iter):"); for e in &query { diff --git a/examples/shader/post_processing.rs b/examples/shader/post_processing.rs index f295abb5f958d..4db91db102b95 100644 --- a/examples/shader/post_processing.rs +++ b/examples/shader/post_processing.rs @@ -116,7 +116,7 @@ impl ViewNode for PostProcessNode { // but it's not a normal system so we need to define it manually. // // This query will only run on the view entity - type ViewQuery = ( + type ViewData = ( &'static ViewTarget, // This makes sure the node only runs on cameras with the PostProcessSettings component &'static PostProcessSettings, @@ -133,7 +133,7 @@ impl ViewNode for PostProcessNode { &self, _graph: &mut RenderGraphContext, render_context: &mut RenderContext, - (view_target, _post_process_settings): QueryItem, + (view_target, _post_process_settings): QueryItem, world: &World, ) -> Result<(), NodeRunError> { // Get the pipeline resource that contains the global data we need diff --git a/examples/shader/shader_instancing.rs b/examples/shader/shader_instancing.rs index 8186b0d74d357..a0b4c7db79c82 100644 --- a/examples/shader/shader_instancing.rs +++ b/examples/shader/shader_instancing.rs @@ -68,11 +68,11 @@ fn setup(mut commands: Commands, mut meshes: ResMut>) { struct InstanceMaterialData(Vec); impl ExtractComponent for InstanceMaterialData { - type Query = &'static InstanceMaterialData; + type Data = &'static InstanceMaterialData; type Filter = (); type Out = Self; - fn extract_component(item: QueryItem<'_, Self::Query>) -> Option { + fn extract_component(item: QueryItem<'_, Self::Data>) -> Option { Some(InstanceMaterialData(item.0.clone())) } } @@ -237,8 +237,8 @@ pub struct DrawMeshInstanced; impl RenderCommand

for DrawMeshInstanced { type Param = (SRes>, SRes); - type ViewWorldQuery = (); - type ItemWorldQuery = Read; + type ViewData = (); + type ItemData = Read; #[inline] fn render<'w>(

for DrawMesh { type Param = (SRes>, SRes); - type ViewWorldQuery = (); - type ItemWorldQuery = (); + type ViewData = (); + type ItemData = (); #[inline] fn render<'w>( item: &P, diff --git a/crates/bevy_pbr/src/ssao/mod.rs b/crates/bevy_pbr/src/ssao/mod.rs index 14f1a05355385..2e97f4d821320 100644 --- a/crates/bevy_pbr/src/ssao/mod.rs +++ b/crates/bevy_pbr/src/ssao/mod.rs @@ -199,7 +199,7 @@ impl ScreenSpaceAmbientOcclusionQualityLevel { struct SsaoNode {} impl ViewNode for SsaoNode { - type ViewQuery = ( + type ViewData = ( &'static ExtractedCamera, &'static SsaoPipelineId, &'static SsaoBindGroups, @@ -210,7 +210,7 @@ impl ViewNode for SsaoNode { &self, _graph: &mut RenderGraphContext, render_context: &mut RenderContext, - (camera, pipeline_id, bind_groups, view_uniform_offset): QueryItem, + (camera, pipeline_id, bind_groups, view_uniform_offset): QueryItem, world: &World, ) -> Result<(), NodeRunError> { let pipelines = world.resource::(); diff --git a/crates/bevy_render/macros/src/extract_component.rs b/crates/bevy_render/macros/src/extract_component.rs index 8fd10ce2b4c10..8e0f5f55860f4 100644 --- a/crates/bevy_render/macros/src/extract_component.rs +++ b/crates/bevy_render/macros/src/extract_component.rs @@ -38,12 +38,12 @@ pub fn derive_extract_component(input: TokenStream) -> TokenStream { TokenStream::from(quote! { impl #impl_generics #bevy_render_path::extract_component::ExtractComponent for #struct_name #type_generics #where_clause { - type Query = &'static Self; + type Data = &'static Self; type Filter = #filter; type Out = Self; - fn extract_component(item: #bevy_ecs_path::query::QueryItem<'_, Self::Query>) -> Option { + fn extract_component(item: #bevy_ecs_path::query::QueryItem<'_, Self::Data>) -> Option { Some(item.clone()) } } diff --git a/crates/bevy_render/src/batching/mod.rs b/crates/bevy_render/src/batching/mod.rs index 8d0fb9a601feb..5f7d5f69d2d27 100644 --- a/crates/bevy_render/src/batching/mod.rs +++ b/crates/bevy_render/src/batching/mod.rs @@ -1,7 +1,7 @@ use bevy_ecs::{ component::Component, prelude::Res, - query::{QueryItem, ReadOnlyWorldQueryData, WorldQueryFilter}, + query::{QueryFilter, QueryItem, ReadOnlyQueryData}, system::{Query, ResMut, StaticSystemParam, SystemParam, SystemParamItem}, }; use bevy_utils::nonmax::NonMaxU32; @@ -57,8 +57,8 @@ impl BatchMeta { /// items. pub trait GetBatchData { type Param: SystemParam + 'static; - type Query: ReadOnlyWorldQueryData; - type QueryFilter: WorldQueryFilter; + type Data: ReadOnlyQueryData; + type Filter: QueryFilter; /// Data used for comparison between phase items. If the pipeline id, draw /// function id, per-instance data buffer dynamic offset and this data /// matches, the draws can be batched. @@ -72,7 +72,7 @@ pub trait GetBatchData { /// for the `CompareData`. fn get_batch_data( param: &SystemParamItem, - query_item: &QueryItem, + query_item: &QueryItem, ) -> (Self::BufferData, Option); } @@ -81,7 +81,7 @@ pub trait GetBatchData { pub fn batch_and_prepare_render_phase( gpu_array_buffer: ResMut>, mut views: Query<&mut RenderPhase>, - query: Query, + query: Query, param: StaticSystemParam, ) { let gpu_array_buffer = gpu_array_buffer.into_inner(); diff --git a/crates/bevy_render/src/extract_component.rs b/crates/bevy_render/src/extract_component.rs index ee5c8c45aec8f..63ef625a170e3 100644 --- a/crates/bevy_render/src/extract_component.rs +++ b/crates/bevy_render/src/extract_component.rs @@ -9,7 +9,7 @@ use bevy_asset::{Asset, Handle}; use bevy_ecs::{ component::Component, prelude::*, - query::{QueryItem, ReadOnlyWorldQueryData, WorldQueryFilter}, + query::{QueryFilter, QueryItem, ReadOnlyQueryData}, system::lifetimeless::Read, }; use std::{marker::PhantomData, ops::Deref}; @@ -35,10 +35,10 @@ impl DynamicUniformIndex { /// Therefore the component is transferred from the "app world" into the "render world" /// in the [`ExtractSchedule`] step. pub trait ExtractComponent: Component { - /// ECS [`ReadOnlyWorldQueryData`] to fetch the components to extract. - type Query: ReadOnlyWorldQueryData; + /// ECS [`ReadOnlyQueryData`] to fetch the components to extract. + type Data: ReadOnlyQueryData; /// Filters the entities with additional constraints. - type Filter: WorldQueryFilter; + type Filter: QueryFilter; /// The output from extraction. /// @@ -58,7 +58,7 @@ pub trait ExtractComponent: Component { // type Out: Component = Self; /// Defines how the component is transferred into the "render world". - fn extract_component(item: QueryItem<'_, Self::Query>) -> Option; + fn extract_component(item: QueryItem<'_, Self::Data>) -> Option; } /// This plugin prepares the components of the corresponding type for the GPU @@ -195,12 +195,12 @@ impl Plugin for ExtractComponentPlugin { } impl ExtractComponent for Handle { - type Query = Read>; + type Data = Read>; type Filter = (); type Out = Handle; #[inline] - fn extract_component(handle: QueryItem<'_, Self::Query>) -> Option { + fn extract_component(handle: QueryItem<'_, Self::Data>) -> Option { Some(handle.clone_weak()) } } @@ -209,7 +209,7 @@ impl ExtractComponent for Handle { fn extract_components( mut commands: Commands, mut previous_len: Local, - query: Extract>, + query: Extract>, ) { let mut values = Vec::with_capacity(*previous_len); for (entity, query_item) in &query { @@ -225,7 +225,7 @@ fn extract_components( fn extract_visible_components( mut commands: Commands, mut previous_len: Local, - query: Extract>, + query: Extract>, ) { let mut values = Vec::with_capacity(*previous_len); for (entity, view_visibility, query_item) in &query { diff --git a/crates/bevy_render/src/extract_instances.rs b/crates/bevy_render/src/extract_instances.rs index 8fc925b8e9ab3..0b088e4607d7e 100644 --- a/crates/bevy_render/src/extract_instances.rs +++ b/crates/bevy_render/src/extract_instances.rs @@ -11,7 +11,7 @@ use bevy_asset::{Asset, AssetId, Handle}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ prelude::Entity, - query::{QueryItem, ReadOnlyWorldQueryData, WorldQueryFilter}, + query::{QueryFilter, QueryItem, ReadOnlyQueryData}, system::{lifetimeless::Read, Query, ResMut, Resource}, }; use bevy_utils::EntityHashMap; @@ -28,13 +28,13 @@ use crate::{prelude::ViewVisibility, Extract, ExtractSchedule, RenderApp}; /// [`ExtractComponent`](crate::extract_component::ExtractComponent), but /// higher-performance because it avoids the ECS overhead. pub trait ExtractInstance: Send + Sync + Sized + 'static { - /// ECS [`ReadOnlyWorldQueryData`] to fetch the components to extract. - type Query: ReadOnlyWorldQueryData; + /// ECS [`ReadOnlyQueryData`] to fetch the components to extract. + type Data: ReadOnlyQueryData; /// Filters the entities with additional constraints. - type Filter: WorldQueryFilter; + type Filter: QueryFilter; /// Defines how the component is transferred into the "render world". - fn extract(item: QueryItem<'_, Self::Query>) -> Option; + fn extract(item: QueryItem<'_, Self::Data>) -> Option; } /// This plugin extracts one or more components into the "render world" as @@ -107,7 +107,7 @@ where fn extract_all( mut extracted_instances: ResMut>, - query: Extract>, + query: Extract>, ) where EI: ExtractInstance, { @@ -121,7 +121,7 @@ fn extract_all( fn extract_visible( mut extracted_instances: ResMut>, - query: Extract>, + query: Extract>, ) where EI: ExtractInstance, { @@ -139,10 +139,10 @@ impl ExtractInstance for AssetId where A: Asset, { - type Query = Read>; + type Data = Read>; type Filter = (); - fn extract(item: QueryItem<'_, Self::Query>) -> Option { + fn extract(item: QueryItem<'_, Self::Data>) -> Option { Some(item.id()) } } diff --git a/crates/bevy_render/src/render_graph/node.rs b/crates/bevy_render/src/render_graph/node.rs index aa4a786089fdd..4d83dad643675 100644 --- a/crates/bevy_render/src/render_graph/node.rs +++ b/crates/bevy_render/src/render_graph/node.rs @@ -7,7 +7,7 @@ use crate::{ renderer::RenderContext, }; use bevy_ecs::{ - query::{QueryItem, QueryState, ReadOnlyWorldQueryData}, + query::{QueryItem, QueryState, ReadOnlyQueryData}, world::{FromWorld, World}, }; use downcast_rs::{impl_downcast, Downcast}; @@ -342,7 +342,7 @@ impl Node for RunGraphOnViewNode { pub trait ViewNode { /// The query that will be used on the view entity. /// It is guaranteed to run on the view entity, so there's no need for a filter - type ViewQuery: ReadOnlyWorldQueryData; + type ViewData: ReadOnlyQueryData; /// Updates internal node state using the current render [`World`] prior to the run method. fn update(&mut self, _world: &mut World) {} @@ -354,7 +354,7 @@ pub trait ViewNode { &self, graph: &mut RenderGraphContext, render_context: &mut RenderContext, - view_query: QueryItem, + view_query: QueryItem, world: &World, ) -> Result<(), NodeRunError>; } @@ -364,7 +364,7 @@ pub trait ViewNode { /// /// This [`Node`] exists to help reduce boilerplate when making a render node that runs on a view. pub struct ViewNodeRunner { - view_query: QueryState, + view_query: QueryState, node: N, } diff --git a/crates/bevy_render/src/render_phase/draw.rs b/crates/bevy_render/src/render_phase/draw.rs index 3ebf9b15507da..d1eee845bf99f 100644 --- a/crates/bevy_render/src/render_phase/draw.rs +++ b/crates/bevy_render/src/render_phase/draw.rs @@ -2,7 +2,7 @@ use crate::render_phase::{PhaseItem, TrackedRenderPass}; use bevy_app::App; use bevy_ecs::{ entity::Entity, - query::{QueryState, ROQueryItem, ReadOnlyWorldQueryData}, + query::{QueryState, ROQueryItem, ReadOnlyQueryData}, system::{ReadOnlySystemParam, Resource, SystemParam, SystemParamItem, SystemState}, world::World, }; @@ -142,8 +142,8 @@ impl DrawFunctions