Skip to content

Commit 5af2f02

Browse files
authored
Rename WorldQueryData & WorldQueryFilter to QueryData & QueryFilter (#10779)
# Rename `WorldQueryData` & `WorldQueryFilter` to `QueryData` & `QueryFilter` Fixes #10776 ## Solution Traits `WorldQueryData` & `WorldQueryFilter` were renamed to `QueryData` and `QueryFilter`, respectively. Related Trait types were also renamed. --- ## Changelog - Trait `WorldQueryData` has been renamed to `QueryData`. Derive macro's `QueryData` attribute `world_query_data` has been renamed to `query_data`. - Trait `WorldQueryFilter` has been renamed to `QueryFilter`. Derive macro's `QueryFilter` attribute `world_query_filter` has been renamed to `query_filter`. - Trait's `ExtractComponent` type `Query` has been renamed to `Data`. - Trait's `GetBatchData` types `Query` & `QueryFilter` has been renamed to `Data` & `Filter`, respectively. - Trait's `ExtractInstance` type `Query` has been renamed to `Data`. - Trait's `ViewNode` type `ViewQuery` has been renamed to `ViewData`. - Trait's `RenderCommand` types `ViewWorldQuery` & `ItemWorldQuery` has been renamed to `ViewData` & `ItemData`, respectively. ## Migration Guide Note: if merged before 0.13 is released, this should instead modify the migration guide of #10776 with the updated names. - Rename `WorldQueryData` & `WorldQueryFilter` trait usages to `QueryData` & `QueryFilter` and their respective derive macro attributes `world_query_data` & `world_query_filter` to `query_data` & `query_filter`. - Rename the following trait type usages: - Trait's `ExtractComponent` type `Query` to `Data`. - Trait's `GetBatchData` type `Query` to `Data`. - Trait's `ExtractInstance` type `Query` to `Data`. - Trait's `ViewNode` type `ViewQuery` to `ViewData`' - Trait's `RenderCommand` types `ViewWolrdQuery` & `ItemWorldQuery` to `ViewData` & `ItemData`, respectively. ```rust // Before #[derive(WorldQueryData)] #[world_query_data(derive(Debug))] struct EmptyQuery { empty: (), } // After #[derive(QueryData)] #[query_data(derive(Debug))] struct EmptyQuery { empty: (), } // Before #[derive(WorldQueryFilter)] struct CustomQueryFilter<T: Component, P: Component> { _c: With<ComponentC>, _d: With<ComponentD>, _or: Or<(Added<ComponentC>, Changed<ComponentD>, Without<ComponentZ>)>, _generic_tuple: (With<T>, With<P>), } // After #[derive(QueryFilter)] struct CustomQueryFilter<T: Component, P: Component> { _c: With<ComponentC>, _d: With<ComponentD>, _or: Or<(Added<ComponentC>, Changed<ComponentD>, Without<ComponentZ>)>, _generic_tuple: (With<T>, With<P>), } // Before impl ExtractComponent for ContrastAdaptiveSharpeningSettings { type Query = &'static Self; type Filter = With<Camera>; type Out = (DenoiseCAS, CASUniform); fn extract_component(item: QueryItem<Self::Query>) -> Option<Self::Out> { //... } } // After impl ExtractComponent for ContrastAdaptiveSharpeningSettings { type Data = &'static Self; type Filter = With<Camera>; type Out = (DenoiseCAS, CASUniform); fn extract_component(item: QueryItem<Self::Data>) -> Option<Self::Out> { //... } } // Before impl GetBatchData for MeshPipeline { type Param = SRes<RenderMeshInstances>; type Query = Entity; type QueryFilter = With<Mesh3d>; type CompareData = (MaterialBindGroupId, AssetId<Mesh>); type BufferData = MeshUniform; fn get_batch_data( mesh_instances: &SystemParamItem<Self::Param>, entity: &QueryItem<Self::Query>, ) -> (Self::BufferData, Option<Self::CompareData>) { // .... } } // After impl GetBatchData for MeshPipeline { type Param = SRes<RenderMeshInstances>; type Data = Entity; type Filter = With<Mesh3d>; type CompareData = (MaterialBindGroupId, AssetId<Mesh>); type BufferData = MeshUniform; fn get_batch_data( mesh_instances: &SystemParamItem<Self::Param>, entity: &QueryItem<Self::Data>, ) -> (Self::BufferData, Option<Self::CompareData>) { // .... } } // Before impl<A> ExtractInstance for AssetId<A> where A: Asset, { type Query = Read<Handle<A>>; type Filter = (); fn extract(item: QueryItem<'_, Self::Query>) -> Option<Self> { Some(item.id()) } } // After impl<A> ExtractInstance for AssetId<A> where A: Asset, { type Data = Read<Handle<A>>; type Filter = (); fn extract(item: QueryItem<'_, Self::Data>) -> Option<Self> { Some(item.id()) } } // Before impl ViewNode for PostProcessNode { type ViewQuery = ( &'static ViewTarget, &'static PostProcessSettings, ); fn run( &self, _graph: &mut RenderGraphContext, render_context: &mut RenderContext, (view_target, _post_process_settings): QueryItem<Self::ViewQuery>, world: &World, ) -> Result<(), NodeRunError> { // ... } } // After impl ViewNode for PostProcessNode { type ViewData = ( &'static ViewTarget, &'static PostProcessSettings, ); fn run( &self, _graph: &mut RenderGraphContext, render_context: &mut RenderContext, (view_target, _post_process_settings): QueryItem<Self::ViewData>, world: &World, ) -> Result<(), NodeRunError> { // ... } } // Before impl<P: CachedRenderPipelinePhaseItem> RenderCommand<P> for SetItemPipeline { type Param = SRes<PipelineCache>; type ViewWorldQuery = (); type ItemWorldQuery = (); #[inline] fn render<'w>( item: &P, _view: (), _entity: (), pipeline_cache: SystemParamItem<'w, '_, Self::Param>, pass: &mut TrackedRenderPass<'w>, ) -> RenderCommandResult { // ... } } // After impl<P: CachedRenderPipelinePhaseItem> RenderCommand<P> for SetItemPipeline { type Param = SRes<PipelineCache>; type ViewData = (); type ItemData = (); #[inline] fn render<'w>( item: &P, _view: (), _entity: (), pipeline_cache: SystemParamItem<'w, '_, Self::Param>, pass: &mut TrackedRenderPass<'w>, ) -> RenderCommandResult { // ... } } ```
1 parent 79641c7 commit 5af2f02

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+413
-416
lines changed

crates/bevy_core/src/name.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use bevy_ecs::query::WorldQueryData;
1+
use bevy_ecs::query::QueryData;
22
use bevy_ecs::{component::Component, entity::Entity, reflect::ReflectComponent};
33

44
use bevy_reflect::std_traits::ReflectDefault;
@@ -102,7 +102,7 @@ impl std::fmt::Debug for Name {
102102
/// }
103103
/// # bevy_ecs::system::assert_is_system(increment_score);
104104
/// ```
105-
#[derive(WorldQueryData)]
105+
#[derive(QueryData)]
106106
pub struct DebugName {
107107
/// A [`Name`] that the entity might have that is displayed if available.
108108
pub name: Option<&'static Name>,

crates/bevy_core_pipeline/src/bloom/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl Plugin for BloomPlugin {
113113
#[derive(Default)]
114114
struct BloomNode;
115115
impl ViewNode for BloomNode {
116-
type ViewQuery = (
116+
type ViewData = (
117117
&'static ExtractedCamera,
118118
&'static ViewTarget,
119119
&'static BloomTexture,
@@ -140,7 +140,7 @@ impl ViewNode for BloomNode {
140140
bloom_settings,
141141
upsampling_pipeline_ids,
142142
downsampling_pipeline_ids,
143-
): QueryItem<Self::ViewQuery>,
143+
): QueryItem<Self::ViewData>,
144144
world: &World,
145145
) -> Result<(), NodeRunError> {
146146
let downsampling_pipeline_res = world.resource::<BloomDownsamplingPipeline>();

crates/bevy_core_pipeline/src/bloom/settings.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,12 @@ pub enum BloomCompositeMode {
182182
}
183183

184184
impl ExtractComponent for BloomSettings {
185-
type Query = (&'static Self, &'static Camera);
185+
type Data = (&'static Self, &'static Camera);
186186

187187
type Filter = ();
188188
type Out = (Self, BloomUniforms);
189189

190-
fn extract_component((settings, camera): QueryItem<'_, Self::Query>) -> Option<Self::Out> {
190+
fn extract_component((settings, camera): QueryItem<'_, Self::Data>) -> Option<Self::Out> {
191191
match (
192192
camera.physical_viewport_rect(),
193193
camera.physical_viewport_size(),

crates/bevy_core_pipeline/src/contrast_adaptive_sharpening/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ pub struct CASUniform {
7777
}
7878

7979
impl ExtractComponent for ContrastAdaptiveSharpeningSettings {
80-
type Query = &'static Self;
80+
type Data = &'static Self;
8181
type Filter = With<Camera>;
8282
type Out = (DenoiseCAS, CASUniform);
8383

84-
fn extract_component(item: QueryItem<Self::Query>) -> Option<Self::Out> {
84+
fn extract_component(item: QueryItem<Self::Data>) -> Option<Self::Out> {
8585
if !item.enabled || item.sharpening_strength == 0.0 {
8686
return None;
8787
}

crates/bevy_core_pipeline/src/core_3d/main_opaque_pass_3d_node.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use super::{AlphaMask3d, Camera3dDepthLoadOp};
2424
#[derive(Default)]
2525
pub struct MainOpaquePass3dNode;
2626
impl ViewNode for MainOpaquePass3dNode {
27-
type ViewQuery = (
27+
type ViewData = (
2828
&'static ExtractedCamera,
2929
&'static RenderPhase<Opaque3d>,
3030
&'static RenderPhase<AlphaMask3d>,
@@ -58,7 +58,7 @@ impl ViewNode for MainOpaquePass3dNode {
5858
skybox_pipeline,
5959
skybox_bind_group,
6060
view_uniform_offset,
61-
): QueryItem<Self::ViewQuery>,
61+
): QueryItem<Self::ViewData>,
6262
world: &World,
6363
) -> Result<(), NodeRunError> {
6464
let load = if deferred_prepass.is_none() {

crates/bevy_core_pipeline/src/core_3d/main_transmissive_pass_3d_node.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use std::ops::Range;
2020
pub struct MainTransmissivePass3dNode;
2121

2222
impl ViewNode for MainTransmissivePass3dNode {
23-
type ViewQuery = (
23+
type ViewData = (
2424
&'static ExtractedCamera,
2525
&'static Camera3d,
2626
&'static RenderPhase<Transmissive3d>,
@@ -34,7 +34,7 @@ impl ViewNode for MainTransmissivePass3dNode {
3434
graph: &mut RenderGraphContext,
3535
render_context: &mut RenderContext,
3636
(camera, camera_3d, transmissive_phase, target, transmission, depth): QueryItem<
37-
Self::ViewQuery,
37+
Self::ViewData,
3838
>,
3939
world: &World,
4040
) -> Result<(), NodeRunError> {

crates/bevy_core_pipeline/src/core_3d/main_transparent_pass_3d_node.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use bevy_utils::tracing::info_span;
1616
pub struct MainTransparentPass3dNode;
1717

1818
impl ViewNode for MainTransparentPass3dNode {
19-
type ViewQuery = (
19+
type ViewData = (
2020
&'static ExtractedCamera,
2121
&'static RenderPhase<Transparent3d>,
2222
&'static ViewTarget,
@@ -26,7 +26,7 @@ impl ViewNode for MainTransparentPass3dNode {
2626
&self,
2727
graph: &mut RenderGraphContext,
2828
render_context: &mut RenderContext,
29-
(camera, transparent_phase, target, depth): QueryItem<Self::ViewQuery>,
29+
(camera, transparent_phase, target, depth): QueryItem<Self::ViewData>,
3030
world: &World,
3131
) -> Result<(), NodeRunError> {
3232
let view_entity = graph.view_entity();

crates/bevy_core_pipeline/src/deferred/copy_lighting_id.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl CopyDeferredLightingIdNode {
6161
}
6262

6363
impl ViewNode for CopyDeferredLightingIdNode {
64-
type ViewQuery = (
64+
type ViewData = (
6565
&'static ViewTarget,
6666
&'static ViewPrepassTextures,
6767
&'static DeferredLightingIdDepthTexture,
@@ -72,7 +72,7 @@ impl ViewNode for CopyDeferredLightingIdNode {
7272
_graph: &mut RenderGraphContext,
7373
render_context: &mut RenderContext,
7474
(_view_target, view_prepass_textures, deferred_lighting_id_depth_texture): QueryItem<
75-
Self::ViewQuery,
75+
Self::ViewData,
7676
>,
7777
world: &World,
7878
) -> Result<(), NodeRunError> {

crates/bevy_core_pipeline/src/deferred/node.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use super::{AlphaMask3dDeferred, Opaque3dDeferred};
2929
pub struct DeferredGBufferPrepassNode;
3030

3131
impl ViewNode for DeferredGBufferPrepassNode {
32-
type ViewQuery = (
32+
type ViewData = (
3333
&'static ExtractedCamera,
3434
&'static RenderPhase<Opaque3dDeferred>,
3535
&'static RenderPhase<AlphaMask3dDeferred>,
@@ -55,7 +55,7 @@ impl ViewNode for DeferredGBufferPrepassNode {
5555
depth_prepass,
5656
normal_prepass,
5757
motion_vector_prepass,
58-
): QueryItem<Self::ViewQuery>,
58+
): QueryItem<Self::ViewData>,
5959
world: &World,
6060
) -> Result<(), NodeRunError> {
6161
let view_entity = graph.view_entity();

crates/bevy_core_pipeline/src/fxaa/node.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub struct FxaaNode {
2020
}
2121

2222
impl ViewNode for FxaaNode {
23-
type ViewQuery = (
23+
type ViewData = (
2424
&'static ViewTarget,
2525
&'static CameraFxaaPipeline,
2626
&'static Fxaa,
@@ -30,7 +30,7 @@ impl ViewNode for FxaaNode {
3030
&self,
3131
_graph: &mut RenderGraphContext,
3232
render_context: &mut RenderContext,
33-
(target, pipeline, fxaa): QueryItem<Self::ViewQuery>,
33+
(target, pipeline, fxaa): QueryItem<Self::ViewData>,
3434
world: &World,
3535
) -> Result<(), NodeRunError> {
3636
let pipeline_cache = world.resource::<PipelineCache>();

crates/bevy_core_pipeline/src/prepass/node.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use super::{AlphaMask3dPrepass, DeferredPrepass, Opaque3dPrepass, ViewPrepassTex
2525
pub struct PrepassNode;
2626

2727
impl ViewNode for PrepassNode {
28-
type ViewQuery = (
28+
type ViewData = (
2929
&'static ExtractedCamera,
3030
&'static RenderPhase<Opaque3dPrepass>,
3131
&'static RenderPhase<AlphaMask3dPrepass>,
@@ -45,7 +45,7 @@ impl ViewNode for PrepassNode {
4545
view_depth_texture,
4646
view_prepass_textures,
4747
deferred_prepass,
48-
): QueryItem<Self::ViewQuery>,
48+
): QueryItem<Self::ViewData>,
4949
world: &World,
5050
) -> Result<(), NodeRunError> {
5151
let view_entity = graph.view_entity();

crates/bevy_core_pipeline/src/taa/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl Default for TemporalAntiAliasSettings {
168168
pub struct TemporalAntiAliasNode;
169169

170170
impl ViewNode for TemporalAntiAliasNode {
171-
type ViewQuery = (
171+
type ViewData = (
172172
&'static ExtractedCamera,
173173
&'static ViewTarget,
174174
&'static TemporalAntiAliasHistoryTextures,
@@ -181,7 +181,7 @@ impl ViewNode for TemporalAntiAliasNode {
181181
_graph: &mut RenderGraphContext,
182182
render_context: &mut RenderContext,
183183
(camera, view_target, taa_history_textures, prepass_textures, taa_pipeline_id): QueryItem<
184-
Self::ViewQuery,
184+
Self::ViewData,
185185
>,
186186
world: &World,
187187
) -> Result<(), NodeRunError> {

crates/bevy_core_pipeline/src/tonemapping/node.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub struct TonemappingNode {
2424
}
2525

2626
impl ViewNode for TonemappingNode {
27-
type ViewQuery = (
27+
type ViewData = (
2828
&'static ViewUniformOffset,
2929
&'static ViewTarget,
3030
&'static ViewTonemappingPipeline,
@@ -36,7 +36,7 @@ impl ViewNode for TonemappingNode {
3636
_graph: &mut RenderGraphContext,
3737
render_context: &mut RenderContext,
3838
(view_uniform_offset, target, view_tonemapping_pipeline, tonemapping): QueryItem<
39-
Self::ViewQuery,
39+
Self::ViewData,
4040
>,
4141
world: &World,
4242
) -> Result<(), NodeRunError> {

crates/bevy_core_pipeline/src/upscaling/node.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub struct UpscalingNode {
1818
}
1919

2020
impl ViewNode for UpscalingNode {
21-
type ViewQuery = (
21+
type ViewData = (
2222
&'static ViewTarget,
2323
&'static ViewUpscalingPipeline,
2424
Option<&'static ExtractedCamera>,
@@ -28,7 +28,7 @@ impl ViewNode for UpscalingNode {
2828
&self,
2929
_graph: &mut RenderGraphContext,
3030
render_context: &mut RenderContext,
31-
(target, upscaling_target, camera): QueryItem<Self::ViewQuery>,
31+
(target, upscaling_target, camera): QueryItem<Self::ViewData>,
3232
world: &World,
3333
) -> Result<(), NodeRunError> {
3434
let pipeline_cache = world.get_resource::<PipelineCache>().unwrap();

crates/bevy_ecs/macros/src/lib.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
extern crate proc_macro;
22

33
mod component;
4+
mod query_data;
5+
mod query_filter;
46
mod states;
57
mod world_query;
6-
mod world_query_data;
7-
mod world_query_filter;
88

9-
use crate::{
10-
world_query_data::derive_world_query_data_impl,
11-
world_query_filter::derive_world_query_filter_impl,
12-
};
9+
use crate::{query_data::derive_query_data_impl, query_filter::derive_query_filter_impl};
1310
use bevy_macro_utils::{derive_label, ensure_no_collision, get_struct_fields, BevyManifest};
1411
use proc_macro::TokenStream;
1512
use proc_macro2::Span;
@@ -450,16 +447,16 @@ pub fn derive_system_param(input: TokenStream) -> TokenStream {
450447
})
451448
}
452449

453-
/// Implement `WorldQueryData` to use a struct as a data parameter in a query
454-
#[proc_macro_derive(WorldQueryData, attributes(world_query_data))]
455-
pub fn derive_world_query_data(input: TokenStream) -> TokenStream {
456-
derive_world_query_data_impl(input)
450+
/// Implement `QueryData` to use a struct as a data parameter in a query
451+
#[proc_macro_derive(QueryData, attributes(query_data))]
452+
pub fn derive_query_data(input: TokenStream) -> TokenStream {
453+
derive_query_data_impl(input)
457454
}
458455

459-
/// Implement `WorldQueryFilter` to use a struct as a filter parameter in a query
460-
#[proc_macro_derive(WorldQueryFilter, attributes(world_query_filter))]
461-
pub fn derive_world_query_filter(input: TokenStream) -> TokenStream {
462-
derive_world_query_filter_impl(input)
456+
/// Implement `QueryFilter` to use a struct as a filter parameter in a query
457+
#[proc_macro_derive(QueryFilter, attributes(query_filter))]
458+
pub fn derive_query_filter(input: TokenStream) -> TokenStream {
459+
derive_query_filter_impl(input)
463460
}
464461

465462
/// Derive macro generating an impl of the trait `ScheduleLabel`.

0 commit comments

Comments
 (0)