pub struct CDEngine {
pub quadtree: QTNode,
pub hazards_map: SlotMap<HazKey, Hazard>,
pub config: CDEConfig,
/* private fields */
}
Expand description
The Collision Detection Engine (CDE).
Hazard
s can be (de)registered and collision queries can be performed.
Fields§
§quadtree: QTNode
Root node of the quadtree
hazards_map: SlotMap<HazKey, Hazard>
All hazards registered in the CDE (active and inactive)
config: CDEConfig
Configuration of the CDE
Implementations§
Source§impl CDEngine
impl CDEngine
pub fn new( bbox: Rect, static_hazards: Vec<Hazard>, config: CDEConfig, ) -> CDEngine
Sourcepub fn register_hazard(&mut self, hazard: Hazard)
pub fn register_hazard(&mut self, hazard: Hazard)
Registers a new hazard in the CDE.
Sourcepub fn deregister_hazard_by_entity(
&mut self,
hazard_entity: HazardEntity,
) -> Hazard
pub fn deregister_hazard_by_entity( &mut self, hazard_entity: HazardEntity, ) -> Hazard
Removes a hazard from the CDE.
pub fn deregister_hazard_by_key(&mut self, hkey: HazKey) -> Hazard
pub fn save(&self) -> CDESnapshot
Sourcepub fn restore(&mut self, snapshot: &CDESnapshot)
pub fn restore(&mut self, snapshot: &CDESnapshot)
Restores the CDE to a previous state, as described by the snapshot.
Sourcepub fn detect_poly_collision(
&self,
shape: &SPolygon,
filter: &impl HazardFilter,
) -> bool
pub fn detect_poly_collision( &self, shape: &SPolygon, filter: &impl HazardFilter, ) -> bool
Checks whether a simple polygon collides with any of the (relevant) hazards
§Arguments
shape
- The shape (already transformed) to be checked for collisionsfilter
- Hazard filter to be applied
Sourcepub fn detect_surrogate_collision(
&self,
base_surrogate: &SPSurrogate,
transform: &Transformation,
filter: &impl HazardFilter,
) -> bool
pub fn detect_surrogate_collision( &self, base_surrogate: &SPSurrogate, transform: &Transformation, filter: &impl HazardFilter, ) -> bool
Checks whether a surrogate collides with any of the (relevant) hazards.
§Arguments
base_surrogate
- The (untransformed) surrogate to be checked for collisionstransform
- The transformation to be applied to the surrogate (on the fly)filter
- Hazard filter to be applied
Sourcepub fn detect_containment_collision(
&self,
shape: &SPolygon,
haz_shape: &SPolygon,
haz_entity: HazardEntity,
) -> bool
pub fn detect_containment_collision( &self, shape: &SPolygon, haz_shape: &SPolygon, haz_entity: HazardEntity, ) -> bool
Check for collision by containment between a shape and a hazard. This only guarantees to detect collisions caused by full containment of one shape in another.
§Arguments
shape
- The shape to be checked for containmenthaz_shape
- The shape of the respective hazardhaz_entity
- The entity inducing the hazard
Sourcepub fn collect_poly_collisions(
&self,
shape: &SPolygon,
collector: &mut impl HazardCollector,
)
pub fn collect_poly_collisions( &self, shape: &SPolygon, collector: &mut impl HazardCollector, )
Collects all hazards with which the polygon collides and reports them to the collector.
§Arguments
shape
- The shape to be checked for collisionscollector
- The collector to which the hazards are reported
Sourcepub fn collect_surrogate_collisions(
&self,
base_surrogate: &SPSurrogate,
transform: &Transformation,
collector: &mut impl HazardCollector,
)
pub fn collect_surrogate_collisions( &self, base_surrogate: &SPSurrogate, transform: &Transformation, collector: &mut impl HazardCollector, )
Collects all hazards with which the surrogate collides and reports them to the collector.
§Arguments
base_surrogate
- The (untransformed) surrogate to be checked for collisionstransform
- The transformation to be applied to the surrogate (on the fly)collector
- The collector to which the hazards are reported
Sourcepub fn get_virtual_root(&self, bbox: Rect) -> &QTNode
pub fn get_virtual_root(&self, bbox: Rect) -> &QTNode
Returns the lowest QTNode
that completely surrounds the given bounding box.
Used to initiate collision checks from lower in the quadtree.
pub fn bbox(&self) -> Rect
pub fn haz_key_from_pi_key(&self, pik: PItemKey) -> Option<HazKey>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CDEngine
impl RefUnwindSafe for CDEngine
impl Send for CDEngine
impl Sync for CDEngine
impl Unpin for CDEngine
impl UnwindSafe for CDEngine
Blanket Implementations§
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more