Skip to content

Commit

Permalink
Implement suggestions for more renames
Browse files Browse the repository at this point in the history
  • Loading branch information
taizu-jin committed Nov 29, 2023
1 parent 4c7b3c1 commit c304119
Show file tree
Hide file tree
Showing 38 changed files with 149 additions and 152 deletions.
4 changes: 2 additions & 2 deletions crates/bevy_core_pipeline/src/bloom/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -140,7 +140,7 @@ impl ViewNode for BloomNode {
bloom_settings,
upsampling_pipeline_ids,
downsampling_pipeline_ids,
): QueryItem<Self::ViewQuery>,
): QueryItem<Self::ViewData>,
world: &World,
) -> Result<(), NodeRunError> {
let downsampling_pipeline_res = world.resource::<BloomDownsamplingPipeline>();
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_core_pipeline/src/bloom/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self::Out> {
fn extract_component((settings, camera): QueryItem<'_, Self::Data>) -> Option<Self::Out> {
match (
camera.physical_viewport_rect(),
camera.physical_viewport_size(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ pub struct CASUniform {
}

impl ExtractComponent for ContrastAdaptiveSharpeningSettings {
type Query = &'static Self;
type Data = &'static Self;
type Filter = With<Camera>;
type Out = (DenoiseCAS, CASUniform);

fn extract_component(item: QueryItem<Self::Query>) -> Option<Self::Out> {
fn extract_component(item: QueryItem<Self::Data>) -> Option<Self::Out> {
if !item.enabled || item.sharpening_strength == 0.0 {
return None;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Opaque3d>,
&'static RenderPhase<AlphaMask3d>,
Expand Down Expand Up @@ -58,7 +58,7 @@ impl ViewNode for MainOpaquePass3dNode {
skybox_pipeline,
skybox_bind_group,
view_uniform_offset,
): QueryItem<Self::ViewQuery>,
): QueryItem<Self::ViewData>,
world: &World,
) -> Result<(), NodeRunError> {
let load = if deferred_prepass.is_none() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Transmissive3d>,
Expand All @@ -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> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Transparent3d>,
&'static ViewTarget,
Expand All @@ -26,7 +26,7 @@ impl ViewNode for MainTransparentPass3dNode {
&self,
graph: &mut RenderGraphContext,
render_context: &mut RenderContext,
(camera, transparent_phase, target, depth): QueryItem<Self::ViewQuery>,
(camera, transparent_phase, target, depth): QueryItem<Self::ViewData>,
world: &World,
) -> Result<(), NodeRunError> {
let view_entity = graph.view_entity();
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_core_pipeline/src/deferred/copy_lighting_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl CopyDeferredLightingIdNode {
}

impl ViewNode for CopyDeferredLightingIdNode {
type ViewQuery = (
type ViewData = (
&'static ViewTarget,
&'static ViewPrepassTextures,
&'static DeferredLightingIdDepthTexture,
Expand All @@ -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> {
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_core_pipeline/src/deferred/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use super::{AlphaMask3dDeferred, Opaque3dDeferred};
pub struct DeferredGBufferPrepassNode;

impl ViewNode for DeferredGBufferPrepassNode {
type ViewQuery = (
type ViewData = (
&'static ExtractedCamera,
&'static RenderPhase<Opaque3dDeferred>,
&'static RenderPhase<AlphaMask3dDeferred>,
Expand All @@ -55,7 +55,7 @@ impl ViewNode for DeferredGBufferPrepassNode {
depth_prepass,
normal_prepass,
motion_vector_prepass,
): QueryItem<Self::ViewQuery>,
): QueryItem<Self::ViewData>,
world: &World,
) -> Result<(), NodeRunError> {
let view_entity = graph.view_entity();
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_core_pipeline/src/fxaa/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct FxaaNode {
}

impl ViewNode for FxaaNode {
type ViewQuery = (
type ViewData = (
&'static ViewTarget,
&'static CameraFxaaPipeline,
&'static Fxaa,
Expand All @@ -30,7 +30,7 @@ impl ViewNode for FxaaNode {
&self,
_graph: &mut RenderGraphContext,
render_context: &mut RenderContext,
(target, pipeline, fxaa): QueryItem<Self::ViewQuery>,
(target, pipeline, fxaa): QueryItem<Self::ViewData>,
world: &World,
) -> Result<(), NodeRunError> {
let pipeline_cache = world.resource::<PipelineCache>();
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_core_pipeline/src/prepass/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Opaque3dPrepass>,
&'static RenderPhase<AlphaMask3dPrepass>,
Expand All @@ -45,7 +45,7 @@ impl ViewNode for PrepassNode {
view_depth_texture,
view_prepass_textures,
deferred_prepass,
): QueryItem<Self::ViewQuery>,
): QueryItem<Self::ViewData>,
world: &World,
) -> Result<(), NodeRunError> {
let view_entity = graph.view_entity();
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_core_pipeline/src/taa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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> {
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_core_pipeline/src/tonemapping/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub struct TonemappingNode {
}

impl ViewNode for TonemappingNode {
type ViewQuery = (
type ViewData = (
&'static ViewUniformOffset,
&'static ViewTarget,
&'static ViewTonemappingPipeline,
Expand All @@ -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> {
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_core_pipeline/src/upscaling/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct UpscalingNode {
}

impl ViewNode for UpscalingNode {
type ViewQuery = (
type ViewData = (
&'static ViewTarget,
&'static ViewUpscalingPipeline,
Option<&'static ExtractedCamera>,
Expand All @@ -28,7 +28,7 @@ impl ViewNode for UpscalingNode {
&self,
_graph: &mut RenderGraphContext,
render_context: &mut RenderContext,
(target, upscaling_target, camera): QueryItem<Self::ViewQuery>,
(target, upscaling_target, camera): QueryItem<Self::ViewData>,
world: &World,
) -> Result<(), NodeRunError> {
let pipeline_cache = world.get_resource::<PipelineCache>().unwrap();
Expand Down
17 changes: 7 additions & 10 deletions crates/bevy_ecs/macros/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -452,14 +449,14 @@ pub fn derive_system_param(input: TokenStream) -> TokenStream {

/// Implement `QueryData` to use a struct as a data parameter in a query
#[proc_macro_derive(QueryData, attributes(query_data))]
pub fn derive_world_query_data(input: TokenStream) -> TokenStream {
derive_world_query_data_impl(input)
pub fn derive_query_data(input: TokenStream) -> TokenStream {
derive_query_data_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_world_query_filter(input: TokenStream) -> TokenStream {
derive_world_query_filter_impl(input)
pub fn derive_query_filter(input: TokenStream) -> TokenStream {
derive_query_filter_impl(input)
}

/// Derive macro generating an impl of the trait `ScheduleLabel`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::{
};

#[derive(Default)]
struct WorldQueryDataAttributes {
struct QueryDataAttributes {
pub is_mutable: bool,

pub derive_args: Punctuated<Meta, syn::token::Comma>,
Expand All @@ -29,20 +29,20 @@ mod field_attr_keywords {
syn::custom_keyword!(ignore);
}

pub static WORLD_QUERY_DATA_ATTRIBUTE_NAME: &str = "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;
}
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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(),
};

Expand Down Expand Up @@ -385,18 +385,18 @@ pub fn derive_world_query_data_impl(input: TokenStream) -> TokenStream {
})
}

struct WorldQueryDataFieldInfo {
struct QueryDataFieldInfo {
/// All field attributes except for `query_data` ones.
attrs: Vec<Attribute>,
}

fn read_world_query_field_info(field: &Field) -> syn::Result<WorldQueryDataFieldInfo> {
fn read_world_query_field_info(field: &Field) -> syn::Result<QueryDataFieldInfo> {
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,
Expand All @@ -406,5 +406,5 @@ fn read_world_query_field_info(field: &Field) -> syn::Result<WorldQueryDataField
attrs.push(attr.clone());
}

Ok(WorldQueryDataFieldInfo { attrs })
Ok(QueryDataFieldInfo { attrs })
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ecs/src/query/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ unsafe impl<T: Component> ReadOnlyQueryData for Has<T> {}
/// Entities are guaranteed to have at least one of the components in `T`.
pub struct AnyOf<T>(PhantomData<T>);

macro_rules! impl_tuple_world_query_data {
macro_rules! impl_tuple_query_data {
($(($name: ident, $state: ident)),*) => {

#[allow(non_snake_case)]
Expand Down Expand Up @@ -1396,7 +1396,7 @@ macro_rules! impl_anytuple_fetch {
};
}

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<Q>` into `Query<NopWorldQuery<Q>>`
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ecs/src/query/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ 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)]
Expand All @@ -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.
Expand Down
Loading

0 comments on commit c304119

Please sign in to comment.