pub struct SpatialQuery<'w, 's> {
pub query_pipeline: ResMut<'w, SpatialQueryPipeline>,
/* private fields */
}
Expand description
A system parameter for performing spatial queries.
§Methods
- Raycasting:
cast_ray
,cast_ray_predicate
,ray_hits
,ray_hits_callback
- Shapecasting:
cast_shape
,cast_shape_predicate
,shape_hits
,shape_hits_callback
- Point projection:
project_point
andproject_point_predicate
- Intersection tests
- Point intersections:
point_intersections
,point_intersections_callback
- AABB intersections:
aabb_intersections_with_aabb
,aabb_intersections_with_aabb_callback
- Shape intersections:
shape_intersections
shape_intersections_callback
- Point intersections:
For simple raycasts and shapecasts, consider using the RayCaster
and ShapeCaster
components that
provide a more ECS-based approach and perform casts on every frame.
§Example
use avian3d::prelude::*;
use bevy::prelude::*;
fn print_hits(spatial_query: SpatialQuery) {
// Ray origin and direction
let origin = Vec3::ZERO;
let direction = Dir3::X;
// Configuration for the ray cast
let max_distance = 100.0;
let solid = true;
let filter = SpatialQueryFilter::default();
// Cast ray and print first hit
if let Some(first_hit) = spatial_query.cast_ray(origin, direction, max_distance, solid, &filter) {
println!("First hit: {:?}", first_hit);
}
// Cast ray and get up to 20 hits
let hits = spatial_query.ray_hits(origin, direction, max_distance, 20, solid, &filter);
// Print hits
for hit in hits.iter() {
println!("Hit: {:?}", hit);
}
}
Fields§
§query_pipeline: ResMut<'w, SpatialQueryPipeline>
The SpatialQueryPipeline
.
Implementations§
source§impl SpatialQuery<'_, '_>
impl SpatialQuery<'_, '_>
sourcepub fn update_pipeline(&mut self)
pub fn update_pipeline(&mut self)
Updates the colliders in the pipeline. This is done automatically once per physics frame in
PhysicsStepSet::SpatialQuery
, but if you modify colliders or their positions before that, you can
call this to make sure the data is up to date when performing spatial queries using SpatialQuery
.
sourcepub fn cast_ray(
&self,
origin: Vector,
direction: Dir3,
max_distance: Scalar,
solid: bool,
filter: &SpatialQueryFilter,
) -> Option<RayHitData>
pub fn cast_ray( &self, origin: Vector, direction: Dir3, max_distance: Scalar, solid: bool, filter: &SpatialQueryFilter, ) -> Option<RayHitData>
Casts a ray and computes the closest hit with a collider.
If there are no hits, None
is returned.
§Arguments
origin
: Where the ray is cast from.direction
: What direction the ray is cast in.max_distance
: The maximum distance the ray can travel.solid
: If true and the ray origin is inside of a collider, the hit point will be the ray origin itself. Otherwise, the collider will be treated as hollow, and the hit point will be at its boundary.filter
: ASpatialQueryFilter
that determines which entities are included in the cast.
§Example
use avian3d::prelude::*;
use bevy::prelude::*;
fn print_hits(spatial_query: SpatialQuery) {
// Ray origin and direction
let origin = Vec3::ZERO;
let direction = Dir3::X;
// Configuration for the ray cast
let max_distance = 100.0;
let solid = true;
let filter = SpatialQueryFilter::default();
// Cast ray and print first hit
if let Some(first_hit) = spatial_query.cast_ray(origin, direction, max_distance, solid, &filter) {
println!("First hit: {:?}", first_hit);
}
}
§Related Methods
sourcepub fn cast_ray_predicate(
&self,
origin: Vector,
direction: Dir3,
max_distance: Scalar,
solid: bool,
filter: &SpatialQueryFilter,
predicate: &dyn Fn(Entity) -> bool,
) -> Option<RayHitData>
pub fn cast_ray_predicate( &self, origin: Vector, direction: Dir3, max_distance: Scalar, solid: bool, filter: &SpatialQueryFilter, predicate: &dyn Fn(Entity) -> bool, ) -> Option<RayHitData>
Casts a ray and computes the closest hit with a collider.
If there are no hits, None
is returned.
§Arguments
origin
: Where the ray is cast from.direction
: What direction the ray is cast in.max_distance
: The maximum distance the ray can travel.solid
: If true and the ray origin is inside of a collider, the hit point will be the ray origin itself. Otherwise, the collider will be treated as hollow, and the hit point will be at its boundary.filter
: ASpatialQueryFilter
that determines which entities are included in the cast.predicate
: A function called on each entity hit by the ray. The ray keeps travelling until the predicate returnsfalse
.
§Example
use avian3d::prelude::*;
use bevy::prelude::*;
#[derive(Component)]
struct Invisible;
fn print_hits(spatial_query: SpatialQuery, query: Query<&Invisible>) {
// Ray origin and direction
let origin = Vec3::ZERO;
let direction = Dir3::X;
// Configuration for the ray cast
let max_distance = 100.0;
let solid = true;
let filter = SpatialQueryFilter::default();
// Cast ray and get the first hit that matches the predicate
let hit = spatial_query.cast_ray_predicate(origin, direction, max_distance, solid, &filter, &|entity| {
// Skip entities with the `Invisible` component.
!query.contains(entity)
});
// Print first hit
if let Some(first_hit) = hit {
println!("First hit: {:?}", first_hit);
}
}
§Related Methods
sourcepub fn ray_hits(
&self,
origin: Vector,
direction: Dir3,
max_distance: Scalar,
max_hits: u32,
solid: bool,
filter: &SpatialQueryFilter,
) -> Vec<RayHitData>
pub fn ray_hits( &self, origin: Vector, direction: Dir3, max_distance: Scalar, max_hits: u32, solid: bool, filter: &SpatialQueryFilter, ) -> Vec<RayHitData>
Casts a ray and computes all hits until max_hits
is reached.
Note that the order of the results is not guaranteed, and if there are more hits than max_hits
,
some hits will be missed.
§Arguments
origin
: Where the ray is cast from.direction
: What direction the ray is cast in.max_distance
: The maximum distance the ray can travel.max_hits
: The maximum number of hits. Additional hits will be missed.solid
: If true and the ray origin is inside of a collider, the hit point will be the ray origin itself. Otherwise, the collider will be treated as hollow, and the hit point will be at its boundary.filter
: ASpatialQueryFilter
that determines which entities are included in the cast.
§Example
use avian3d::prelude::*;
use bevy::prelude::*;
fn print_hits(spatial_query: SpatialQuery) {
// Ray origin and direction
let origin = Vec3::ZERO;
let direction = Dir3::X;
// Configuration for the ray cast
let max_distance = 100.0;
let solid = true;
let filter = SpatialQueryFilter::default();
// Cast ray and get up to 20 hits
let hits = spatial_query.ray_hits(origin, direction, max_distance, 20, solid, &filter);
// Print hits
for hit in hits.iter() {
println!("Hit: {:?}", hit);
}
}
§Related Methods
sourcepub fn ray_hits_callback(
&self,
origin: Vector,
direction: Dir3,
max_distance: Scalar,
solid: bool,
filter: &SpatialQueryFilter,
callback: impl FnMut(RayHitData) -> bool,
)
pub fn ray_hits_callback( &self, origin: Vector, direction: Dir3, max_distance: Scalar, solid: bool, filter: &SpatialQueryFilter, callback: impl FnMut(RayHitData) -> bool, )
Casts a ray and computes all hits, calling the given callback
for each hit. The raycast stops when callback
returns false or all hits have been found.
Note that the order of the results is not guaranteed.
§Arguments
origin
: Where the ray is cast from.direction
: What direction the ray is cast in.max_distance
: The maximum distance the ray can travel.solid
: If true and the ray origin is inside of a collider, the hit point will be the ray origin itself. Otherwise, the collider will be treated as hollow, and the hit point will be at its boundary.filter
: ASpatialQueryFilter
that determines which entities are included in the cast.callback
: A callback function called for each hit.
§Example
use avian3d::prelude::*;
use bevy::prelude::*;
fn print_hits(spatial_query: SpatialQuery) {
// Ray origin and direction
let origin = Vec3::ZERO;
let direction = Dir3::X;
// Configuration for the ray cast
let max_distance = 100.0;
let solid = true;
let filter = SpatialQueryFilter::default();
// Cast ray and get all hits
let mut hits = vec![];
spatial_query.ray_hits_callback(origin, direction, max_distance, 20, solid, &filter, |hit| {
hits.push(hit);
true
});
// Print hits
for hit in hits.iter() {
println!("Hit: {:?}", hit);
}
}
§Related Methods
sourcepub fn cast_shape(
&self,
shape: &Collider,
origin: Vector,
shape_rotation: Quaternion,
direction: Dir3,
config: &ShapeCastConfig,
filter: &SpatialQueryFilter,
) -> Option<ShapeHitData>
pub fn cast_shape( &self, shape: &Collider, origin: Vector, shape_rotation: Quaternion, direction: Dir3, config: &ShapeCastConfig, filter: &SpatialQueryFilter, ) -> Option<ShapeHitData>
Casts a shape with a given rotation and computes the closest hit
with a collider. If there are no hits, None
is returned.
For a more ECS-based approach, consider using the ShapeCaster
component instead.
§Arguments
shape
: The shape being cast represented as aCollider
.origin
: Where the shape is cast from.shape_rotation
: The rotation of the shape being cast.direction
: What direction the shape is cast in.config
: AShapeCastConfig
that determines the behavior of the cast.filter
: ASpatialQueryFilter
that determines which entities are included in the cast.
§Example
use avian3d::prelude::*;
use bevy::prelude::*;
fn print_hits(spatial_query: SpatialQuery) {
// Shape properties
let shape = Collider::sphere(0.5);
let origin = Vec3::ZERO;
let rotation = Quat::default();
let direction = Dir3::X;
// Configuration for the shape cast
let config = ShapeCastConfig::from_max_distance(100.0);
let filter = SpatialQueryFilter::default();
// Cast shape and print first hit
if let Some(first_hit) = spatial_query.cast_shape(&shape, origin, rotation, direction, &config, &filter)
{
println!("First hit: {:?}", first_hit);
}
}
§Related Methods
sourcepub fn cast_shape_predicate(
&self,
shape: &Collider,
origin: Vector,
shape_rotation: Quaternion,
direction: Dir3,
config: &ShapeCastConfig,
filter: &SpatialQueryFilter,
predicate: &dyn Fn(Entity) -> bool,
) -> Option<ShapeHitData>
pub fn cast_shape_predicate( &self, shape: &Collider, origin: Vector, shape_rotation: Quaternion, direction: Dir3, config: &ShapeCastConfig, filter: &SpatialQueryFilter, predicate: &dyn Fn(Entity) -> bool, ) -> Option<ShapeHitData>
Casts a shape with a given rotation and computes the closest hit
with a collider. If there are no hits, None
is returned.
For a more ECS-based approach, consider using the ShapeCaster
component instead.
§Arguments
shape
: The shape being cast represented as aCollider
.origin
: Where the shape is cast from.shape_rotation
: The rotation of the shape being cast.direction
: What direction the shape is cast in.config
: AShapeCastConfig
that determines the behavior of the cast.filter
: ASpatialQueryFilter
that determines which entities are included in the cast.predicate
: A function called on each entity hit by the shape. The shape keeps travelling until the predicate returnsfalse
.
§Example
use avian3d::prelude::*;
use bevy::prelude::*;
#[derive(Component)]
struct Invisible;
fn print_hits(spatial_query: SpatialQuery, query: Query<&Invisible>) {
// Shape properties
let shape = Collider::sphere(0.5);
let origin = Vec3::ZERO;
let rotation = Quat::default();
let direction = Dir3::X;
// Configuration for the shape cast
let config = ShapeCastConfig::from_max_distance(100.0);
let filter = SpatialQueryFilter::default();
// Cast shape and get the first hit that matches the predicate
let hit = spatial_query.cast_shape(&shape, origin, rotation, direction, &config, &filter, &|entity| {
// Skip entities with the `Invisible` component.
!query.contains(entity)
});
// Print first hit
if let Some(first_hit) = hit {
println!("First hit: {:?}", first_hit);
}
}
§Related Methods
sourcepub fn shape_hits(
&self,
shape: &Collider,
origin: Vector,
shape_rotation: Quaternion,
direction: Dir3,
max_hits: u32,
config: &ShapeCastConfig,
filter: &SpatialQueryFilter,
) -> Vec<ShapeHitData>
pub fn shape_hits( &self, shape: &Collider, origin: Vector, shape_rotation: Quaternion, direction: Dir3, max_hits: u32, config: &ShapeCastConfig, filter: &SpatialQueryFilter, ) -> Vec<ShapeHitData>
Casts a shape with a given rotation and computes computes all hits
in the order of distance until max_hits
is reached.
§Arguments
shape
: The shape being cast represented as aCollider
.origin
: Where the shape is cast from.shape_rotation
: The rotation of the shape being cast.direction
: What direction the shape is cast in.max_hits
: The maximum number of hits. Additional hits will be missed.config
: AShapeCastConfig
that determines the behavior of the cast.filter
: ASpatialQueryFilter
that determines which entities are included in the cast.callback
: A callback function called for each hit.
§Example
use avian3d::prelude::*;
use bevy::prelude::*;
fn print_hits(spatial_query: SpatialQuery) {
// Shape properties
let shape = Collider::sphere(0.5);
let origin = Vec3::ZERO;
let rotation = Quat::default();
let direction = Dir3::X;
// Configuration for the shape cast
let config = ShapeCastConfig::from_max_distance(100.0);
let filter = SpatialQueryFilter::default();
// Cast shape and get up to 20 hits
let hits = spatial_query.cast_shape(&shape, origin, rotation, direction, 20, &config, &filter);
// Print hits
for hit in hits.iter() {
println!("Hit: {:?}", hit);
}
}
§Related Methods
sourcepub fn shape_hits_callback(
&self,
shape: &Collider,
origin: Vector,
shape_rotation: Quaternion,
direction: Dir3,
config: &ShapeCastConfig,
filter: &SpatialQueryFilter,
callback: impl FnMut(ShapeHitData) -> bool,
)
pub fn shape_hits_callback( &self, shape: &Collider, origin: Vector, shape_rotation: Quaternion, direction: Dir3, config: &ShapeCastConfig, filter: &SpatialQueryFilter, callback: impl FnMut(ShapeHitData) -> bool, )
Casts a shape with a given rotation and computes computes all hits
in the order of distance, calling the given callback
for each hit. The shapecast stops when
callback
returns false or all hits have been found.
§Arguments
shape
: The shape being cast represented as aCollider
.origin
: Where the shape is cast from.shape_rotation
: The rotation of the shape being cast.direction
: What direction the shape is cast in.config
: AShapeCastConfig
that determines the behavior of the cast.filter
: ASpatialQueryFilter
that determines which entities are included in the cast.callback
: A callback function called for each hit.
§Example
use avian3d::prelude::*;
use bevy::prelude::*;
fn print_hits(spatial_query: SpatialQuery) {
// Shape properties
let shape = Collider::sphere(0.5);
let origin = Vec3::ZERO;
let rotation = Quat::default();
let direction = Dir3::X;
// Configuration for the shape cast
let config = ShapeCastConfig::from_max_distance(100.0);
let filter = SpatialQueryFilter::default();
// Cast shape and get up to 20 hits
let mut hits = vec![];
spatial_query.shape_hits_callback(&shape, origin, rotation, direction, 20, &config, &filter, |hit| {
hits.push(hit);
true
});
// Print hits
for hit in hits.iter() {
println!("Hit: {:?}", hit);
}
}
§Related Methods
sourcepub fn project_point(
&self,
point: Vector,
solid: bool,
filter: &SpatialQueryFilter,
) -> Option<PointProjection>
pub fn project_point( &self, point: Vector, solid: bool, filter: &SpatialQueryFilter, ) -> Option<PointProjection>
Finds the projection of a given point on the closest collider.
If one isn’t found, None
is returned.
§Arguments
point
: The point that should be projected.solid
: If true and the point is inside of a collider, the projection will be at the point. Otherwise, the collider will be treated as hollow, and the projection will be at the collider’s boundary.query_filter
: ASpatialQueryFilter
that determines which colliders are taken into account in the query.
§Example
use avian3d::prelude::*;
use bevy::prelude::*;
fn print_point_projection(spatial_query: SpatialQuery) {
// Project a point and print the result
if let Some(projection) = spatial_query.project_point(
Vec3::ZERO, // Point
true, // Are colliders treated as "solid"
&SpatialQueryFilter::default(),// Query filter
) {
println!("Projection: {:?}", projection);
}
}
§Related Methods
sourcepub fn project_point_predicate(
&self,
point: Vector,
solid: bool,
filter: &SpatialQueryFilter,
predicate: &dyn Fn(Entity) -> bool,
) -> Option<PointProjection>
pub fn project_point_predicate( &self, point: Vector, solid: bool, filter: &SpatialQueryFilter, predicate: &dyn Fn(Entity) -> bool, ) -> Option<PointProjection>
Finds the projection of a given point on the closest collider.
If one isn’t found, None
is returned.
§Arguments
point
: The point that should be projected.solid
: If true and the point is inside of a collider, the projection will be at the point. Otherwise, the collider will be treated as hollow, and the projection will be at the collider’s boundary.filter
: ASpatialQueryFilter
that determines which colliders are taken into account in the query.predicate
: A function for filtering which entities are considered in the query. The projection will be on the closest collider that passes the predicate.
§Example
use avian3d::prelude::*;
use bevy::prelude::*;
#[derive(Component)]
struct Invisible;
fn print_point_projection(spatial_query: SpatialQuery, query: Query<&Invisible>) {
// Project a point and print the result
if let Some(projection) = spatial_query.project_point_predicate(
Vec3::ZERO, // Point
true, // Are colliders treated as "solid"
SpatialQueryFilter::default(), // Query filter
&|entity| { // Predicate
// Skip entities with the `Invisible` component.
!query.contains(entity)
}
) {
println!("Projection: {:?}", projection);
}
}
§Related Methods
sourcepub fn point_intersections(
&self,
point: Vector,
filter: &SpatialQueryFilter,
) -> Vec<Entity>
pub fn point_intersections( &self, point: Vector, filter: &SpatialQueryFilter, ) -> Vec<Entity>
An intersection test that finds all entities with a collider that contains the given point.
§Arguments
point
: The point that intersections are tested against.filter
: ASpatialQueryFilter
that determines which colliders are taken into account in the query.
§Example
use avian3d::prelude::*;
use bevy::prelude::*;
fn print_point_intersections(spatial_query: SpatialQuery) {
let intersections =
spatial_query.point_intersections(Vec3::ZERO, &SpatialQueryFilter::default());
for entity in intersections.iter() {
println!("Entity: {}", entity);
}
}
§Related Methods
sourcepub fn point_intersections_callback(
&self,
point: Vector,
filter: &SpatialQueryFilter,
callback: impl FnMut(Entity) -> bool,
)
pub fn point_intersections_callback( &self, point: Vector, filter: &SpatialQueryFilter, callback: impl FnMut(Entity) -> bool, )
An intersection test that finds all entities with a collider
that contains the given point, calling the given callback
for each intersection.
The search stops when callback
returns false
or all intersections have been found.
§Arguments
point
: The point that intersections are tested against.filter
: ASpatialQueryFilter
that determines which colliders are taken into account in the query.callback
: A callback function called for each intersection.
§Example
use avian3d::prelude::*;
use bevy::prelude::*;
fn print_point_intersections(spatial_query: SpatialQuery) {
let mut intersections = vec![];
spatial_query.point_intersections_callback(
Vec3::ZERO, // Point
&SpatialQueryFilter::default(), // Query filter
|entity| { // Callback function
intersections.push(entity);
true
},
);
for entity in intersections.iter() {
println!("Entity: {}", entity);
}
}
§Related Methods
sourcepub fn aabb_intersections_with_aabb(&self, aabb: ColliderAabb) -> Vec<Entity>
pub fn aabb_intersections_with_aabb(&self, aabb: ColliderAabb) -> Vec<Entity>
An intersection test that finds all entities with a ColliderAabb
that is intersecting the given aabb
.
§Example
use avian3d::prelude::*;
use bevy::prelude::*;
fn print_aabb_intersections(spatial_query: SpatialQuery) {
let aabb = Collider::sphere(0.5).aabb(Vec3::ZERO, Quat::default());
let intersections = spatial_query.aabb_intersections_with_aabb(aabb);
for entity in intersections.iter() {
println!("Entity: {}", entity);
}
}
§Related Methods
sourcepub fn aabb_intersections_with_aabb_callback(
&self,
aabb: ColliderAabb,
callback: impl FnMut(Entity) -> bool,
)
pub fn aabb_intersections_with_aabb_callback( &self, aabb: ColliderAabb, callback: impl FnMut(Entity) -> bool, )
An intersection test that finds all entities with a ColliderAabb
that is intersecting the given aabb
, calling callback
for each intersection.
The search stops when callback
returns false
or all intersections have been found.
§Example
use avian3d::prelude::*;
use bevy::prelude::*;
fn print_aabb_intersections(spatial_query: SpatialQuery) {
let mut intersections = vec![];
spatial_query.aabb_intersections_with_aabb_callback(
Collider::sphere(0.5).aabb(Vec3::ZERO, Quat::default()),
|entity| {
intersections.push(entity);
true
}
);
for entity in intersections.iter() {
println!("Entity: {}", entity);
}
}
§Related Methods
sourcepub fn shape_intersections(
&self,
shape: &Collider,
shape_position: Vector,
shape_rotation: Quaternion,
filter: &SpatialQueryFilter,
) -> Vec<Entity>
pub fn shape_intersections( &self, shape: &Collider, shape_position: Vector, shape_rotation: Quaternion, filter: &SpatialQueryFilter, ) -> Vec<Entity>
An intersection test that finds all entities with a Collider
that is intersecting the given shape
with a given position and rotation.
§Arguments
shape
: The shape that intersections are tested against represented as aCollider
.shape_position
: The position of the shape.shape_rotation
: The rotation of the shape.filter
: ASpatialQueryFilter
that determines which colliders are taken into account in the query.
§Example
use avian3d::prelude::*;
use bevy::prelude::*;
fn print_shape_intersections(spatial_query: SpatialQuery) {
let intersections = spatial_query.shape_intersections(
&Collider::sphere(0.5), // Shape
Vec3::ZERO, // Shape position
Quat::default(), // Shape rotation
&SpatialQueryFilter::default(), // Query filter
);
for entity in intersections.iter() {
println!("Entity: {}", entity);
}
}
§Related Methods
sourcepub fn shape_intersections_callback(
&self,
shape: &Collider,
shape_position: Vector,
shape_rotation: Quaternion,
filter: &SpatialQueryFilter,
callback: impl FnMut(Entity) -> bool,
)
pub fn shape_intersections_callback( &self, shape: &Collider, shape_position: Vector, shape_rotation: Quaternion, filter: &SpatialQueryFilter, callback: impl FnMut(Entity) -> bool, )
An intersection test that finds all entities with a Collider
that is intersecting the given shape
with a given position and rotation, calling callback
for each
intersection. The search stops when callback
returns false
or all intersections have been found.
§Arguments
shape
: The shape that intersections are tested against represented as aCollider
.shape_position
: The position of the shape.shape_rotation
: The rotation of the shape.filter
: ASpatialQueryFilter
that determines which colliders are taken into account in the query.callback
: A callback function called for each intersection.
§Example
use avian3d::prelude::*;
use bevy::prelude::*;
fn print_shape_intersections(spatial_query: SpatialQuery) {
let mut intersections = vec![];
spatial_query.shape_intersections_callback(
&Collider::sphere(0.5), // Shape
Vec3::ZERO, // Shape position
Quat::default(), // Shape rotation
&SpatialQueryFilter::default(), // Query filter
|entity| { // Callback function
intersections.push(entity);
true
},
);
for entity in intersections.iter() {
println!("Entity: {}", entity);
}
}
§Related Methods
Trait Implementations§
source§impl SystemParam for SpatialQuery<'_, '_>
impl SystemParam for SpatialQuery<'_, '_>
source§type Item<'w, 's> = SpatialQuery<'w, 's>
type Item<'w, 's> = SpatialQuery<'w, 's>
Self
, instantiated with new lifetimes. Read moresource§fn init_state(world: &mut World, system_meta: &mut SystemMeta) -> Self::State
fn init_state(world: &mut World, system_meta: &mut SystemMeta) -> Self::State
World
access used by this SystemParam
and creates a new instance of this param’s State
.source§unsafe fn new_archetype(
state: &mut Self::State,
archetype: &Archetype,
system_meta: &mut SystemMeta,
)
unsafe fn new_archetype( state: &mut Self::State, archetype: &Archetype, system_meta: &mut SystemMeta, )
Archetype
, registers the components accessed by this SystemParam
(if applicable).a Read moresource§fn apply(state: &mut Self::State, system_meta: &SystemMeta, world: &mut World)
fn apply(state: &mut Self::State, system_meta: &SystemMeta, world: &mut World)
SystemParam
’s state.
This is used to apply Commands
during apply_deferred
.source§fn queue(
state: &mut Self::State,
system_meta: &SystemMeta,
world: DeferredWorld<'_>,
)
fn queue( state: &mut Self::State, system_meta: &SystemMeta, world: DeferredWorld<'_>, )
apply_deferred
.source§unsafe fn validate_param<'w, 's>(
state: &'s Self::State,
system_meta: &SystemMeta,
world: UnsafeWorldCell<'w>,
) -> bool
unsafe fn validate_param<'w, 's>( state: &'s Self::State, system_meta: &SystemMeta, world: UnsafeWorldCell<'w>, ) -> bool
get_param
.
Built-in executors use this to prevent systems with invalid params from running.
For nested SystemParam
s validation will fail if any
delegated validation fails. Read moresource§unsafe fn get_param<'w, 's>(
state: &'s mut Self::State,
system_meta: &SystemMeta,
world: UnsafeWorldCell<'w>,
change_tick: Tick,
) -> Self::Item<'w, 's>
unsafe fn get_param<'w, 's>( state: &'s mut Self::State, system_meta: &SystemMeta, world: UnsafeWorldCell<'w>, change_tick: Tick, ) -> Self::Item<'w, 's>
SystemParamFunction
. Read moreimpl<'w, 's> ReadOnlySystemParam for SpatialQuery<'w, 's>where
Query<'w, 's, (Entity, &'static Position, &'static Rotation, &'static Collider, Option<&'static CollisionLayers>), Without<ColliderDisabled>>: ReadOnlySystemParam,
Query<'w, 's, Entity, Added<Collider>>: ReadOnlySystemParam,
ResMut<'w, SpatialQueryPipeline>: ReadOnlySystemParam,
Auto Trait Implementations§
impl<'w, 's> Freeze for SpatialQuery<'w, 's>
impl<'w, 's> !RefUnwindSafe for SpatialQuery<'w, 's>
impl<'w, 's> Send for SpatialQuery<'w, 's>
impl<'w, 's> Sync for SpatialQuery<'w, 's>
impl<'w, 's> Unpin for SpatialQuery<'w, 's>
impl<'w, 's> !UnwindSafe for SpatialQuery<'w, 's>
Blanket Implementations§
source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moresource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.