Trait bevy_spatial::SpatialAccess
source · [−]pub trait SpatialAccess where
Self::TComp: Component + Sync + 'static, {
type TComp;
Show 14 methods
fn distance_squared(&self, loc_a: Vec3, loc_b: Vec3) -> f32;
fn nearest_neighbour(&self, loc: Vec3) -> Option<(Vec3, Entity)>;
fn k_nearest_neighbour(&self, loc: Vec3, k: usize) -> Vec<(Vec3, Entity)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
;
fn within_distance(&self, loc: Vec3, distance: f32) -> Vec<(Vec3, Entity)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
;
fn recreate(&mut self, all: Vec<(Vec3, Entity)>);
fn add_point(&mut self, point: (Vec3, Entity));
fn remove_point(&mut self, point: (Vec3, Entity)) -> bool;
fn remove_entity(&mut self, entity: Entity) -> bool;
fn size(&self) -> usize;
fn get_min_dist(&self) -> f32;
fn get_recreate_after(&self) -> usize;
fn update_moved(
&mut self,
set: ParamSet<'_, '_, (Query<'_, '_, TrackedQuery<'_, Self::TComp>, Changed<Transform>>, Query<'_, '_, TrackedQuery<'_, Self::TComp>>)>
) { ... }
fn add_added(
&mut self,
commands: Commands<'_, '_>,
all_query: Query<'_, '_, (Entity, &Transform), With<Self::TComp>>,
added_query: Query<'_, '_, (Entity, &Transform), Added<Self::TComp>>
) { ... }
fn delete(&mut self, removed: RemovedComponents<'_, Self::TComp>) { ... }
}
Required Associated Types
Required Methods
fn distance_squared(&self, loc_a: Vec3, loc_b: Vec3) -> f32
fn distance_squared(&self, loc_a: Vec3, loc_b: Vec3) -> f32
Get the squared distance using the calculation that implementation uses. Mainly a trait method due to 2d structures using Vec3 but ignoring the 3rd dimension for distance calculations.
Get the nearest neighbour to loc
.
Be aware that that distance to the returned point will be zero if loc
is part of the datastructure.
Return the k nearest neighbours to loc
.
Return all points which are within the specified distance.
Recreate the underlying datastructure with all
points.
Remove the point by coordinate + entity from the underlying datastructure.
fn remove_entity(&mut self, entity: Entity) -> bool
fn remove_entity(&mut self, entity: Entity) -> bool
Remove the point by entity from the underlying datastructure.
Get the size of the underlying datastructure. Should match the number of tracked elements.
fn get_min_dist(&self) -> f32
fn get_min_dist(&self) -> f32
Get the minimum distance that a entity has to travel before being updated in the datastructure.
fn get_recreate_after(&self) -> usize
fn get_recreate_after(&self) -> usize
Get the amount of moved/changed/added entities after which to perform a full recreate.
Provided Methods
Update moved entities in datastructure, from bevy query. Used internally and called from a system.
Add entities which recently had the tracked component added. Used internally and called from a system.