Struct CDEngine

Source
pub struct CDEngine {
    pub quadtree: QTNode,
    pub static_hazards: Vec<Hazard>,
    pub dynamic_hazards: Vec<Hazard>,
    pub config: CDEConfig,
    pub bbox: Rect,
    pub uncommitted_deregisters: Vec<Hazard>,
}
Expand description

The Collision Detection Engine (CDE). Hazards can be (de)registered and collision queries can be performed.

Fields§

§quadtree: QTNode§static_hazards: Vec<Hazard>§dynamic_hazards: Vec<Hazard>§config: CDEConfig§bbox: Rect§uncommitted_deregisters: Vec<Hazard>

Implementations§

Source§

impl CDEngine

Source

pub fn new( bbox: Rect, static_hazards: Vec<Hazard>, config: CDEConfig, ) -> CDEngine

Source

pub fn register_hazard(&mut self, hazard: Hazard)

Registers a new hazard in the CDE.

Source

pub fn deregister_hazard( &mut self, hazard_entity: HazardEntity, commit_instant: bool, )

Removes a hazard from the CDE. If commit_instant the deregistration is fully executed immediately. If not, the deregistration causes the hazard to be deactivated in the quadtree and the hazard_proximity_grid to become dirty (and therefore inaccessible).
Can be beneficial not to commit_instant if multiple hazards are to be deregistered, or if the chance of restoring from a snapshot with the hazard present is high.

Source

pub fn create_snapshot(&mut self) -> CDESnapshot

Source

pub fn restore(&mut self, snapshot: &CDESnapshot)

Restores the CDE to a previous state, as described by the snapshot.

Source

pub fn commit_deregisters(&mut self)

Commits all pending deregisters by actually removing them from the quadtree

Source

pub fn quadtree(&self) -> &QTNode

Source

pub fn number_of_nodes(&self) -> usize

Source

pub fn bbox(&self) -> Rect

Source

pub fn config(&self) -> CDEConfig

Source

pub fn has_uncommitted_deregisters(&self) -> bool

Source

pub fn dynamic_hazards(&self) -> &Vec<Hazard>

Returns all hazards in the CDE, which can change during the lifetime of the CDE.

Source

pub fn static_hazards(&self) -> &Vec<Hazard>

Returns all hazards in the CDE, which cannot change during the lifetime of the CDE.

Source

pub fn all_hazards(&self) -> impl Iterator<Item = &Hazard>

Returns all hazards in the CDE, both static and dynamic.

Source

pub fn surrogate_or_poly_collides( &self, reference_shape: &SPolygon, transform: &Transformation, buffer_shape: &mut SPolygon, filter: &impl HazardFilter, ) -> bool

Checks whether a reference simple polygon, with a transformation applies, collides with any of the hazards. The check is first done on the surrogate, then with the actual shape. A buffer shape is used as a temporary storage for the transformed shape.

§Arguments
  • reference_shape - The shape to be checked for collisions
  • transform - The transformation to be applied to the reference shape
  • buffer_shape - A temporary storage for the transformed shape
  • filter - Hazard filter to be applied
Source

pub fn poly_collides( &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 collisions
  • filter - Hazard filter to be applied
Source

pub fn surrogate_collides( &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 collisions
  • transform - The transformation to be applied to the surrogate
  • filter - Hazard filter to be applied
Source

pub fn point_definitely_collides_with( &self, point: &Point, entity: HazardEntity, ) -> Tribool

Checks whether a point definitely collides with any of the (relevant) hazards. Only fully hazardous nodes in the quadtree are considered.

Source

pub fn edge_definitely_collides( &self, edge: &Edge, filter: &impl HazardFilter, ) -> Tribool

Checks whether an edge definitely collides with any of the (relevant) hazards. Only fully hazardous nodes in the quadtree are considered.

Source

pub fn circle_definitely_collides( &self, circle: &Circle, filter: &impl HazardFilter, ) -> Tribool

Checks whether a circle definitely collides with any of the (relevant) hazards. Only fully hazardous nodes in the quadtree are considered.

Source

pub fn poly_or_hazard_are_contained( &self, shape: &SPolygon, haz: &Hazard, ) -> bool

Source

pub fn collect_poly_collisions( &self, shape: &SPolygon, detector: &mut impl HazardDetector, )

Collects all hazards with which the polygon collides and reports them to the detector.

Source

pub fn collect_surrogate_collisions( &self, base_surrogate: &SPSurrogate, transform: &Transformation, detector: &mut impl HazardDetector, )

Collects all hazards with which the surrogate collides and reports them to the detector.

Source

pub fn collect_potential_hazards_within( &self, bbox: Rect, detector: &mut impl HazardDetector, )

Collects all hazards potentially colliding with the given bounding box. This is an overestimation, as it is limited by the quadtree resolution.

Trait Implementations§

Source§

impl Clone for CDEngine

Source§

fn clone(&self) -> CDEngine

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CDEngine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V