Replace WorldQueryGats trait with actual gats (#6319)
# Objective Replace `WorldQueryGats` trait with actual gats ## Solution Replace `WorldQueryGats` trait with actual gats --- ## Changelog - Replaced `WorldQueryGats` trait with actual gats ## Migration Guide - Replace usage of `WorldQueryGats` assoc types with the actual gats on `WorldQuery` trait
This commit is contained in:
parent
157f2c1584
commit
30e35764a1
@ -19,7 +19,7 @@ impl ExtractComponent for Camera2d {
|
|||||||
type Query = &'static Self;
|
type Query = &'static Self;
|
||||||
type Filter = With<Camera>;
|
type Filter = With<Camera>;
|
||||||
|
|
||||||
fn extract_component(item: QueryItem<Self::Query>) -> Self {
|
fn extract_component(item: QueryItem<'_, Self::Query>) -> Self {
|
||||||
item.clone()
|
item.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,7 +51,7 @@ impl ExtractComponent for Camera3d {
|
|||||||
type Query = &'static Self;
|
type Query = &'static Self;
|
||||||
type Filter = With<Camera>;
|
type Filter = With<Camera>;
|
||||||
|
|
||||||
fn extract_component(item: QueryItem<Self::Query>) -> Self {
|
fn extract_component(item: QueryItem<'_, Self::Query>) -> Self {
|
||||||
item.clone()
|
item.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -185,7 +185,7 @@ pub fn derive_world_query_impl(ast: DeriveInput) -> TokenStream {
|
|||||||
#[doc = "`], returned when iterating over query results."]
|
#[doc = "`], returned when iterating over query results."]
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
#visibility struct #item_struct_name #user_impl_generics_with_world #user_where_clauses_with_world {
|
#visibility struct #item_struct_name #user_impl_generics_with_world #user_where_clauses_with_world {
|
||||||
#(#(#field_attrs)* #field_visibilities #field_idents: <#field_types as #path::query::WorldQueryGats<'__w>>::Item,)*
|
#(#(#field_attrs)* #field_visibilities #field_idents: <#field_types as #path::query::WorldQuery>::Item<'__w>,)*
|
||||||
#(#(#ignored_field_attrs)* #ignored_field_visibilities #ignored_field_idents: #ignored_field_types,)*
|
#(#(#ignored_field_attrs)* #ignored_field_visibilities #ignored_field_idents: #ignored_field_types,)*
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,27 +195,22 @@ pub fn derive_world_query_impl(ast: DeriveInput) -> TokenStream {
|
|||||||
#[doc = "`], used to define the world data accessed by this query."]
|
#[doc = "`], used to define the world data accessed by this query."]
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
#visibility struct #fetch_struct_name #user_impl_generics_with_world #user_where_clauses_with_world {
|
#visibility struct #fetch_struct_name #user_impl_generics_with_world #user_where_clauses_with_world {
|
||||||
#(#field_idents: <#field_types as #path::query::WorldQueryGats<'__w>>::Fetch,)*
|
#(#field_idents: <#field_types as #path::query::WorldQuery>::Fetch<'__w>,)*
|
||||||
#(#ignored_field_idents: #ignored_field_types,)*
|
#(#ignored_field_idents: #ignored_field_types,)*
|
||||||
}
|
}
|
||||||
|
|
||||||
// SAFETY: `update_component_access` and `update_archetype_component_access` are called on every field
|
// SAFETY: `update_component_access` and `update_archetype_component_access` are called on every field
|
||||||
|
|
||||||
impl #user_impl_generics_with_world #path::query::WorldQueryGats<'__w>
|
|
||||||
for #struct_name #user_ty_generics #user_where_clauses {
|
|
||||||
type Item = #item_struct_name #user_ty_generics_with_world;
|
|
||||||
type Fetch = #fetch_struct_name #user_ty_generics_with_world;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe impl #user_impl_generics #path::query::WorldQuery
|
unsafe impl #user_impl_generics #path::query::WorldQuery
|
||||||
for #struct_name #user_ty_generics #user_where_clauses {
|
for #struct_name #user_ty_generics #user_where_clauses {
|
||||||
|
|
||||||
|
type Item<'__w> = #item_struct_name #user_ty_generics_with_world;
|
||||||
|
type Fetch<'__w> = #fetch_struct_name #user_ty_generics_with_world;
|
||||||
type ReadOnly = #read_only_struct_name #user_ty_generics;
|
type ReadOnly = #read_only_struct_name #user_ty_generics;
|
||||||
type State = #state_struct_name #user_ty_generics;
|
type State = #state_struct_name #user_ty_generics;
|
||||||
|
|
||||||
fn shrink<'__wlong: '__wshort, '__wshort>(
|
fn shrink<'__wlong: '__wshort, '__wshort>(
|
||||||
item: <#struct_name #user_ty_generics as #path::query::WorldQueryGats<'__wlong>>::Item
|
item: <#struct_name #user_ty_generics as #path::query::WorldQuery>::Item<'__wlong>
|
||||||
) -> <#struct_name #user_ty_generics as #path::query::WorldQueryGats<'__wshort>>::Item {
|
) -> <#struct_name #user_ty_generics as #path::query::WorldQuery>::Item<'__wshort> {
|
||||||
#item_struct_name {
|
#item_struct_name {
|
||||||
#(
|
#(
|
||||||
#field_idents: <#field_types>::shrink(item.#field_idents),
|
#field_idents: <#field_types>::shrink(item.#field_idents),
|
||||||
@ -231,7 +226,7 @@ pub fn derive_world_query_impl(ast: DeriveInput) -> TokenStream {
|
|||||||
state: &Self::State,
|
state: &Self::State,
|
||||||
_last_change_tick: u32,
|
_last_change_tick: u32,
|
||||||
_change_tick: u32
|
_change_tick: u32
|
||||||
) -> <Self as #path::query::WorldQueryGats<'__w>>::Fetch {
|
) -> <Self as #path::query::WorldQuery>::Fetch<'__w> {
|
||||||
#fetch_struct_name {
|
#fetch_struct_name {
|
||||||
#(#field_idents:
|
#(#field_idents:
|
||||||
<#field_types>::init_fetch(
|
<#field_types>::init_fetch(
|
||||||
@ -246,8 +241,8 @@ pub fn derive_world_query_impl(ast: DeriveInput) -> TokenStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn clone_fetch<'__w>(
|
unsafe fn clone_fetch<'__w>(
|
||||||
_fetch: &<Self as #path::query::WorldQueryGats<'__w>>::Fetch
|
_fetch: &<Self as #path::query::WorldQuery>::Fetch<'__w>
|
||||||
) -> <Self as #path::query::WorldQueryGats<'__w>>::Fetch {
|
) -> <Self as #path::query::WorldQuery>::Fetch<'__w> {
|
||||||
#fetch_struct_name {
|
#fetch_struct_name {
|
||||||
#(
|
#(
|
||||||
#field_idents: <#field_types>::clone_fetch(& _fetch. #field_idents),
|
#field_idents: <#field_types>::clone_fetch(& _fetch. #field_idents),
|
||||||
@ -265,7 +260,7 @@ pub fn derive_world_query_impl(ast: DeriveInput) -> TokenStream {
|
|||||||
/// SAFETY: we call `set_archetype` for each member that implements `Fetch`
|
/// SAFETY: we call `set_archetype` for each member that implements `Fetch`
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn set_archetype<'__w>(
|
unsafe fn set_archetype<'__w>(
|
||||||
_fetch: &mut <Self as #path::query::WorldQueryGats<'__w>>::Fetch,
|
_fetch: &mut <Self as #path::query::WorldQuery>::Fetch<'__w>,
|
||||||
_state: &Self::State,
|
_state: &Self::State,
|
||||||
_archetype: &'__w #path::archetype::Archetype,
|
_archetype: &'__w #path::archetype::Archetype,
|
||||||
_table: &'__w #path::storage::Table
|
_table: &'__w #path::storage::Table
|
||||||
@ -276,7 +271,7 @@ pub fn derive_world_query_impl(ast: DeriveInput) -> TokenStream {
|
|||||||
/// SAFETY: we call `set_table` for each member that implements `Fetch`
|
/// SAFETY: we call `set_table` for each member that implements `Fetch`
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn set_table<'__w>(
|
unsafe fn set_table<'__w>(
|
||||||
_fetch: &mut <Self as #path::query::WorldQueryGats<'__w>>::Fetch,
|
_fetch: &mut <Self as #path::query::WorldQuery>::Fetch<'__w>,
|
||||||
_state: &Self::State,
|
_state: &Self::State,
|
||||||
_table: &'__w #path::storage::Table
|
_table: &'__w #path::storage::Table
|
||||||
) {
|
) {
|
||||||
@ -286,10 +281,10 @@ pub fn derive_world_query_impl(ast: DeriveInput) -> TokenStream {
|
|||||||
/// SAFETY: we call `fetch` for each member that implements `Fetch`.
|
/// SAFETY: we call `fetch` for each member that implements `Fetch`.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
unsafe fn fetch<'__w>(
|
unsafe fn fetch<'__w>(
|
||||||
_fetch: &mut <Self as #path::query::WorldQueryGats<'__w>>::Fetch,
|
_fetch: &mut <Self as #path::query::WorldQuery>::Fetch<'__w>,
|
||||||
_entity: Entity,
|
_entity: Entity,
|
||||||
_table_row: usize
|
_table_row: usize
|
||||||
) -> <Self as #path::query::WorldQueryGats<'__w>>::Item {
|
) -> <Self as #path::query::WorldQuery>::Item<'__w> {
|
||||||
Self::Item {
|
Self::Item {
|
||||||
#(#field_idents: <#field_types>::fetch(&mut _fetch.#field_idents, _entity, _table_row),)*
|
#(#field_idents: <#field_types>::fetch(&mut _fetch.#field_idents, _entity, _table_row),)*
|
||||||
#(#ignored_field_idents: Default::default(),)*
|
#(#ignored_field_idents: Default::default(),)*
|
||||||
@ -299,7 +294,7 @@ pub fn derive_world_query_impl(ast: DeriveInput) -> TokenStream {
|
|||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
unsafe fn filter_fetch<'__w>(
|
unsafe fn filter_fetch<'__w>(
|
||||||
_fetch: &mut <Self as #path::query::WorldQueryGats<'__w>>::Fetch,
|
_fetch: &mut <Self as #path::query::WorldQuery>::Fetch<'__w>,
|
||||||
_entity: Entity,
|
_entity: Entity,
|
||||||
_table_row: usize
|
_table_row: usize
|
||||||
) -> bool {
|
) -> bool {
|
||||||
|
|||||||
@ -283,8 +283,8 @@ use std::{cell::UnsafeCell, marker::PhantomData};
|
|||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
///
|
///
|
||||||
/// Component access of `ROQueryFetch<Self>` must be a subset of `QueryFetch<Self>`
|
/// Component access of `Self::ReadOnly` must be a subset of `Self`
|
||||||
/// and `ROQueryFetch<Self>` must match exactly the same archetypes/tables as `QueryFetch<Self>`
|
/// and `Self::ReadOnly` must match exactly the same archetypes/tables as `Self`
|
||||||
///
|
///
|
||||||
/// Implementor must ensure that
|
/// Implementor must ensure that
|
||||||
/// [`update_component_access`] and [`update_archetype_component_access`]
|
/// [`update_component_access`] and [`update_archetype_component_access`]
|
||||||
@ -296,7 +296,7 @@ use std::{cell::UnsafeCell, marker::PhantomData};
|
|||||||
/// [`Added`]: crate::query::Added
|
/// [`Added`]: crate::query::Added
|
||||||
/// [`fetch`]: Self::fetch
|
/// [`fetch`]: Self::fetch
|
||||||
/// [`Changed`]: crate::query::Changed
|
/// [`Changed`]: crate::query::Changed
|
||||||
/// [`Fetch`]: crate::query::WorldQueryGats::Fetch
|
/// [`Fetch`]: crate::query::WorldQuery::Fetch
|
||||||
/// [`matches_component_set`]: Self::matches_component_set
|
/// [`matches_component_set`]: Self::matches_component_set
|
||||||
/// [`Or`]: crate::query::Or
|
/// [`Or`]: crate::query::Or
|
||||||
/// [`Query`]: crate::system::Query
|
/// [`Query`]: crate::system::Query
|
||||||
@ -306,17 +306,23 @@ use std::{cell::UnsafeCell, marker::PhantomData};
|
|||||||
/// [`update_component_access`]: Self::update_component_access
|
/// [`update_component_access`]: Self::update_component_access
|
||||||
/// [`With`]: crate::query::With
|
/// [`With`]: crate::query::With
|
||||||
/// [`Without`]: crate::query::Without
|
/// [`Without`]: crate::query::Without
|
||||||
pub unsafe trait WorldQuery: for<'w> WorldQueryGats<'w> {
|
pub unsafe trait WorldQuery {
|
||||||
|
/// The item returned by this [`WorldQuery`]
|
||||||
|
type Item<'a>;
|
||||||
|
|
||||||
|
/// Per archetype/table state used by this [`WorldQuery`] to fetch [`Self::Item`](crate::query::WorldQuery::Item)
|
||||||
|
type Fetch<'a>;
|
||||||
|
|
||||||
/// The read-only variant of this [`WorldQuery`], which satisfies the [`ReadOnlyWorldQuery`] trait.
|
/// The read-only variant of this [`WorldQuery`], which satisfies the [`ReadOnlyWorldQuery`] trait.
|
||||||
type ReadOnly: ReadOnlyWorldQuery<State = Self::State>;
|
type ReadOnly: ReadOnlyWorldQuery<State = Self::State>;
|
||||||
|
|
||||||
/// State used to construct a [`Self::Fetch`](crate::query::WorldQueryGats::Fetch). This will be cached inside [`QueryState`](crate::query::QueryState),
|
/// State used to construct a [`Self::Fetch`](crate::query::WorldQuery::Fetch). This will be cached inside [`QueryState`](crate::query::QueryState),
|
||||||
/// so it is best to move as much data / computation here as possible to reduce the cost of
|
/// so it is best to move as much data / computation here as possible to reduce the cost of
|
||||||
/// constructing [`Self::Fetch`](crate::query::WorldQueryGats::Fetch).
|
/// constructing [`Self::Fetch`](crate::query::WorldQuery::Fetch).
|
||||||
type State: Send + Sync + Sized;
|
type State: Send + Sync + Sized;
|
||||||
|
|
||||||
/// This function manually implements subtyping for the query items.
|
/// This function manually implements subtyping for the query items.
|
||||||
fn shrink<'wlong: 'wshort, 'wshort>(item: QueryItem<'wlong, Self>) -> QueryItem<'wshort, Self>;
|
fn shrink<'wlong: 'wshort, 'wshort>(item: Self::Item<'wlong>) -> Self::Item<'wshort>;
|
||||||
|
|
||||||
/// Creates a new instance of this fetch.
|
/// Creates a new instance of this fetch.
|
||||||
///
|
///
|
||||||
@ -329,7 +335,7 @@ pub unsafe trait WorldQuery: for<'w> WorldQueryGats<'w> {
|
|||||||
state: &Self::State,
|
state: &Self::State,
|
||||||
last_change_tick: u32,
|
last_change_tick: u32,
|
||||||
change_tick: u32,
|
change_tick: u32,
|
||||||
) -> <Self as WorldQueryGats<'w>>::Fetch;
|
) -> Self::Fetch<'w>;
|
||||||
|
|
||||||
/// While this function can be called for any query, it is always safe to call if `Self: ReadOnlyWorldQuery` holds.
|
/// While this function can be called for any query, it is always safe to call if `Self: ReadOnlyWorldQuery` holds.
|
||||||
///
|
///
|
||||||
@ -337,9 +343,7 @@ pub unsafe trait WorldQuery: for<'w> WorldQueryGats<'w> {
|
|||||||
/// While calling this method on its own cannot cause UB it is marked `unsafe` as the caller must ensure
|
/// While calling this method on its own cannot cause UB it is marked `unsafe` as the caller must ensure
|
||||||
/// that the returned value is not used in any way that would cause two `QueryItem<Self>` for the same
|
/// that the returned value is not used in any way that would cause two `QueryItem<Self>` for the same
|
||||||
/// `archetype_index` or `table_row` to be alive at the same time.
|
/// `archetype_index` or `table_row` to be alive at the same time.
|
||||||
unsafe fn clone_fetch<'w>(
|
unsafe fn clone_fetch<'w>(fetch: &Self::Fetch<'w>) -> Self::Fetch<'w>;
|
||||||
fetch: &<Self as WorldQueryGats<'w>>::Fetch,
|
|
||||||
) -> <Self as WorldQueryGats<'w>>::Fetch;
|
|
||||||
|
|
||||||
/// Returns true if (and only if) every table of every archetype matched by this fetch contains
|
/// Returns true if (and only if) every table of every archetype matched by this fetch contains
|
||||||
/// all of the matched components. This is used to select a more efficient "table iterator"
|
/// all of the matched components. This is used to select a more efficient "table iterator"
|
||||||
@ -364,7 +368,7 @@ pub unsafe trait WorldQuery: for<'w> WorldQueryGats<'w> {
|
|||||||
/// `archetype` and `tables` must be from the [`World`] [`WorldQuery::init_state`] was called on. `state` must
|
/// `archetype` and `tables` must be from the [`World`] [`WorldQuery::init_state`] was called on. `state` must
|
||||||
/// be the [`Self::State`] this was initialized with.
|
/// be the [`Self::State`] this was initialized with.
|
||||||
unsafe fn set_archetype<'w>(
|
unsafe fn set_archetype<'w>(
|
||||||
fetch: &mut <Self as WorldQueryGats<'w>>::Fetch,
|
fetch: &mut Self::Fetch<'w>,
|
||||||
state: &Self::State,
|
state: &Self::State,
|
||||||
archetype: &'w Archetype,
|
archetype: &'w Archetype,
|
||||||
table: &'w Table,
|
table: &'w Table,
|
||||||
@ -377,13 +381,9 @@ pub unsafe trait WorldQuery: for<'w> WorldQueryGats<'w> {
|
|||||||
///
|
///
|
||||||
/// `table` must be from the [`World`] [`WorldQuery::init_state`] was called on. `state` must be the
|
/// `table` must be from the [`World`] [`WorldQuery::init_state`] was called on. `state` must be the
|
||||||
/// [`Self::State`] this was initialized with.
|
/// [`Self::State`] this was initialized with.
|
||||||
unsafe fn set_table<'w>(
|
unsafe fn set_table<'w>(fetch: &mut Self::Fetch<'w>, state: &Self::State, table: &'w Table);
|
||||||
fetch: &mut <Self as WorldQueryGats<'w>>::Fetch,
|
|
||||||
state: &Self::State,
|
|
||||||
table: &'w Table,
|
|
||||||
);
|
|
||||||
|
|
||||||
/// Fetch [`Self::Item`](`WorldQueryGats::Item`) for either the given `entity` in the current [`Table`],
|
/// Fetch [`Self::Item`](`WorldQuery::Item`) for either the given `entity` in the current [`Table`],
|
||||||
/// or for the given `entity` in the current [`Archetype`]. This must always be called after
|
/// or for the given `entity` in the current [`Archetype`]. This must always be called after
|
||||||
/// [`WorldQuery::set_table`] with a `table_row` in the range of the current [`Table`] or after
|
/// [`WorldQuery::set_table`] with a `table_row` in the range of the current [`Table`] or after
|
||||||
/// [`WorldQuery::set_archetype`] with a `entity` in the current archetype.
|
/// [`WorldQuery::set_archetype`] with a `entity` in the current archetype.
|
||||||
@ -393,10 +393,10 @@ pub unsafe trait WorldQuery: for<'w> WorldQueryGats<'w> {
|
|||||||
/// Must always be called _after_ [`WorldQuery::set_table`] or [`WorldQuery::set_archetype`]. `entity` and
|
/// Must always be called _after_ [`WorldQuery::set_table`] or [`WorldQuery::set_archetype`]. `entity` and
|
||||||
/// `table_row` must be in the range of the current table and archetype.
|
/// `table_row` must be in the range of the current table and archetype.
|
||||||
unsafe fn fetch<'w>(
|
unsafe fn fetch<'w>(
|
||||||
fetch: &mut <Self as WorldQueryGats<'w>>::Fetch,
|
fetch: &mut Self::Fetch<'w>,
|
||||||
entity: Entity,
|
entity: Entity,
|
||||||
table_row: usize,
|
table_row: usize,
|
||||||
) -> <Self as WorldQueryGats<'w>>::Item;
|
) -> Self::Item<'w>;
|
||||||
|
|
||||||
/// # Safety
|
/// # Safety
|
||||||
///
|
///
|
||||||
@ -404,11 +404,7 @@ pub unsafe trait WorldQuery: for<'w> WorldQueryGats<'w> {
|
|||||||
/// `table_row` must be in the range of the current table and archetype.
|
/// `table_row` must be in the range of the current table and archetype.
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
unsafe fn filter_fetch(
|
unsafe fn filter_fetch(fetch: &mut Self::Fetch<'_>, entity: Entity, table_row: usize) -> bool {
|
||||||
fetch: &mut <Self as WorldQueryGats<'_>>::Fetch,
|
|
||||||
entity: Entity,
|
|
||||||
table_row: usize,
|
|
||||||
) -> bool {
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -430,14 +426,6 @@ pub unsafe trait WorldQuery: for<'w> WorldQueryGats<'w> {
|
|||||||
) -> bool;
|
) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A helper trait for [`WorldQuery`] that works around Rust's lack of Generic Associated Types.
|
|
||||||
///
|
|
||||||
/// **Note**: Consider using the type aliases [`QueryItem`] and [`QueryFetch`] when using `Item` or `Fetch`.
|
|
||||||
pub trait WorldQueryGats<'world> {
|
|
||||||
type Item;
|
|
||||||
type Fetch;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A world query that is read only.
|
/// A world query that is read only.
|
||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
@ -446,9 +434,9 @@ pub trait WorldQueryGats<'world> {
|
|||||||
pub unsafe trait ReadOnlyWorldQuery: WorldQuery<ReadOnly = Self> {}
|
pub unsafe trait ReadOnlyWorldQuery: WorldQuery<ReadOnly = Self> {}
|
||||||
|
|
||||||
/// The `Fetch` of a [`WorldQuery`], which is used to store state for each archetype/table.
|
/// The `Fetch` of a [`WorldQuery`], which is used to store state for each archetype/table.
|
||||||
pub type QueryFetch<'w, Q> = <Q as WorldQueryGats<'w>>::Fetch;
|
pub type QueryFetch<'w, Q> = <Q as WorldQuery>::Fetch<'w>;
|
||||||
/// The item type returned when a [`WorldQuery`] is iterated over
|
/// The item type returned when a [`WorldQuery`] is iterated over
|
||||||
pub type QueryItem<'w, Q> = <Q as WorldQueryGats<'w>>::Item;
|
pub type QueryItem<'w, Q> = <Q as WorldQuery>::Item<'w>;
|
||||||
/// The read-only `Fetch` of a [`WorldQuery`], which is used to store state for each archetype/table.
|
/// The read-only `Fetch` of a [`WorldQuery`], which is used to store state for each archetype/table.
|
||||||
pub type ROQueryFetch<'w, Q> = QueryFetch<'w, <Q as WorldQuery>::ReadOnly>;
|
pub type ROQueryFetch<'w, Q> = QueryFetch<'w, <Q as WorldQuery>::ReadOnly>;
|
||||||
/// The read-only variant of the item type returned when a [`WorldQuery`] is iterated over immutably
|
/// The read-only variant of the item type returned when a [`WorldQuery`] is iterated over immutably
|
||||||
@ -456,10 +444,12 @@ pub type ROQueryItem<'w, Q> = QueryItem<'w, <Q as WorldQuery>::ReadOnly>;
|
|||||||
|
|
||||||
/// SAFETY: no component or archetype access
|
/// SAFETY: no component or archetype access
|
||||||
unsafe impl WorldQuery for Entity {
|
unsafe impl WorldQuery for Entity {
|
||||||
|
type Fetch<'w> = ();
|
||||||
|
type Item<'w> = Entity;
|
||||||
type ReadOnly = Self;
|
type ReadOnly = Self;
|
||||||
type State = ();
|
type State = ();
|
||||||
|
|
||||||
fn shrink<'wlong: 'wshort, 'wshort>(item: QueryItem<'wlong, Self>) -> QueryItem<'wshort, Self> {
|
fn shrink<'wlong: 'wshort, 'wshort>(item: Self::Item<'wlong>) -> Self::Item<'wshort> {
|
||||||
item
|
item
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -472,17 +462,14 @@ unsafe impl WorldQuery for Entity {
|
|||||||
_state: &Self::State,
|
_state: &Self::State,
|
||||||
_last_change_tick: u32,
|
_last_change_tick: u32,
|
||||||
_change_tick: u32,
|
_change_tick: u32,
|
||||||
) -> <Self as WorldQueryGats<'w>>::Fetch {
|
) -> Self::Fetch<'w> {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn clone_fetch<'w>(
|
unsafe fn clone_fetch<'w>(_fetch: &Self::Fetch<'w>) -> Self::Fetch<'w> {}
|
||||||
_fetch: &<Self as WorldQueryGats<'w>>::Fetch,
|
|
||||||
) -> <Self as WorldQueryGats<'w>>::Fetch {
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn set_archetype<'w>(
|
unsafe fn set_archetype<'w>(
|
||||||
_fetch: &mut <Self as WorldQueryGats<'w>>::Fetch,
|
_fetch: &mut Self::Fetch<'w>,
|
||||||
_state: &Self::State,
|
_state: &Self::State,
|
||||||
_archetype: &'w Archetype,
|
_archetype: &'w Archetype,
|
||||||
_table: &Table,
|
_table: &Table,
|
||||||
@ -490,19 +477,15 @@ unsafe impl WorldQuery for Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn set_table<'w>(
|
unsafe fn set_table<'w>(_fetch: &mut Self::Fetch<'w>, _state: &Self::State, _table: &'w Table) {
|
||||||
_fetch: &mut <Self as WorldQueryGats<'w>>::Fetch,
|
|
||||||
_state: &Self::State,
|
|
||||||
_table: &'w Table,
|
|
||||||
) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
unsafe fn fetch<'w>(
|
unsafe fn fetch<'w>(
|
||||||
_fetch: &mut <Self as WorldQueryGats<'w>>::Fetch,
|
_fetch: &mut Self::Fetch<'w>,
|
||||||
entity: Entity,
|
entity: Entity,
|
||||||
_table_row: usize,
|
_table_row: usize,
|
||||||
) -> <Self as WorldQueryGats<'w>>::Item {
|
) -> Self::Item<'w> {
|
||||||
entity
|
entity
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -525,11 +508,6 @@ unsafe impl WorldQuery for Entity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'w> WorldQueryGats<'w> for Entity {
|
|
||||||
type Fetch = ();
|
|
||||||
type Item = Entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// SAFETY: access is read only
|
/// SAFETY: access is read only
|
||||||
unsafe impl ReadOnlyWorldQuery for Entity {}
|
unsafe impl ReadOnlyWorldQuery for Entity {}
|
||||||
|
|
||||||
@ -541,8 +519,10 @@ pub struct ReadFetch<'w, T> {
|
|||||||
sparse_set: Option<&'w ComponentSparseSet>,
|
sparse_set: Option<&'w ComponentSparseSet>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// SAFETY: `ROQueryFetch<Self>` is the same as `QueryFetch<Self>`
|
/// SAFETY: `Self` is the same as `Self::ReadOnly`
|
||||||
unsafe impl<T: Component> WorldQuery for &T {
|
unsafe impl<T: Component> WorldQuery for &T {
|
||||||
|
type Fetch<'w> = ReadFetch<'w, T>;
|
||||||
|
type Item<'w> = &'w T;
|
||||||
type ReadOnly = Self;
|
type ReadOnly = Self;
|
||||||
type State = ComponentId;
|
type State = ComponentId;
|
||||||
|
|
||||||
@ -577,9 +557,7 @@ unsafe impl<T: Component> WorldQuery for &T {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn clone_fetch<'w>(
|
unsafe fn clone_fetch<'w>(fetch: &Self::Fetch<'w>) -> Self::Fetch<'w> {
|
||||||
fetch: &<Self as WorldQueryGats<'w>>::Fetch,
|
|
||||||
) -> <Self as WorldQueryGats<'w>>::Fetch {
|
|
||||||
ReadFetch {
|
ReadFetch {
|
||||||
table_components: fetch.table_components,
|
table_components: fetch.table_components,
|
||||||
sparse_set: fetch.sparse_set,
|
sparse_set: fetch.sparse_set,
|
||||||
@ -615,10 +593,10 @@ unsafe impl<T: Component> WorldQuery for &T {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
unsafe fn fetch<'w>(
|
unsafe fn fetch<'w>(
|
||||||
fetch: &mut <Self as WorldQueryGats<'w>>::Fetch,
|
fetch: &mut Self::Fetch<'w>,
|
||||||
entity: Entity,
|
entity: Entity,
|
||||||
table_row: usize,
|
table_row: usize,
|
||||||
) -> <Self as WorldQueryGats<'w>>::Item {
|
) -> Self::Item<'w> {
|
||||||
match T::Storage::STORAGE_TYPE {
|
match T::Storage::STORAGE_TYPE {
|
||||||
StorageType::Table => fetch
|
StorageType::Table => fetch
|
||||||
.table_components
|
.table_components
|
||||||
@ -671,11 +649,6 @@ unsafe impl<T: Component> WorldQuery for &T {
|
|||||||
/// SAFETY: access is read only
|
/// SAFETY: access is read only
|
||||||
unsafe impl<T: Component> ReadOnlyWorldQuery for &T {}
|
unsafe impl<T: Component> ReadOnlyWorldQuery for &T {}
|
||||||
|
|
||||||
impl<'w, T: Component> WorldQueryGats<'w> for &T {
|
|
||||||
type Fetch = ReadFetch<'w, T>;
|
|
||||||
type Item = &'w T;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub struct WriteFetch<'w, T> {
|
pub struct WriteFetch<'w, T> {
|
||||||
// T::Storage = TableStorage
|
// T::Storage = TableStorage
|
||||||
@ -692,6 +665,8 @@ pub struct WriteFetch<'w, T> {
|
|||||||
|
|
||||||
/// SAFETY: access of `&T` is a subset of `&mut T`
|
/// SAFETY: access of `&T` is a subset of `&mut T`
|
||||||
unsafe impl<'__w, T: Component> WorldQuery for &'__w mut T {
|
unsafe impl<'__w, T: Component> WorldQuery for &'__w mut T {
|
||||||
|
type Fetch<'w> = WriteFetch<'w, T>;
|
||||||
|
type Item<'w> = Mut<'w, T>;
|
||||||
type ReadOnly = &'__w T;
|
type ReadOnly = &'__w T;
|
||||||
type State = ComponentId;
|
type State = ComponentId;
|
||||||
|
|
||||||
@ -728,9 +703,7 @@ unsafe impl<'__w, T: Component> WorldQuery for &'__w mut T {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn clone_fetch<'w>(
|
unsafe fn clone_fetch<'w>(fetch: &Self::Fetch<'w>) -> Self::Fetch<'w> {
|
||||||
fetch: &<Self as WorldQueryGats<'w>>::Fetch,
|
|
||||||
) -> <Self as WorldQueryGats<'w>>::Fetch {
|
|
||||||
WriteFetch {
|
WriteFetch {
|
||||||
table_data: fetch.table_data,
|
table_data: fetch.table_data,
|
||||||
sparse_set: fetch.sparse_set,
|
sparse_set: fetch.sparse_set,
|
||||||
@ -768,10 +741,10 @@ unsafe impl<'__w, T: Component> WorldQuery for &'__w mut T {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
unsafe fn fetch<'w>(
|
unsafe fn fetch<'w>(
|
||||||
fetch: &mut <Self as WorldQueryGats<'w>>::Fetch,
|
fetch: &mut Self::Fetch<'w>,
|
||||||
entity: Entity,
|
entity: Entity,
|
||||||
table_row: usize,
|
table_row: usize,
|
||||||
) -> <Self as WorldQueryGats<'w>>::Item {
|
) -> Self::Item<'w> {
|
||||||
match T::Storage::STORAGE_TYPE {
|
match T::Storage::STORAGE_TYPE {
|
||||||
StorageType::Table => {
|
StorageType::Table => {
|
||||||
let (table_components, table_ticks) = fetch
|
let (table_components, table_ticks) = fetch
|
||||||
@ -838,23 +811,20 @@ unsafe impl<'__w, T: Component> WorldQuery for &'__w mut T {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'w, T: Component> WorldQueryGats<'w> for &mut T {
|
|
||||||
type Fetch = WriteFetch<'w, T>;
|
|
||||||
type Item = Mut<'w, T>;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub struct OptionFetch<'w, T: WorldQuery> {
|
pub struct OptionFetch<'w, T: WorldQuery> {
|
||||||
fetch: <T as WorldQueryGats<'w>>::Fetch,
|
fetch: T::Fetch<'w>,
|
||||||
matches: bool,
|
matches: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
// SAFETY: defers to soundness of `T: WorldQuery` impl
|
// SAFETY: defers to soundness of `T: WorldQuery` impl
|
||||||
unsafe impl<T: WorldQuery> WorldQuery for Option<T> {
|
unsafe impl<T: WorldQuery> WorldQuery for Option<T> {
|
||||||
|
type Fetch<'w> = OptionFetch<'w, T>;
|
||||||
|
type Item<'w> = Option<T::Item<'w>>;
|
||||||
type ReadOnly = Option<T::ReadOnly>;
|
type ReadOnly = Option<T::ReadOnly>;
|
||||||
type State = T::State;
|
type State = T::State;
|
||||||
|
|
||||||
fn shrink<'wlong: 'wshort, 'wshort>(item: QueryItem<'wlong, Self>) -> QueryItem<'wshort, Self> {
|
fn shrink<'wlong: 'wshort, 'wshort>(item: Self::Item<'wlong>) -> Self::Item<'wshort> {
|
||||||
item.map(T::shrink)
|
item.map(T::shrink)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -874,9 +844,7 @@ unsafe impl<T: WorldQuery> WorldQuery for Option<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn clone_fetch<'w>(
|
unsafe fn clone_fetch<'w>(fetch: &Self::Fetch<'w>) -> Self::Fetch<'w> {
|
||||||
fetch: &<Self as WorldQueryGats<'w>>::Fetch,
|
|
||||||
) -> <Self as WorldQueryGats<'w>>::Fetch {
|
|
||||||
OptionFetch {
|
OptionFetch {
|
||||||
fetch: T::clone_fetch(&fetch.fetch),
|
fetch: T::clone_fetch(&fetch.fetch),
|
||||||
matches: fetch.matches,
|
matches: fetch.matches,
|
||||||
@ -906,10 +874,10 @@ unsafe impl<T: WorldQuery> WorldQuery for Option<T> {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
unsafe fn fetch<'w>(
|
unsafe fn fetch<'w>(
|
||||||
fetch: &mut <Self as WorldQueryGats<'w>>::Fetch,
|
fetch: &mut Self::Fetch<'w>,
|
||||||
entity: Entity,
|
entity: Entity,
|
||||||
table_row: usize,
|
table_row: usize,
|
||||||
) -> <Self as WorldQueryGats<'w>>::Item {
|
) -> Self::Item<'w> {
|
||||||
fetch
|
fetch
|
||||||
.matches
|
.matches
|
||||||
.then(|| T::fetch(&mut fetch.fetch, entity, table_row))
|
.then(|| T::fetch(&mut fetch.fetch, entity, table_row))
|
||||||
@ -950,11 +918,6 @@ unsafe impl<T: WorldQuery> WorldQuery for Option<T> {
|
|||||||
/// SAFETY: [`OptionFetch`] is read only because `T` is read only
|
/// SAFETY: [`OptionFetch`] is read only because `T` is read only
|
||||||
unsafe impl<T: ReadOnlyWorldQuery> ReadOnlyWorldQuery for Option<T> {}
|
unsafe impl<T: ReadOnlyWorldQuery> ReadOnlyWorldQuery for Option<T> {}
|
||||||
|
|
||||||
impl<'w, T: WorldQuery> WorldQueryGats<'w> for Option<T> {
|
|
||||||
type Fetch = OptionFetch<'w, T>;
|
|
||||||
type Item = Option<QueryItem<'w, T>>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// [`WorldQuery`] that tracks changes and additions for component `T`.
|
/// [`WorldQuery`] that tracks changes and additions for component `T`.
|
||||||
///
|
///
|
||||||
/// Wraps a [`Component`] to track whether the component changed for the corresponding entities in
|
/// Wraps a [`Component`] to track whether the component changed for the corresponding entities in
|
||||||
@ -1044,10 +1007,12 @@ pub struct ChangeTrackersFetch<'w, T> {
|
|||||||
|
|
||||||
// SAFETY: `ROQueryFetch<Self>` is the same as `QueryFetch<Self>`
|
// SAFETY: `ROQueryFetch<Self>` is the same as `QueryFetch<Self>`
|
||||||
unsafe impl<T: Component> WorldQuery for ChangeTrackers<T> {
|
unsafe impl<T: Component> WorldQuery for ChangeTrackers<T> {
|
||||||
|
type Fetch<'w> = ChangeTrackersFetch<'w, T>;
|
||||||
|
type Item<'w> = ChangeTrackers<T>;
|
||||||
type ReadOnly = Self;
|
type ReadOnly = Self;
|
||||||
type State = ComponentId;
|
type State = ComponentId;
|
||||||
|
|
||||||
fn shrink<'wlong: 'wshort, 'wshort>(item: QueryItem<'wlong, Self>) -> QueryItem<'wshort, Self> {
|
fn shrink<'wlong: 'wshort, 'wshort>(item: Self::Item<'wlong>) -> Self::Item<'wshort> {
|
||||||
item
|
item
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1081,9 +1046,7 @@ unsafe impl<T: Component> WorldQuery for ChangeTrackers<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn clone_fetch<'w>(
|
unsafe fn clone_fetch<'w>(fetch: &Self::Fetch<'w>) -> Self::Fetch<'w> {
|
||||||
fetch: &<Self as WorldQueryGats<'w>>::Fetch,
|
|
||||||
) -> <Self as WorldQueryGats<'w>>::Fetch {
|
|
||||||
ChangeTrackersFetch {
|
ChangeTrackersFetch {
|
||||||
table_ticks: fetch.table_ticks,
|
table_ticks: fetch.table_ticks,
|
||||||
sparse_set: fetch.sparse_set,
|
sparse_set: fetch.sparse_set,
|
||||||
@ -1122,10 +1085,10 @@ unsafe impl<T: Component> WorldQuery for ChangeTrackers<T> {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
unsafe fn fetch<'w>(
|
unsafe fn fetch<'w>(
|
||||||
fetch: &mut <Self as WorldQueryGats<'w>>::Fetch,
|
fetch: &mut Self::Fetch<'w>,
|
||||||
entity: Entity,
|
entity: Entity,
|
||||||
table_row: usize,
|
table_row: usize,
|
||||||
) -> <Self as WorldQueryGats<'w>>::Item {
|
) -> Self::Item<'w> {
|
||||||
match T::Storage::STORAGE_TYPE {
|
match T::Storage::STORAGE_TYPE {
|
||||||
StorageType::Table => ChangeTrackers {
|
StorageType::Table => ChangeTrackers {
|
||||||
component_ticks: {
|
component_ticks: {
|
||||||
@ -1186,28 +1149,18 @@ unsafe impl<T: Component> WorldQuery for ChangeTrackers<T> {
|
|||||||
/// SAFETY: access is read only
|
/// SAFETY: access is read only
|
||||||
unsafe impl<T: Component> ReadOnlyWorldQuery for ChangeTrackers<T> {}
|
unsafe impl<T: Component> ReadOnlyWorldQuery for ChangeTrackers<T> {}
|
||||||
|
|
||||||
impl<'w, T: Component> WorldQueryGats<'w> for ChangeTrackers<T> {
|
|
||||||
type Fetch = ChangeTrackersFetch<'w, T>;
|
|
||||||
type Item = ChangeTrackers<T>;
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! impl_tuple_fetch {
|
macro_rules! impl_tuple_fetch {
|
||||||
($(($name: ident, $state: ident)),*) => {
|
($(($name: ident, $state: ident)),*) => {
|
||||||
#[allow(unused_variables)]
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
impl<'w, $($name: WorldQueryGats<'w>),*> WorldQueryGats<'w> for ($($name,)*) {
|
|
||||||
type Fetch = ($($name::Fetch,)*);
|
|
||||||
type Item = ($($name::Item,)*);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[allow(clippy::unused_unit)]
|
#[allow(clippy::unused_unit)]
|
||||||
// SAFETY: defers to soundness `$name: WorldQuery` impl
|
// SAFETY: defers to soundness `$name: WorldQuery` impl
|
||||||
unsafe impl<$($name: WorldQuery),*> WorldQuery for ($($name,)*) {
|
unsafe impl<$($name: WorldQuery),*> WorldQuery for ($($name,)*) {
|
||||||
|
type Fetch<'w> = ($($name::Fetch<'w>,)*);
|
||||||
|
type Item<'w> = ($($name::Item<'w>,)*);
|
||||||
type ReadOnly = ($($name::ReadOnly,)*);
|
type ReadOnly = ($($name::ReadOnly,)*);
|
||||||
type State = ($($name::State,)*);
|
type State = ($($name::State,)*);
|
||||||
|
|
||||||
fn shrink<'wlong: 'wshort, 'wshort>(item: QueryItem<'wlong, Self>) -> QueryItem<'wshort, Self> {
|
fn shrink<'wlong: 'wshort, 'wshort>(item: Self::Item<'wlong>) -> Self::Item<'wshort> {
|
||||||
let ($($name,)*) = item;
|
let ($($name,)*) = item;
|
||||||
($(
|
($(
|
||||||
$name::shrink($name),
|
$name::shrink($name),
|
||||||
@ -1215,14 +1168,14 @@ macro_rules! impl_tuple_fetch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::unused_unit)]
|
#[allow(clippy::unused_unit)]
|
||||||
unsafe fn init_fetch<'w>(_world: &'w World, state: &Self::State, _last_change_tick: u32, _change_tick: u32) -> <Self as WorldQueryGats<'w>>::Fetch {
|
unsafe fn init_fetch<'w>(_world: &'w World, state: &Self::State, _last_change_tick: u32, _change_tick: u32) -> Self::Fetch<'w> {
|
||||||
let ($($name,)*) = state;
|
let ($($name,)*) = state;
|
||||||
($($name::init_fetch(_world, $name, _last_change_tick, _change_tick),)*)
|
($($name::init_fetch(_world, $name, _last_change_tick, _change_tick),)*)
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn clone_fetch<'w>(
|
unsafe fn clone_fetch<'w>(
|
||||||
fetch: &<Self as WorldQueryGats<'w>>::Fetch,
|
fetch: &Self::Fetch<'w>,
|
||||||
) -> <Self as WorldQueryGats<'w>>::Fetch {
|
) -> Self::Fetch<'w> {
|
||||||
let ($($name,)*) = &fetch;
|
let ($($name,)*) = &fetch;
|
||||||
($($name::clone_fetch($name),)*)
|
($($name::clone_fetch($name),)*)
|
||||||
}
|
}
|
||||||
@ -1233,7 +1186,7 @@ macro_rules! impl_tuple_fetch {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn set_archetype<'w>(
|
unsafe fn set_archetype<'w>(
|
||||||
_fetch: &mut <Self as WorldQueryGats<'w>>::Fetch,
|
_fetch: &mut Self::Fetch<'w>,
|
||||||
_state: &Self::State,
|
_state: &Self::State,
|
||||||
_archetype: &'w Archetype,
|
_archetype: &'w Archetype,
|
||||||
_table: &'w Table
|
_table: &'w Table
|
||||||
@ -1244,7 +1197,7 @@ macro_rules! impl_tuple_fetch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn set_table<'w>(_fetch: &mut <Self as WorldQueryGats<'w>>::Fetch, _state: &Self::State, _table: &'w Table) {
|
unsafe fn set_table<'w>(_fetch: &mut Self::Fetch<'w>, _state: &Self::State, _table: &'w Table) {
|
||||||
let ($($name,)*) = _fetch;
|
let ($($name,)*) = _fetch;
|
||||||
let ($($state,)*) = _state;
|
let ($($state,)*) = _state;
|
||||||
$($name::set_table($name, $state, _table);)*
|
$($name::set_table($name, $state, _table);)*
|
||||||
@ -1253,17 +1206,17 @@ macro_rules! impl_tuple_fetch {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[allow(clippy::unused_unit)]
|
#[allow(clippy::unused_unit)]
|
||||||
unsafe fn fetch<'w>(
|
unsafe fn fetch<'w>(
|
||||||
_fetch: &mut <Self as WorldQueryGats<'w>>::Fetch,
|
_fetch: &mut Self::Fetch<'w>,
|
||||||
_entity: Entity,
|
_entity: Entity,
|
||||||
_table_row: usize
|
_table_row: usize
|
||||||
) -> <Self as WorldQueryGats<'w>>::Item {
|
) -> Self::Item<'w> {
|
||||||
let ($($name,)*) = _fetch;
|
let ($($name,)*) = _fetch;
|
||||||
($($name::fetch($name, _entity, _table_row),)*)
|
($($name::fetch($name, _entity, _table_row),)*)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
unsafe fn filter_fetch<'w>(
|
unsafe fn filter_fetch<'w>(
|
||||||
_fetch: &mut <Self as WorldQueryGats<'w>>::Fetch,
|
_fetch: &mut Self::Fetch<'w>,
|
||||||
_entity: Entity,
|
_entity: Entity,
|
||||||
_table_row: usize
|
_table_row: usize
|
||||||
) -> bool {
|
) -> bool {
|
||||||
@ -1307,21 +1260,16 @@ pub struct AnyOf<T>(PhantomData<T>);
|
|||||||
|
|
||||||
macro_rules! impl_anytuple_fetch {
|
macro_rules! impl_anytuple_fetch {
|
||||||
($(($name: ident, $state: ident)),*) => {
|
($(($name: ident, $state: ident)),*) => {
|
||||||
#[allow(unused_variables)]
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
impl<'w, $($name: WorldQueryGats<'w>),*> WorldQueryGats<'w> for AnyOf<($($name,)*)> {
|
|
||||||
type Fetch = ($(($name::Fetch, bool),)*);
|
|
||||||
type Item = ($(Option<$name::Item>,)*);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[allow(clippy::unused_unit)]
|
#[allow(clippy::unused_unit)]
|
||||||
// SAFETY: defers to soundness of `$name: WorldQuery` impl
|
// SAFETY: defers to soundness of `$name: WorldQuery` impl
|
||||||
unsafe impl<$($name: WorldQuery),*> WorldQuery for AnyOf<($($name,)*)> {
|
unsafe impl<$($name: WorldQuery),*> WorldQuery for AnyOf<($($name,)*)> {
|
||||||
|
type Fetch<'w> = ($(($name::Fetch<'w>, bool),)*);
|
||||||
|
type Item<'w> = ($(Option<$name::Item<'w>>,)*);
|
||||||
type ReadOnly = AnyOf<($($name::ReadOnly,)*)>;
|
type ReadOnly = AnyOf<($($name::ReadOnly,)*)>;
|
||||||
type State = ($($name::State,)*);
|
type State = ($($name::State,)*);
|
||||||
|
|
||||||
fn shrink<'wlong: 'wshort, 'wshort>(item: QueryItem<'wlong, Self>) -> QueryItem<'wshort, Self> {
|
fn shrink<'wlong: 'wshort, 'wshort>(item: Self::Item<'wlong>) -> Self::Item<'wshort> {
|
||||||
let ($($name,)*) = item;
|
let ($($name,)*) = item;
|
||||||
($(
|
($(
|
||||||
$name.map($name::shrink),
|
$name.map($name::shrink),
|
||||||
@ -1329,14 +1277,14 @@ macro_rules! impl_anytuple_fetch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::unused_unit)]
|
#[allow(clippy::unused_unit)]
|
||||||
unsafe fn init_fetch<'w>(_world: &'w World, state: &Self::State, _last_change_tick: u32, _change_tick: u32) -> <Self as WorldQueryGats<'w>>::Fetch {
|
unsafe fn init_fetch<'w>(_world: &'w World, state: &Self::State, _last_change_tick: u32, _change_tick: u32) -> Self::Fetch<'w> {
|
||||||
let ($($name,)*) = state;
|
let ($($name,)*) = state;
|
||||||
($(($name::init_fetch(_world, $name, _last_change_tick, _change_tick), false),)*)
|
($(($name::init_fetch(_world, $name, _last_change_tick, _change_tick), false),)*)
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn clone_fetch<'w>(
|
unsafe fn clone_fetch<'w>(
|
||||||
fetch: &<Self as WorldQueryGats<'w>>::Fetch,
|
fetch: &Self::Fetch<'w>,
|
||||||
) -> <Self as WorldQueryGats<'w>>::Fetch {
|
) -> Self::Fetch<'w> {
|
||||||
let ($($name,)*) = &fetch;
|
let ($($name,)*) = &fetch;
|
||||||
($(($name::clone_fetch(& $name.0), $name.1),)*)
|
($(($name::clone_fetch(& $name.0), $name.1),)*)
|
||||||
}
|
}
|
||||||
@ -1347,7 +1295,7 @@ macro_rules! impl_anytuple_fetch {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn set_archetype<'w>(
|
unsafe fn set_archetype<'w>(
|
||||||
_fetch: &mut <Self as WorldQueryGats<'w>>::Fetch,
|
_fetch: &mut Self::Fetch<'w>,
|
||||||
_state: &Self::State,
|
_state: &Self::State,
|
||||||
_archetype: &'w Archetype,
|
_archetype: &'w Archetype,
|
||||||
_table: &'w Table
|
_table: &'w Table
|
||||||
@ -1363,7 +1311,7 @@ macro_rules! impl_anytuple_fetch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn set_table<'w>(_fetch: &mut <Self as WorldQueryGats<'w>>::Fetch, _state: &Self::State, _table: &'w Table) {
|
unsafe fn set_table<'w>(_fetch: &mut Self::Fetch<'w>, _state: &Self::State, _table: &'w Table) {
|
||||||
let ($($name,)*) = _fetch;
|
let ($($name,)*) = _fetch;
|
||||||
let ($($state,)*) = _state;
|
let ($($state,)*) = _state;
|
||||||
$(
|
$(
|
||||||
@ -1377,10 +1325,10 @@ macro_rules! impl_anytuple_fetch {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
#[allow(clippy::unused_unit)]
|
#[allow(clippy::unused_unit)]
|
||||||
unsafe fn fetch<'w>(
|
unsafe fn fetch<'w>(
|
||||||
_fetch: &mut <Self as WorldQueryGats<'w>>::Fetch,
|
_fetch: &mut Self::Fetch<'w>,
|
||||||
_entity: Entity,
|
_entity: Entity,
|
||||||
_table_row: usize
|
_table_row: usize
|
||||||
) -> <Self as WorldQueryGats<'w>>::Item {
|
) -> Self::Item<'w> {
|
||||||
let ($($name,)*) = _fetch;
|
let ($($name,)*) = _fetch;
|
||||||
($(
|
($(
|
||||||
$name.1.then(|| $name::fetch(&mut $name.0, _entity, _table_row)),
|
$name.1.then(|| $name::fetch(&mut $name.0, _entity, _table_row)),
|
||||||
@ -1455,6 +1403,8 @@ pub struct NopWorldQuery<Q: WorldQuery>(PhantomData<Q>);
|
|||||||
|
|
||||||
/// SAFETY: `Self::ReadOnly` is `Self`
|
/// SAFETY: `Self::ReadOnly` is `Self`
|
||||||
unsafe impl<Q: WorldQuery> WorldQuery for NopWorldQuery<Q> {
|
unsafe impl<Q: WorldQuery> WorldQuery for NopWorldQuery<Q> {
|
||||||
|
type Fetch<'w> = ();
|
||||||
|
type Item<'w> = ();
|
||||||
type ReadOnly = Self;
|
type ReadOnly = Self;
|
||||||
type State = Q::State;
|
type State = Q::State;
|
||||||
|
|
||||||
@ -1473,10 +1423,7 @@ unsafe impl<Q: WorldQuery> WorldQuery for NopWorldQuery<Q> {
|
|||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn clone_fetch<'w>(
|
unsafe fn clone_fetch<'w>(_fetch: &Self::Fetch<'w>) -> Self::Fetch<'w> {}
|
||||||
_fetch: &<Self as WorldQueryGats<'w>>::Fetch,
|
|
||||||
) -> <Self as WorldQueryGats<'w>>::Fetch {
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
unsafe fn set_archetype(
|
unsafe fn set_archetype(
|
||||||
@ -1492,10 +1439,10 @@ unsafe impl<Q: WorldQuery> WorldQuery for NopWorldQuery<Q> {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
unsafe fn fetch<'w>(
|
unsafe fn fetch<'w>(
|
||||||
_fetch: &mut <Self as WorldQueryGats<'w>>::Fetch,
|
_fetch: &mut Self::Fetch<'w>,
|
||||||
_entity: Entity,
|
_entity: Entity,
|
||||||
_table_row: usize,
|
_table_row: usize,
|
||||||
) -> <Self as WorldQueryGats<'w>>::Item {
|
) -> Self::Item<'w> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_component_access(_state: &Q::State, _access: &mut FilteredAccess<ComponentId>) {}
|
fn update_component_access(_state: &Q::State, _access: &mut FilteredAccess<ComponentId>) {}
|
||||||
@ -1519,9 +1466,5 @@ unsafe impl<Q: WorldQuery> WorldQuery for NopWorldQuery<Q> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, Q: WorldQuery> WorldQueryGats<'a> for NopWorldQuery<Q> {
|
|
||||||
type Fetch = ();
|
|
||||||
type Item = ();
|
|
||||||
}
|
|
||||||
/// SAFETY: `NopFetch` never accesses any data
|
/// SAFETY: `NopFetch` never accesses any data
|
||||||
unsafe impl<Q: WorldQuery> ReadOnlyWorldQuery for NopWorldQuery<Q> {}
|
unsafe impl<Q: WorldQuery> ReadOnlyWorldQuery for NopWorldQuery<Q> {}
|
||||||
|
|||||||
@ -2,9 +2,7 @@ use crate::{
|
|||||||
archetype::{Archetype, ArchetypeComponentId},
|
archetype::{Archetype, ArchetypeComponentId},
|
||||||
component::{Component, ComponentId, ComponentStorage, ComponentTicks, StorageType},
|
component::{Component, ComponentId, ComponentStorage, ComponentTicks, StorageType},
|
||||||
entity::Entity,
|
entity::Entity,
|
||||||
query::{
|
query::{debug_checked_unreachable, Access, FilteredAccess, WorldQuery},
|
||||||
debug_checked_unreachable, Access, FilteredAccess, QueryFetch, WorldQuery, WorldQueryGats,
|
|
||||||
},
|
|
||||||
storage::{ComponentSparseSet, Table},
|
storage::{ComponentSparseSet, Table},
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
@ -43,20 +41,14 @@ use super::ReadOnlyWorldQuery;
|
|||||||
/// ```
|
/// ```
|
||||||
pub struct With<T>(PhantomData<T>);
|
pub struct With<T>(PhantomData<T>);
|
||||||
|
|
||||||
impl<T: Component> WorldQueryGats<'_> for With<T> {
|
// SAFETY: `Self::ReadOnly` is the same as `Self`
|
||||||
type Fetch = ();
|
|
||||||
type Item = ();
|
|
||||||
}
|
|
||||||
|
|
||||||
// SAFETY: `ROQueryFetch<Self>` is the same as `QueryFetch<Self>`
|
|
||||||
unsafe impl<T: Component> WorldQuery for With<T> {
|
unsafe impl<T: Component> WorldQuery for With<T> {
|
||||||
|
type Fetch<'w> = ();
|
||||||
|
type Item<'w> = ();
|
||||||
type ReadOnly = Self;
|
type ReadOnly = Self;
|
||||||
type State = ComponentId;
|
type State = ComponentId;
|
||||||
|
|
||||||
fn shrink<'wlong: 'wshort, 'wshort>(
|
fn shrink<'wlong: 'wshort, 'wshort>(_: Self::Item<'wlong>) -> Self::Item<'wshort> {}
|
||||||
_: <Self as WorldQueryGats<'wlong>>::Item,
|
|
||||||
) -> <Self as WorldQueryGats<'wshort>>::Item {
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe fn init_fetch(
|
unsafe fn init_fetch(
|
||||||
_world: &World,
|
_world: &World,
|
||||||
@ -66,10 +58,7 @@ unsafe impl<T: Component> WorldQuery for With<T> {
|
|||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn clone_fetch<'w>(
|
unsafe fn clone_fetch<'w>(_fetch: &Self::Fetch<'w>) -> Self::Fetch<'w> {}
|
||||||
_fetch: &<Self as WorldQueryGats<'w>>::Fetch,
|
|
||||||
) -> <Self as WorldQueryGats<'w>>::Fetch {
|
|
||||||
}
|
|
||||||
|
|
||||||
const IS_DENSE: bool = {
|
const IS_DENSE: bool = {
|
||||||
match T::Storage::STORAGE_TYPE {
|
match T::Storage::STORAGE_TYPE {
|
||||||
@ -94,10 +83,10 @@ unsafe impl<T: Component> WorldQuery for With<T> {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
unsafe fn fetch<'w>(
|
unsafe fn fetch<'w>(
|
||||||
_fetch: &mut <Self as WorldQueryGats<'w>>::Fetch,
|
_fetch: &mut Self::Fetch<'w>,
|
||||||
_entity: Entity,
|
_entity: Entity,
|
||||||
_table_row: usize,
|
_table_row: usize,
|
||||||
) -> <Self as WorldQueryGats<'w>>::Item {
|
) -> Self::Item<'w> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -154,15 +143,14 @@ unsafe impl<T: Component> ReadOnlyWorldQuery for With<T> {}
|
|||||||
/// ```
|
/// ```
|
||||||
pub struct Without<T>(PhantomData<T>);
|
pub struct Without<T>(PhantomData<T>);
|
||||||
|
|
||||||
// SAFETY: `ROQueryFetch<Self>` is the same as `QueryFetch<Self>`
|
// SAFETY: `Self::ReadOnly` is the same as `Self`
|
||||||
unsafe impl<T: Component> WorldQuery for Without<T> {
|
unsafe impl<T: Component> WorldQuery for Without<T> {
|
||||||
|
type Fetch<'w> = ();
|
||||||
|
type Item<'w> = ();
|
||||||
type ReadOnly = Self;
|
type ReadOnly = Self;
|
||||||
type State = ComponentId;
|
type State = ComponentId;
|
||||||
|
|
||||||
fn shrink<'wlong: 'wshort, 'wshort>(
|
fn shrink<'wlong: 'wshort, 'wshort>(_: Self::Item<'wlong>) -> Self::Item<'wshort> {}
|
||||||
_: <Self as WorldQueryGats<'wlong>>::Item,
|
|
||||||
) -> <Self as WorldQueryGats<'wshort>>::Item {
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe fn init_fetch(
|
unsafe fn init_fetch(
|
||||||
_world: &World,
|
_world: &World,
|
||||||
@ -172,10 +160,7 @@ unsafe impl<T: Component> WorldQuery for Without<T> {
|
|||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn clone_fetch<'w>(
|
unsafe fn clone_fetch<'w>(_fetch: &Self::Fetch<'w>) -> Self::Fetch<'w> {}
|
||||||
_fetch: &<Self as WorldQueryGats<'w>>::Fetch,
|
|
||||||
) -> <Self as WorldQueryGats<'w>>::Fetch {
|
|
||||||
}
|
|
||||||
|
|
||||||
const IS_DENSE: bool = {
|
const IS_DENSE: bool = {
|
||||||
match T::Storage::STORAGE_TYPE {
|
match T::Storage::STORAGE_TYPE {
|
||||||
@ -200,10 +185,10 @@ unsafe impl<T: Component> WorldQuery for Without<T> {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
unsafe fn fetch<'w>(
|
unsafe fn fetch<'w>(
|
||||||
_fetch: &mut <Self as WorldQueryGats<'w>>::Fetch,
|
_fetch: &mut Self::Fetch<'w>,
|
||||||
_entity: Entity,
|
_entity: Entity,
|
||||||
_table_row: usize,
|
_table_row: usize,
|
||||||
) -> <Self as WorldQueryGats<'w>>::Item {
|
) -> Self::Item<'w> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -231,11 +216,6 @@ unsafe impl<T: Component> WorldQuery for Without<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Component> WorldQueryGats<'_> for Without<T> {
|
|
||||||
type Fetch = ();
|
|
||||||
type Item = ();
|
|
||||||
}
|
|
||||||
|
|
||||||
// SAFETY: no component access or archetype component access
|
// SAFETY: no component access or archetype component access
|
||||||
unsafe impl<T: Component> ReadOnlyWorldQuery for Without<T> {}
|
unsafe impl<T: Component> ReadOnlyWorldQuery for Without<T> {}
|
||||||
|
|
||||||
@ -273,29 +253,23 @@ pub struct Or<T>(pub T);
|
|||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub struct OrFetch<'w, T: WorldQuery> {
|
pub struct OrFetch<'w, T: WorldQuery> {
|
||||||
fetch: QueryFetch<'w, T>,
|
fetch: T::Fetch<'w>,
|
||||||
matches: bool,
|
matches: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! impl_query_filter_tuple {
|
macro_rules! impl_query_filter_tuple {
|
||||||
($(($filter: ident, $state: ident)),*) => {
|
($(($filter: ident, $state: ident)),*) => {
|
||||||
#[allow(unused_variables)]
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
impl<'w, $($filter: WorldQuery),*> WorldQueryGats<'w> for Or<($($filter,)*)> {
|
|
||||||
type Fetch = ($(OrFetch<'w, $filter>,)*);
|
|
||||||
type Item = bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[allow(clippy::unused_unit)]
|
#[allow(clippy::unused_unit)]
|
||||||
// SAFETY: defers to soundness of `$filter: WorldQuery` impl
|
// SAFETY: defers to soundness of `$filter: WorldQuery` impl
|
||||||
unsafe impl<$($filter: WorldQuery),*> WorldQuery for Or<($($filter,)*)> {
|
unsafe impl<$($filter: WorldQuery),*> WorldQuery for Or<($($filter,)*)> {
|
||||||
|
type Fetch<'w> = ($(OrFetch<'w, $filter>,)*);
|
||||||
|
type Item<'w> = bool;
|
||||||
type ReadOnly = Or<($($filter::ReadOnly,)*)>;
|
type ReadOnly = Or<($($filter::ReadOnly,)*)>;
|
||||||
type State = ($($filter::State,)*);
|
type State = ($($filter::State,)*);
|
||||||
|
|
||||||
fn shrink<'wlong: 'wshort, 'wshort>(item: super::QueryItem<'wlong, Self>) -> super::QueryItem<'wshort, Self> {
|
fn shrink<'wlong: 'wshort, 'wshort>(item: Self::Item<'wlong>) -> Self::Item<'wshort> {
|
||||||
item
|
item
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,7 +277,7 @@ macro_rules! impl_query_filter_tuple {
|
|||||||
|
|
||||||
const IS_ARCHETYPAL: bool = true $(&& $filter::IS_ARCHETYPAL)*;
|
const IS_ARCHETYPAL: bool = true $(&& $filter::IS_ARCHETYPAL)*;
|
||||||
|
|
||||||
unsafe fn init_fetch<'w>(world: &'w World, state: &Self::State, last_change_tick: u32, change_tick: u32) -> <Self as WorldQueryGats<'w>>::Fetch {
|
unsafe fn init_fetch<'w>(world: &'w World, state: &Self::State, last_change_tick: u32, change_tick: u32) -> Self::Fetch<'w> {
|
||||||
let ($($filter,)*) = state;
|
let ($($filter,)*) = state;
|
||||||
($(OrFetch {
|
($(OrFetch {
|
||||||
fetch: $filter::init_fetch(world, $filter, last_change_tick, change_tick),
|
fetch: $filter::init_fetch(world, $filter, last_change_tick, change_tick),
|
||||||
@ -312,8 +286,8 @@ macro_rules! impl_query_filter_tuple {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn clone_fetch<'w>(
|
unsafe fn clone_fetch<'w>(
|
||||||
fetch: &<Self as WorldQueryGats<'w>>::Fetch,
|
fetch: &Self::Fetch<'w>,
|
||||||
) -> <Self as WorldQueryGats<'w>>::Fetch {
|
) -> Self::Fetch<'w> {
|
||||||
let ($($filter,)*) = &fetch;
|
let ($($filter,)*) = &fetch;
|
||||||
($(
|
($(
|
||||||
OrFetch {
|
OrFetch {
|
||||||
@ -324,7 +298,7 @@ macro_rules! impl_query_filter_tuple {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn set_table<'w>(fetch: &mut <Self as WorldQueryGats<'w>>::Fetch, state: &Self::State, table: &'w Table) {
|
unsafe fn set_table<'w>(fetch: &mut Self::Fetch<'w>, state: &Self::State, table: &'w Table) {
|
||||||
let ($($filter,)*) = fetch;
|
let ($($filter,)*) = fetch;
|
||||||
let ($($state,)*) = state;
|
let ($($state,)*) = state;
|
||||||
$(
|
$(
|
||||||
@ -337,7 +311,7 @@ macro_rules! impl_query_filter_tuple {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn set_archetype<'w>(
|
unsafe fn set_archetype<'w>(
|
||||||
fetch: &mut <Self as WorldQueryGats<'w>>::Fetch,
|
fetch: &mut Self::Fetch<'w>,
|
||||||
state: & Self::State,
|
state: & Self::State,
|
||||||
archetype: &'w Archetype,
|
archetype: &'w Archetype,
|
||||||
table: &'w Table
|
table: &'w Table
|
||||||
@ -354,17 +328,17 @@ macro_rules! impl_query_filter_tuple {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
unsafe fn fetch<'w>(
|
unsafe fn fetch<'w>(
|
||||||
fetch: &mut <Self as WorldQueryGats<'w>>::Fetch,
|
fetch: &mut Self::Fetch<'w>,
|
||||||
_entity: Entity,
|
_entity: Entity,
|
||||||
_table_row: usize
|
_table_row: usize
|
||||||
) -> <Self as WorldQueryGats<'w>>::Item {
|
) -> Self::Item<'w> {
|
||||||
let ($($filter,)*) = fetch;
|
let ($($filter,)*) = fetch;
|
||||||
false $(|| ($filter.matches && $filter::filter_fetch(&mut $filter.fetch, _entity, _table_row)))*
|
false $(|| ($filter.matches && $filter::filter_fetch(&mut $filter.fetch, _entity, _table_row)))*
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
unsafe fn filter_fetch<'w>(
|
unsafe fn filter_fetch<'w>(
|
||||||
fetch: &mut <Self as WorldQueryGats<'w>>::Fetch,
|
fetch: &mut Self::Fetch<'w>,
|
||||||
entity: Entity,
|
entity: Entity,
|
||||||
table_row: usize
|
table_row: usize
|
||||||
) -> bool {
|
) -> bool {
|
||||||
@ -446,17 +420,19 @@ macro_rules! impl_tick_filter {
|
|||||||
change_tick: u32,
|
change_tick: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
// SAFETY: `ROQueryFetch<Self>` is the same as `QueryFetch<Self>`
|
// SAFETY: `Self::ReadOnly` is the same as `Self`
|
||||||
unsafe impl<T: Component> WorldQuery for $name<T> {
|
unsafe impl<T: Component> WorldQuery for $name<T> {
|
||||||
|
type Fetch<'w> = $fetch_name<'w, T>;
|
||||||
|
type Item<'w> = bool;
|
||||||
type ReadOnly = Self;
|
type ReadOnly = Self;
|
||||||
type State = ComponentId;
|
type State = ComponentId;
|
||||||
|
|
||||||
fn shrink<'wlong: 'wshort, 'wshort>(item: super::QueryItem<'wlong, Self>) -> super::QueryItem<'wshort, Self> {
|
fn shrink<'wlong: 'wshort, 'wshort>(item: Self::Item<'wlong>) -> Self::Item<'wshort> {
|
||||||
item
|
item
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn init_fetch<'w>(world: &'w World, &id: &ComponentId, last_change_tick: u32, change_tick: u32) -> <Self as WorldQueryGats<'w>>::Fetch {
|
unsafe fn init_fetch<'w>(world: &'w World, &id: &ComponentId, last_change_tick: u32, change_tick: u32) -> Self::Fetch<'w> {
|
||||||
QueryFetch::<'w, Self> {
|
Self::Fetch::<'w> {
|
||||||
table_ticks: None,
|
table_ticks: None,
|
||||||
sparse_set: (T::Storage::STORAGE_TYPE == StorageType::SparseSet)
|
sparse_set: (T::Storage::STORAGE_TYPE == StorageType::SparseSet)
|
||||||
.then(|| {
|
.then(|| {
|
||||||
@ -472,8 +448,8 @@ macro_rules! impl_tick_filter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn clone_fetch<'w>(
|
unsafe fn clone_fetch<'w>(
|
||||||
fetch: &<Self as WorldQueryGats<'w>>::Fetch,
|
fetch: &Self::Fetch<'w>,
|
||||||
) -> <Self as WorldQueryGats<'w>>::Fetch {
|
) -> Self::Fetch<'w> {
|
||||||
$fetch_name {
|
$fetch_name {
|
||||||
table_ticks: fetch.table_ticks,
|
table_ticks: fetch.table_ticks,
|
||||||
sparse_set: fetch.sparse_set,
|
sparse_set: fetch.sparse_set,
|
||||||
@ -494,7 +470,7 @@ macro_rules! impl_tick_filter {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn set_table<'w>(
|
unsafe fn set_table<'w>(
|
||||||
fetch: &mut <Self as WorldQueryGats<'w>>::Fetch,
|
fetch: &mut Self::Fetch<'w>,
|
||||||
&component_id: &ComponentId,
|
&component_id: &ComponentId,
|
||||||
table: &'w Table
|
table: &'w Table
|
||||||
) {
|
) {
|
||||||
@ -508,7 +484,7 @@ macro_rules! impl_tick_filter {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn set_archetype<'w>(
|
unsafe fn set_archetype<'w>(
|
||||||
fetch: &mut <Self as WorldQueryGats<'w>>::Fetch,
|
fetch: &mut Self::Fetch<'w>,
|
||||||
component_id: &ComponentId,
|
component_id: &ComponentId,
|
||||||
_archetype: &'w Archetype,
|
_archetype: &'w Archetype,
|
||||||
table: &'w Table
|
table: &'w Table
|
||||||
@ -520,10 +496,10 @@ macro_rules! impl_tick_filter {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
unsafe fn fetch<'w>(
|
unsafe fn fetch<'w>(
|
||||||
fetch: &mut <Self as WorldQueryGats<'w>>::Fetch,
|
fetch: &mut Self::Fetch<'w>,
|
||||||
entity: Entity,
|
entity: Entity,
|
||||||
table_row: usize
|
table_row: usize
|
||||||
) -> <Self as WorldQueryGats<'w>>::Item {
|
) -> Self::Item<'w> {
|
||||||
match T::Storage::STORAGE_TYPE {
|
match T::Storage::STORAGE_TYPE {
|
||||||
StorageType::Table => {
|
StorageType::Table => {
|
||||||
$is_detected(&*(
|
$is_detected(&*(
|
||||||
@ -549,7 +525,7 @@ macro_rules! impl_tick_filter {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
unsafe fn filter_fetch<'w>(
|
unsafe fn filter_fetch<'w>(
|
||||||
fetch: &mut QueryFetch<'w, Self>,
|
fetch: &mut Self::Fetch<'w>,
|
||||||
entity: Entity,
|
entity: Entity,
|
||||||
table_row: usize
|
table_row: usize
|
||||||
) -> bool {
|
) -> bool {
|
||||||
@ -585,11 +561,6 @@ macro_rules! impl_tick_filter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'w, T: Component> WorldQueryGats<'w> for $name<T> {
|
|
||||||
type Fetch = $fetch_name<'w, T>;
|
|
||||||
type Item = bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// SAFETY: read-only access
|
/// SAFETY: read-only access
|
||||||
unsafe impl<T: Component> ReadOnlyWorldQuery for $name<T> {}
|
unsafe impl<T: Component> ReadOnlyWorldQuery for $name<T> {}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -7,7 +7,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use std::{borrow::Borrow, iter::FusedIterator, marker::PhantomData, mem::MaybeUninit};
|
use std::{borrow::Borrow, iter::FusedIterator, marker::PhantomData, mem::MaybeUninit};
|
||||||
|
|
||||||
use super::{QueryFetch, QueryItem, ReadOnlyWorldQuery};
|
use super::ReadOnlyWorldQuery;
|
||||||
|
|
||||||
/// An [`Iterator`] over query results of a [`Query`](crate::system::Query).
|
/// An [`Iterator`] over query results of a [`Query`](crate::system::Query).
|
||||||
///
|
///
|
||||||
@ -42,7 +42,7 @@ impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> QueryIter<'w, 's, Q, F> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> Iterator for QueryIter<'w, 's, Q, F> {
|
impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> Iterator for QueryIter<'w, 's, Q, F> {
|
||||||
type Item = QueryItem<'w, Q>;
|
type Item = Q::Item<'w>;
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
@ -86,8 +86,8 @@ where
|
|||||||
entities: &'w Entities,
|
entities: &'w Entities,
|
||||||
tables: &'w Tables,
|
tables: &'w Tables,
|
||||||
archetypes: &'w Archetypes,
|
archetypes: &'w Archetypes,
|
||||||
fetch: QueryFetch<'w, Q>,
|
fetch: Q::Fetch<'w>,
|
||||||
filter: QueryFetch<'w, F>,
|
filter: F::Fetch<'w>,
|
||||||
query_state: &'s QueryState<Q, F>,
|
query_state: &'s QueryState<Q, F>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ where
|
|||||||
///
|
///
|
||||||
/// It is always safe for shared access.
|
/// It is always safe for shared access.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
unsafe fn fetch_next_aliased_unchecked(&mut self) -> Option<QueryItem<'w, Q>> {
|
unsafe fn fetch_next_aliased_unchecked(&mut self) -> Option<Q::Item<'w>> {
|
||||||
for entity in self.entity_iter.by_ref() {
|
for entity in self.entity_iter.by_ref() {
|
||||||
let entity = *entity.borrow();
|
let entity = *entity.borrow();
|
||||||
let location = match self.entities.get(entity) {
|
let location = match self.entities.get(entity) {
|
||||||
@ -186,7 +186,7 @@ where
|
|||||||
|
|
||||||
/// Get next result from the query
|
/// Get next result from the query
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn fetch_next(&mut self) -> Option<QueryItem<'_, Q>> {
|
pub fn fetch_next(&mut self) -> Option<Q::Item<'_>> {
|
||||||
// SAFETY: we are limiting the returned reference to self,
|
// SAFETY: we are limiting the returned reference to self,
|
||||||
// making sure this method cannot be called multiple times without getting rid
|
// making sure this method cannot be called multiple times without getting rid
|
||||||
// of any previously returned unique references first, thus preventing aliasing.
|
// of any previously returned unique references first, thus preventing aliasing.
|
||||||
@ -199,7 +199,7 @@ impl<'w, 's, Q: ReadOnlyWorldQuery, F: ReadOnlyWorldQuery, I: Iterator> Iterator
|
|||||||
where
|
where
|
||||||
I::Item: Borrow<Entity>,
|
I::Item: Borrow<Entity>,
|
||||||
{
|
{
|
||||||
type Item = QueryItem<'w, Q>;
|
type Item = Q::Item<'w>;
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
@ -343,7 +343,7 @@ impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery, const K: usize>
|
|||||||
/// references to the same component, leading to unique reference aliasing.
|
/// references to the same component, leading to unique reference aliasing.
|
||||||
///.
|
///.
|
||||||
/// It is always safe for shared access.
|
/// It is always safe for shared access.
|
||||||
unsafe fn fetch_next_aliased_unchecked(&mut self) -> Option<[QueryItem<'w, Q>; K]> {
|
unsafe fn fetch_next_aliased_unchecked(&mut self) -> Option<[Q::Item<'w>; K]> {
|
||||||
if K == 0 {
|
if K == 0 {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
@ -368,9 +368,9 @@ impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery, const K: usize>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut values = MaybeUninit::<[QueryItem<'w, Q>; K]>::uninit();
|
let mut values = MaybeUninit::<[Q::Item<'w>; K]>::uninit();
|
||||||
|
|
||||||
let ptr = values.as_mut_ptr().cast::<QueryItem<'w, Q>>();
|
let ptr = values.as_mut_ptr().cast::<Q::Item<'w>>();
|
||||||
for (offset, cursor) in self.cursors.iter_mut().enumerate() {
|
for (offset, cursor) in self.cursors.iter_mut().enumerate() {
|
||||||
ptr.add(offset).write(cursor.peek_last().unwrap());
|
ptr.add(offset).write(cursor.peek_last().unwrap());
|
||||||
}
|
}
|
||||||
@ -380,7 +380,7 @@ impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery, const K: usize>
|
|||||||
|
|
||||||
/// Get next combination of queried components
|
/// Get next combination of queried components
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn fetch_next(&mut self) -> Option<[QueryItem<'_, Q>; K]> {
|
pub fn fetch_next(&mut self) -> Option<[Q::Item<'_>; K]> {
|
||||||
// SAFETY: we are limiting the returned reference to self,
|
// SAFETY: we are limiting the returned reference to self,
|
||||||
// making sure this method cannot be called multiple times without getting rid
|
// making sure this method cannot be called multiple times without getting rid
|
||||||
// of any previously returned unique references first, thus preventing aliasing.
|
// of any previously returned unique references first, thus preventing aliasing.
|
||||||
@ -397,7 +397,7 @@ impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery, const K: usize>
|
|||||||
impl<'w, 's, Q: ReadOnlyWorldQuery, F: ReadOnlyWorldQuery, const K: usize> Iterator
|
impl<'w, 's, Q: ReadOnlyWorldQuery, F: ReadOnlyWorldQuery, const K: usize> Iterator
|
||||||
for QueryCombinationIter<'w, 's, Q, F, K>
|
for QueryCombinationIter<'w, 's, Q, F, K>
|
||||||
{
|
{
|
||||||
type Item = [QueryItem<'w, Q>; K];
|
type Item = [Q::Item<'w>; K];
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
@ -468,8 +468,8 @@ struct QueryIterationCursor<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> {
|
|||||||
archetype_id_iter: std::slice::Iter<'s, ArchetypeId>,
|
archetype_id_iter: std::slice::Iter<'s, ArchetypeId>,
|
||||||
table_entities: &'w [Entity],
|
table_entities: &'w [Entity],
|
||||||
archetype_entities: &'w [ArchetypeEntity],
|
archetype_entities: &'w [ArchetypeEntity],
|
||||||
fetch: QueryFetch<'w, Q>,
|
fetch: Q::Fetch<'w>,
|
||||||
filter: QueryFetch<'w, F>,
|
filter: F::Fetch<'w>,
|
||||||
// length of the table table or length of the archetype, depending on whether both `Q`'s and `F`'s fetches are dense
|
// length of the table table or length of the archetype, depending on whether both `Q`'s and `F`'s fetches are dense
|
||||||
current_len: usize,
|
current_len: usize,
|
||||||
// either table row or archetype index, depending on whether both `Q`'s and `F`'s fetches are dense
|
// either table row or archetype index, depending on whether both `Q`'s and `F`'s fetches are dense
|
||||||
@ -549,7 +549,7 @@ impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> QueryIterationCursor<'w, 's,
|
|||||||
|
|
||||||
/// retrieve item returned from most recent `next` call again.
|
/// retrieve item returned from most recent `next` call again.
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn peek_last(&mut self) -> Option<QueryItem<'w, Q>> {
|
unsafe fn peek_last(&mut self) -> Option<Q::Item<'w>> {
|
||||||
if self.current_index > 0 {
|
if self.current_index > 0 {
|
||||||
let index = self.current_index - 1;
|
let index = self.current_index - 1;
|
||||||
if Self::IS_DENSE {
|
if Self::IS_DENSE {
|
||||||
@ -580,7 +580,7 @@ impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> QueryIterationCursor<'w, 's,
|
|||||||
tables: &'w Tables,
|
tables: &'w Tables,
|
||||||
archetypes: &'w Archetypes,
|
archetypes: &'w Archetypes,
|
||||||
query_state: &'s QueryState<Q, F>,
|
query_state: &'s QueryState<Q, F>,
|
||||||
) -> Option<QueryItem<'w, Q>> {
|
) -> Option<Q::Item<'w>> {
|
||||||
if Self::IS_DENSE {
|
if Self::IS_DENSE {
|
||||||
loop {
|
loop {
|
||||||
// we are on the beginning of the query, or finished processing a table, so skip to the next
|
// we are on the beginning of the query, or finished processing a table, so skip to the next
|
||||||
|
|||||||
@ -13,7 +13,7 @@ use bevy_utils::tracing::Instrument;
|
|||||||
use fixedbitset::FixedBitSet;
|
use fixedbitset::FixedBitSet;
|
||||||
use std::{borrow::Borrow, fmt, mem::MaybeUninit};
|
use std::{borrow::Borrow, fmt, mem::MaybeUninit};
|
||||||
|
|
||||||
use super::{NopWorldQuery, QueryItem, QueryManyIter, ROQueryItem, ReadOnlyWorldQuery};
|
use super::{NopWorldQuery, QueryManyIter, ROQueryItem, ReadOnlyWorldQuery};
|
||||||
|
|
||||||
/// Provides scoped access to a [`World`] state according to a given [`WorldQuery`] and query filter.
|
/// Provides scoped access to a [`World`] state according to a given [`WorldQuery`] and query filter.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
@ -272,7 +272,7 @@ impl<Q: WorldQuery, F: ReadOnlyWorldQuery> QueryState<Q, F> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
world: &'w mut World,
|
world: &'w mut World,
|
||||||
entity: Entity,
|
entity: Entity,
|
||||||
) -> Result<QueryItem<'w, Q>, QueryEntityError> {
|
) -> Result<Q::Item<'w>, QueryEntityError> {
|
||||||
self.update_archetypes(world);
|
self.update_archetypes(world);
|
||||||
// SAFETY: query has unique world access
|
// SAFETY: query has unique world access
|
||||||
unsafe {
|
unsafe {
|
||||||
@ -328,7 +328,7 @@ impl<Q: WorldQuery, F: ReadOnlyWorldQuery> QueryState<Q, F> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
world: &'w mut World,
|
world: &'w mut World,
|
||||||
entities: [Entity; N],
|
entities: [Entity; N],
|
||||||
) -> Result<[QueryItem<'w, Q>; N], QueryEntityError> {
|
) -> Result<[Q::Item<'w>; N], QueryEntityError> {
|
||||||
self.update_archetypes(world);
|
self.update_archetypes(world);
|
||||||
|
|
||||||
// SAFETY: method requires exclusive world access
|
// SAFETY: method requires exclusive world access
|
||||||
@ -372,7 +372,7 @@ impl<Q: WorldQuery, F: ReadOnlyWorldQuery> QueryState<Q, F> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
world: &'w World,
|
world: &'w World,
|
||||||
entity: Entity,
|
entity: Entity,
|
||||||
) -> Result<QueryItem<'w, Q>, QueryEntityError> {
|
) -> Result<Q::Item<'w>, QueryEntityError> {
|
||||||
self.update_archetypes(world);
|
self.update_archetypes(world);
|
||||||
self.get_unchecked_manual(
|
self.get_unchecked_manual(
|
||||||
world,
|
world,
|
||||||
@ -398,7 +398,7 @@ impl<Q: WorldQuery, F: ReadOnlyWorldQuery> QueryState<Q, F> {
|
|||||||
entity: Entity,
|
entity: Entity,
|
||||||
last_change_tick: u32,
|
last_change_tick: u32,
|
||||||
change_tick: u32,
|
change_tick: u32,
|
||||||
) -> Result<QueryItem<'w, Q>, QueryEntityError> {
|
) -> Result<Q::Item<'w>, QueryEntityError> {
|
||||||
let location = world
|
let location = world
|
||||||
.entities
|
.entities
|
||||||
.get(entity)
|
.get(entity)
|
||||||
@ -472,7 +472,7 @@ impl<Q: WorldQuery, F: ReadOnlyWorldQuery> QueryState<Q, F> {
|
|||||||
entities: [Entity; N],
|
entities: [Entity; N],
|
||||||
last_change_tick: u32,
|
last_change_tick: u32,
|
||||||
change_tick: u32,
|
change_tick: u32,
|
||||||
) -> Result<[QueryItem<'w, Q>; N], QueryEntityError> {
|
) -> Result<[Q::Item<'w>; N], QueryEntityError> {
|
||||||
// Verify that all entities are unique
|
// Verify that all entities are unique
|
||||||
for i in 0..N {
|
for i in 0..N {
|
||||||
for j in 0..i {
|
for j in 0..i {
|
||||||
@ -786,11 +786,7 @@ impl<Q: WorldQuery, F: ReadOnlyWorldQuery> QueryState<Q, F> {
|
|||||||
/// Runs `func` on each query result for the given [`World`]. This is faster than the equivalent
|
/// Runs `func` on each query result for the given [`World`]. This is faster than the equivalent
|
||||||
/// `iter_mut()` method, but cannot be chained like a normal [`Iterator`].
|
/// `iter_mut()` method, but cannot be chained like a normal [`Iterator`].
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn for_each_mut<'w, FN: FnMut(QueryItem<'w, Q>)>(
|
pub fn for_each_mut<'w, FN: FnMut(Q::Item<'w>)>(&mut self, world: &'w mut World, func: FN) {
|
||||||
&mut self,
|
|
||||||
world: &'w mut World,
|
|
||||||
func: FN,
|
|
||||||
) {
|
|
||||||
// SAFETY: query has unique world access
|
// SAFETY: query has unique world access
|
||||||
unsafe {
|
unsafe {
|
||||||
self.update_archetypes(world);
|
self.update_archetypes(world);
|
||||||
@ -813,7 +809,7 @@ impl<Q: WorldQuery, F: ReadOnlyWorldQuery> QueryState<Q, F> {
|
|||||||
/// This does not check for mutable query correctness. To be safe, make sure mutable queries
|
/// This does not check for mutable query correctness. To be safe, make sure mutable queries
|
||||||
/// have unique access to the components they query.
|
/// have unique access to the components they query.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn for_each_unchecked<'w, FN: FnMut(QueryItem<'w, Q>)>(
|
pub unsafe fn for_each_unchecked<'w, FN: FnMut(Q::Item<'w>)>(
|
||||||
&mut self,
|
&mut self,
|
||||||
world: &'w World,
|
world: &'w World,
|
||||||
func: FN,
|
func: FN,
|
||||||
@ -861,7 +857,7 @@ impl<Q: WorldQuery, F: ReadOnlyWorldQuery> QueryState<Q, F> {
|
|||||||
/// The [`ComputeTaskPool`] is not initialized. If using this from a query that is being
|
/// The [`ComputeTaskPool`] is not initialized. If using this from a query that is being
|
||||||
/// initialized and run from the ECS scheduler, this should never panic.
|
/// initialized and run from the ECS scheduler, this should never panic.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn par_for_each_mut<'w, FN: Fn(QueryItem<'w, Q>) + Send + Sync + Clone>(
|
pub fn par_for_each_mut<'w, FN: Fn(Q::Item<'w>) + Send + Sync + Clone>(
|
||||||
&mut self,
|
&mut self,
|
||||||
world: &'w mut World,
|
world: &'w mut World,
|
||||||
batch_size: usize,
|
batch_size: usize,
|
||||||
@ -893,7 +889,7 @@ impl<Q: WorldQuery, F: ReadOnlyWorldQuery> QueryState<Q, F> {
|
|||||||
/// This does not check for mutable query correctness. To be safe, make sure mutable queries
|
/// This does not check for mutable query correctness. To be safe, make sure mutable queries
|
||||||
/// have unique access to the components they query.
|
/// have unique access to the components they query.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn par_for_each_unchecked<'w, FN: Fn(QueryItem<'w, Q>) + Send + Sync + Clone>(
|
pub unsafe fn par_for_each_unchecked<'w, FN: Fn(Q::Item<'w>) + Send + Sync + Clone>(
|
||||||
&mut self,
|
&mut self,
|
||||||
world: &'w World,
|
world: &'w World,
|
||||||
batch_size: usize,
|
batch_size: usize,
|
||||||
@ -919,7 +915,7 @@ impl<Q: WorldQuery, F: ReadOnlyWorldQuery> QueryState<Q, F> {
|
|||||||
/// have unique access to the components they query.
|
/// have unique access to the components they query.
|
||||||
/// This does not validate that `world.id()` matches `self.world_id`. Calling this on a `world`
|
/// This does not validate that `world.id()` matches `self.world_id`. Calling this on a `world`
|
||||||
/// with a mismatched [`WorldId`] is unsound.
|
/// with a mismatched [`WorldId`] is unsound.
|
||||||
pub(crate) unsafe fn for_each_unchecked_manual<'w, FN: FnMut(QueryItem<'w, Q>)>(
|
pub(crate) unsafe fn for_each_unchecked_manual<'w, FN: FnMut(Q::Item<'w>)>(
|
||||||
&self,
|
&self,
|
||||||
world: &'w World,
|
world: &'w World,
|
||||||
mut func: FN,
|
mut func: FN,
|
||||||
@ -991,7 +987,7 @@ impl<Q: WorldQuery, F: ReadOnlyWorldQuery> QueryState<Q, F> {
|
|||||||
/// with a mismatched [`WorldId`] is unsound.
|
/// with a mismatched [`WorldId`] is unsound.
|
||||||
pub(crate) unsafe fn par_for_each_unchecked_manual<
|
pub(crate) unsafe fn par_for_each_unchecked_manual<
|
||||||
'w,
|
'w,
|
||||||
FN: Fn(QueryItem<'w, Q>) + Send + Sync + Clone,
|
FN: Fn(Q::Item<'w>) + Send + Sync + Clone,
|
||||||
>(
|
>(
|
||||||
&self,
|
&self,
|
||||||
world: &'w World,
|
world: &'w World,
|
||||||
@ -1171,7 +1167,7 @@ impl<Q: WorldQuery, F: ReadOnlyWorldQuery> QueryState<Q, F> {
|
|||||||
/// [`get_single_mut`](Self::get_single_mut) to return a `Result` instead of panicking.
|
/// [`get_single_mut`](Self::get_single_mut) to return a `Result` instead of panicking.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn single_mut<'w>(&mut self, world: &'w mut World) -> QueryItem<'w, Q> {
|
pub fn single_mut<'w>(&mut self, world: &'w mut World) -> Q::Item<'w> {
|
||||||
// SAFETY: query has unique world access
|
// SAFETY: query has unique world access
|
||||||
self.get_single_mut(world).unwrap()
|
self.get_single_mut(world).unwrap()
|
||||||
}
|
}
|
||||||
@ -1185,7 +1181,7 @@ impl<Q: WorldQuery, F: ReadOnlyWorldQuery> QueryState<Q, F> {
|
|||||||
pub fn get_single_mut<'w>(
|
pub fn get_single_mut<'w>(
|
||||||
&mut self,
|
&mut self,
|
||||||
world: &'w mut World,
|
world: &'w mut World,
|
||||||
) -> Result<QueryItem<'w, Q>, QuerySingleError> {
|
) -> Result<Q::Item<'w>, QuerySingleError> {
|
||||||
self.update_archetypes(world);
|
self.update_archetypes(world);
|
||||||
|
|
||||||
// SAFETY: query has unique world access
|
// SAFETY: query has unique world access
|
||||||
@ -1211,7 +1207,7 @@ impl<Q: WorldQuery, F: ReadOnlyWorldQuery> QueryState<Q, F> {
|
|||||||
pub unsafe fn get_single_unchecked<'w>(
|
pub unsafe fn get_single_unchecked<'w>(
|
||||||
&mut self,
|
&mut self,
|
||||||
world: &'w World,
|
world: &'w World,
|
||||||
) -> Result<QueryItem<'w, Q>, QuerySingleError> {
|
) -> Result<Q::Item<'w>, QuerySingleError> {
|
||||||
self.update_archetypes(world);
|
self.update_archetypes(world);
|
||||||
self.get_single_unchecked_manual(world, world.last_change_tick(), world.read_change_tick())
|
self.get_single_unchecked_manual(world, world.last_change_tick(), world.read_change_tick())
|
||||||
}
|
}
|
||||||
@ -1232,7 +1228,7 @@ impl<Q: WorldQuery, F: ReadOnlyWorldQuery> QueryState<Q, F> {
|
|||||||
world: &'w World,
|
world: &'w World,
|
||||||
last_change_tick: u32,
|
last_change_tick: u32,
|
||||||
change_tick: u32,
|
change_tick: u32,
|
||||||
) -> Result<QueryItem<'w, Q>, QuerySingleError> {
|
) -> Result<Q::Item<'w>, QuerySingleError> {
|
||||||
let mut query = self.iter_unchecked_manual(world, last_change_tick, change_tick);
|
let mut query = self.iter_unchecked_manual(world, last_change_tick, change_tick);
|
||||||
let first = query.next();
|
let first = query.next();
|
||||||
let extra = query.next().is_some();
|
let extra = query.next().is_some();
|
||||||
|
|||||||
@ -2,8 +2,8 @@ use crate::{
|
|||||||
component::Component,
|
component::Component,
|
||||||
entity::Entity,
|
entity::Entity,
|
||||||
query::{
|
query::{
|
||||||
QueryCombinationIter, QueryEntityError, QueryItem, QueryIter, QueryManyIter,
|
QueryCombinationIter, QueryEntityError, QueryIter, QueryManyIter, QuerySingleError,
|
||||||
QuerySingleError, QueryState, ROQueryItem, ReadOnlyWorldQuery, WorldQuery,
|
QueryState, ROQueryItem, ReadOnlyWorldQuery, WorldQuery,
|
||||||
},
|
},
|
||||||
world::{Mut, World},
|
world::{Mut, World},
|
||||||
};
|
};
|
||||||
@ -712,7 +712,7 @@ impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> Query<'w, 's, Q, F> {
|
|||||||
/// - [`for_each`](Self::for_each) to operate on read-only query items.
|
/// - [`for_each`](Self::for_each) to operate on read-only query items.
|
||||||
/// - [`iter_mut`](Self::iter_mut) for the iterator based alternative.
|
/// - [`iter_mut`](Self::iter_mut) for the iterator based alternative.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn for_each_mut<'a>(&'a mut self, f: impl FnMut(QueryItem<'a, Q>)) {
|
pub fn for_each_mut<'a>(&'a mut self, f: impl FnMut(Q::Item<'a>)) {
|
||||||
// SAFETY: system runs without conflicts with other systems. same-system queries have runtime
|
// SAFETY: system runs without conflicts with other systems. same-system queries have runtime
|
||||||
// borrow checks when they conflict
|
// borrow checks when they conflict
|
||||||
unsafe {
|
unsafe {
|
||||||
@ -786,7 +786,7 @@ impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> Query<'w, 's, Q, F> {
|
|||||||
pub fn par_for_each_mut<'a>(
|
pub fn par_for_each_mut<'a>(
|
||||||
&'a mut self,
|
&'a mut self,
|
||||||
batch_size: usize,
|
batch_size: usize,
|
||||||
f: impl Fn(QueryItem<'a, Q>) + Send + Sync + Clone,
|
f: impl Fn(Q::Item<'a>) + Send + Sync + Clone,
|
||||||
) {
|
) {
|
||||||
// SAFETY: system runs without conflicts with other systems. same-system queries have runtime
|
// SAFETY: system runs without conflicts with other systems. same-system queries have runtime
|
||||||
// borrow checks when they conflict
|
// borrow checks when they conflict
|
||||||
@ -945,7 +945,7 @@ impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> Query<'w, 's, Q, F> {
|
|||||||
///
|
///
|
||||||
/// - [`get`](Self::get) to get a read-only query item.
|
/// - [`get`](Self::get) to get a read-only query item.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_mut(&mut self, entity: Entity) -> Result<QueryItem<'_, Q>, QueryEntityError> {
|
pub fn get_mut(&mut self, entity: Entity) -> Result<Q::Item<'_>, QueryEntityError> {
|
||||||
// SAFETY: system runs without conflicts with other systems.
|
// SAFETY: system runs without conflicts with other systems.
|
||||||
// same-system queries have runtime borrow checks when they conflict
|
// same-system queries have runtime borrow checks when they conflict
|
||||||
unsafe {
|
unsafe {
|
||||||
@ -970,7 +970,7 @@ impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> Query<'w, 's, Q, F> {
|
|||||||
pub fn get_many_mut<const N: usize>(
|
pub fn get_many_mut<const N: usize>(
|
||||||
&mut self,
|
&mut self,
|
||||||
entities: [Entity; N],
|
entities: [Entity; N],
|
||||||
) -> Result<[QueryItem<'_, Q>; N], QueryEntityError> {
|
) -> Result<[Q::Item<'_>; N], QueryEntityError> {
|
||||||
// SAFETY: scheduler ensures safe Query world access
|
// SAFETY: scheduler ensures safe Query world access
|
||||||
unsafe {
|
unsafe {
|
||||||
self.state.get_many_unchecked_manual(
|
self.state.get_many_unchecked_manual(
|
||||||
@ -1031,7 +1031,7 @@ impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> Query<'w, 's, Q, F> {
|
|||||||
/// - [`get_many_mut`](Self::get_many_mut) for the non panicking version.
|
/// - [`get_many_mut`](Self::get_many_mut) for the non panicking version.
|
||||||
/// - [`many`](Self::many) to get read-only query items.
|
/// - [`many`](Self::many) to get read-only query items.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn many_mut<const N: usize>(&mut self, entities: [Entity; N]) -> [QueryItem<'_, Q>; N] {
|
pub fn many_mut<const N: usize>(&mut self, entities: [Entity; N]) -> [Q::Item<'_>; N] {
|
||||||
self.get_many_mut(entities).unwrap()
|
self.get_many_mut(entities).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1048,10 +1048,7 @@ impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> Query<'w, 's, Q, F> {
|
|||||||
///
|
///
|
||||||
/// - [`get_mut`](Self::get_mut) for the safe version.
|
/// - [`get_mut`](Self::get_mut) for the safe version.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn get_unchecked(
|
pub unsafe fn get_unchecked(&self, entity: Entity) -> Result<Q::Item<'_>, QueryEntityError> {
|
||||||
&self,
|
|
||||||
entity: Entity,
|
|
||||||
) -> Result<QueryItem<'_, Q>, QueryEntityError> {
|
|
||||||
// SEMI-SAFETY: system runs without conflicts with other systems.
|
// SEMI-SAFETY: system runs without conflicts with other systems.
|
||||||
// same-system queries have runtime borrow checks when they conflict
|
// same-system queries have runtime borrow checks when they conflict
|
||||||
self.state
|
self.state
|
||||||
@ -1302,7 +1299,7 @@ impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> Query<'w, 's, Q, F> {
|
|||||||
/// - [`get_single_mut`](Self::get_single_mut) for the non-panicking version.
|
/// - [`get_single_mut`](Self::get_single_mut) for the non-panicking version.
|
||||||
/// - [`single`](Self::single) to get the read-only query item.
|
/// - [`single`](Self::single) to get the read-only query item.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn single_mut(&mut self) -> QueryItem<'_, Q> {
|
pub fn single_mut(&mut self) -> Q::Item<'_> {
|
||||||
self.get_single_mut().unwrap()
|
self.get_single_mut().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1332,7 +1329,7 @@ impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> Query<'w, 's, Q, F> {
|
|||||||
/// - [`get_single`](Self::get_single) to get the read-only query item.
|
/// - [`get_single`](Self::get_single) to get the read-only query item.
|
||||||
/// - [`single_mut`](Self::single_mut) for the panicking version.
|
/// - [`single_mut`](Self::single_mut) for the panicking version.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_single_mut(&mut self) -> Result<QueryItem<'_, Q>, QuerySingleError> {
|
pub fn get_single_mut(&mut self) -> Result<Q::Item<'_>, QuerySingleError> {
|
||||||
// SAFETY:
|
// SAFETY:
|
||||||
// the query ensures mutable access to the components it accesses, and the query
|
// the query ensures mutable access to the components it accesses, and the query
|
||||||
// is uniquely borrowed
|
// is uniquely borrowed
|
||||||
@ -1415,7 +1412,7 @@ impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> IntoIterator for &'w Query<'_
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> IntoIterator for &'w mut Query<'_, 's, Q, F> {
|
impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> IntoIterator for &'w mut Query<'_, 's, Q, F> {
|
||||||
type Item = QueryItem<'w, Q>;
|
type Item = Q::Item<'w>;
|
||||||
type IntoIter = QueryIter<'w, 's, Q, F>;
|
type IntoIter = QueryIter<'w, 's, Q, F>;
|
||||||
|
|
||||||
fn into_iter(self) -> Self::IntoIter {
|
fn into_iter(self) -> Self::IntoIter {
|
||||||
|
|||||||
@ -2,7 +2,7 @@ use std::collections::VecDeque;
|
|||||||
|
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
entity::Entity,
|
entity::Entity,
|
||||||
query::{ReadOnlyWorldQuery, WorldQuery, WorldQueryGats},
|
query::{ReadOnlyWorldQuery, WorldQuery},
|
||||||
system::Query,
|
system::Query,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ pub trait HierarchyQueryExt<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> {
|
|||||||
/// ```
|
/// ```
|
||||||
fn iter_descendants(&'w self, entity: Entity) -> DescendantIter<'w, 's, Q, F>
|
fn iter_descendants(&'w self, entity: Entity) -> DescendantIter<'w, 's, Q, F>
|
||||||
where
|
where
|
||||||
Q::ReadOnly: WorldQueryGats<'w, Item = &'w Children>;
|
Q::ReadOnly: WorldQuery<Item<'w> = &'w Children>;
|
||||||
|
|
||||||
/// Returns an [`Iterator`] of [`Entity`]s over all of `entity`s ancestors.
|
/// Returns an [`Iterator`] of [`Entity`]s over all of `entity`s ancestors.
|
||||||
///
|
///
|
||||||
@ -54,7 +54,7 @@ pub trait HierarchyQueryExt<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> {
|
|||||||
/// ```
|
/// ```
|
||||||
fn iter_ancestors(&'w self, entity: Entity) -> AncestorIter<'w, 's, Q, F>
|
fn iter_ancestors(&'w self, entity: Entity) -> AncestorIter<'w, 's, Q, F>
|
||||||
where
|
where
|
||||||
Q::ReadOnly: WorldQueryGats<'w, Item = &'w Parent>;
|
Q::ReadOnly: WorldQuery<Item<'w> = &'w Parent>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> HierarchyQueryExt<'w, 's, Q, F>
|
impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> HierarchyQueryExt<'w, 's, Q, F>
|
||||||
@ -62,14 +62,14 @@ impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> HierarchyQueryExt<'w, 's, Q,
|
|||||||
{
|
{
|
||||||
fn iter_descendants(&'w self, entity: Entity) -> DescendantIter<'w, 's, Q, F>
|
fn iter_descendants(&'w self, entity: Entity) -> DescendantIter<'w, 's, Q, F>
|
||||||
where
|
where
|
||||||
Q::ReadOnly: WorldQueryGats<'w, Item = &'w Children>,
|
Q::ReadOnly: WorldQuery<Item<'w> = &'w Children>,
|
||||||
{
|
{
|
||||||
DescendantIter::new(self, entity)
|
DescendantIter::new(self, entity)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn iter_ancestors(&'w self, entity: Entity) -> AncestorIter<'w, 's, Q, F>
|
fn iter_ancestors(&'w self, entity: Entity) -> AncestorIter<'w, 's, Q, F>
|
||||||
where
|
where
|
||||||
Q::ReadOnly: WorldQueryGats<'w, Item = &'w Parent>,
|
Q::ReadOnly: WorldQuery<Item<'w> = &'w Parent>,
|
||||||
{
|
{
|
||||||
AncestorIter::new(self, entity)
|
AncestorIter::new(self, entity)
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> HierarchyQueryExt<'w, 's, Q,
|
|||||||
/// Traverses the hierarchy breadth-first.
|
/// Traverses the hierarchy breadth-first.
|
||||||
pub struct DescendantIter<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery>
|
pub struct DescendantIter<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery>
|
||||||
where
|
where
|
||||||
Q::ReadOnly: WorldQueryGats<'w, Item = &'w Children>,
|
Q::ReadOnly: WorldQuery<Item<'w> = &'w Children>,
|
||||||
{
|
{
|
||||||
children_query: &'w Query<'w, 's, Q, F>,
|
children_query: &'w Query<'w, 's, Q, F>,
|
||||||
vecdeque: VecDeque<Entity>,
|
vecdeque: VecDeque<Entity>,
|
||||||
@ -88,7 +88,7 @@ where
|
|||||||
|
|
||||||
impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> DescendantIter<'w, 's, Q, F>
|
impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> DescendantIter<'w, 's, Q, F>
|
||||||
where
|
where
|
||||||
Q::ReadOnly: WorldQueryGats<'w, Item = &'w Children>,
|
Q::ReadOnly: WorldQuery<Item<'w> = &'w Children>,
|
||||||
{
|
{
|
||||||
/// Returns a new [`DescendantIter`].
|
/// Returns a new [`DescendantIter`].
|
||||||
pub fn new(children_query: &'w Query<'w, 's, Q, F>, entity: Entity) -> Self {
|
pub fn new(children_query: &'w Query<'w, 's, Q, F>, entity: Entity) -> Self {
|
||||||
@ -106,7 +106,7 @@ where
|
|||||||
|
|
||||||
impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> Iterator for DescendantIter<'w, 's, Q, F>
|
impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> Iterator for DescendantIter<'w, 's, Q, F>
|
||||||
where
|
where
|
||||||
Q::ReadOnly: WorldQueryGats<'w, Item = &'w Children>,
|
Q::ReadOnly: WorldQuery<Item<'w> = &'w Children>,
|
||||||
{
|
{
|
||||||
type Item = Entity;
|
type Item = Entity;
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ where
|
|||||||
/// An [`Iterator`] of [`Entity`]s over the ancestors of an [`Entity`].
|
/// An [`Iterator`] of [`Entity`]s over the ancestors of an [`Entity`].
|
||||||
pub struct AncestorIter<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery>
|
pub struct AncestorIter<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery>
|
||||||
where
|
where
|
||||||
Q::ReadOnly: WorldQueryGats<'w, Item = &'w Parent>,
|
Q::ReadOnly: WorldQuery<Item<'w> = &'w Parent>,
|
||||||
{
|
{
|
||||||
parent_query: &'w Query<'w, 's, Q, F>,
|
parent_query: &'w Query<'w, 's, Q, F>,
|
||||||
next: Option<Entity>,
|
next: Option<Entity>,
|
||||||
@ -132,7 +132,7 @@ where
|
|||||||
|
|
||||||
impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> AncestorIter<'w, 's, Q, F>
|
impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> AncestorIter<'w, 's, Q, F>
|
||||||
where
|
where
|
||||||
Q::ReadOnly: WorldQueryGats<'w, Item = &'w Parent>,
|
Q::ReadOnly: WorldQuery<Item<'w> = &'w Parent>,
|
||||||
{
|
{
|
||||||
/// Returns a new [`AncestorIter`].
|
/// Returns a new [`AncestorIter`].
|
||||||
pub fn new(parent_query: &'w Query<'w, 's, Q, F>, entity: Entity) -> Self {
|
pub fn new(parent_query: &'w Query<'w, 's, Q, F>, entity: Entity) -> Self {
|
||||||
@ -145,7 +145,7 @@ where
|
|||||||
|
|
||||||
impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> Iterator for AncestorIter<'w, 's, Q, F>
|
impl<'w, 's, Q: WorldQuery, F: ReadOnlyWorldQuery> Iterator for AncestorIter<'w, 's, Q, F>
|
||||||
where
|
where
|
||||||
Q::ReadOnly: WorldQueryGats<'w, Item = &'w Parent>,
|
Q::ReadOnly: WorldQuery<Item<'w> = &'w Parent>,
|
||||||
{
|
{
|
||||||
type Item = Entity;
|
type Item = Entity;
|
||||||
|
|
||||||
|
|||||||
@ -38,7 +38,7 @@ pub trait ExtractComponent: Component {
|
|||||||
/// Filters the entities with additional constraints.
|
/// Filters the entities with additional constraints.
|
||||||
type Filter: WorldQuery + ReadOnlyWorldQuery;
|
type Filter: WorldQuery + ReadOnlyWorldQuery;
|
||||||
/// Defines how the component is transferred into the "render world".
|
/// Defines how the component is transferred into the "render world".
|
||||||
fn extract_component(item: QueryItem<Self::Query>) -> Self;
|
fn extract_component(item: QueryItem<'_, Self::Query>) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This plugin prepares the components of the corresponding type for the GPU
|
/// This plugin prepares the components of the corresponding type for the GPU
|
||||||
@ -174,7 +174,7 @@ impl<T: Asset> ExtractComponent for Handle<T> {
|
|||||||
type Filter = ();
|
type Filter = ();
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn extract_component(handle: QueryItem<Self::Query>) -> Self {
|
fn extract_component(handle: QueryItem<'_, Self::Query>) -> Self {
|
||||||
handle.clone_weak()
|
handle.clone_weak()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -266,7 +266,7 @@ impl ExtractComponent for UiCameraConfig {
|
|||||||
type Query = &'static Self;
|
type Query = &'static Self;
|
||||||
type Filter = With<Camera>;
|
type Filter = With<Camera>;
|
||||||
|
|
||||||
fn extract_component(item: QueryItem<Self::Query>) -> Self {
|
fn extract_component(item: QueryItem<'_, Self::Query>) -> Self {
|
||||||
item.clone()
|
item.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,10 @@
|
|||||||
|
|
||||||
use bevy::{
|
use bevy::{
|
||||||
core_pipeline::core_3d::Transparent3d,
|
core_pipeline::core_3d::Transparent3d,
|
||||||
ecs::system::{lifetimeless::*, SystemParamItem},
|
ecs::{
|
||||||
|
query::QueryItem,
|
||||||
|
system::{lifetimeless::*, SystemParamItem},
|
||||||
|
},
|
||||||
pbr::{MeshPipeline, MeshPipelineKey, MeshUniform, SetMeshBindGroup, SetMeshViewBindGroup},
|
pbr::{MeshPipeline, MeshPipelineKey, MeshUniform, SetMeshBindGroup, SetMeshViewBindGroup},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
render::{
|
render::{
|
||||||
@ -67,7 +70,7 @@ impl ExtractComponent for InstanceMaterialData {
|
|||||||
type Query = &'static InstanceMaterialData;
|
type Query = &'static InstanceMaterialData;
|
||||||
type Filter = ();
|
type Filter = ();
|
||||||
|
|
||||||
fn extract_component(item: bevy::ecs::query::QueryItem<Self::Query>) -> Self {
|
fn extract_component(item: QueryItem<'_, Self::Query>) -> Self {
|
||||||
InstanceMaterialData(item.0.clone())
|
InstanceMaterialData(item.0.clone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user