pub struct QTNode {
pub level: u8,
pub bbox: Rect,
pub children: Option<Box<[QTNode; 4]>>,
pub hazards: QTHazardVec,
pub cd_threshold: u8,
}
Expand description
Quadtree node
Fields§
§level: u8
The level of the node in the tree, 0 being the bottom-most level
bbox: Rect
The bounding box of the node
children: Option<Box<[QTNode; 4]>>
The children of the node, if any
hazards: QTHazardVec
The hazards present in the node
cd_threshold: u8
Stop traversing the quadtree and perform collision detection immediately when the total number of edges in a node falls below this number
Implementations§
Source§impl QTNode
impl QTNode
pub fn new(level: u8, bbox: Rect, cd_threshold: u8) -> Self
pub fn register_hazard(&mut self, hazard: QTHazard)
pub fn deregister_hazard(&mut self, hazard_entity: HazardEntity)
pub fn activate_hazard(&mut self, entity: HazardEntity)
pub fn deactivate_hazard(&mut self, entity: HazardEntity)
Sourcepub fn collides<T: QTQueryable>(
&self,
entity: &T,
filter: &impl HazardFilter,
) -> Option<&HazardEntity>
pub fn collides<T: QTQueryable>( &self, entity: &T, filter: &impl HazardFilter, ) -> Option<&HazardEntity>
Used to detect collisions in a binary fashion: either there is a collision or there isn’t.
Returns None
if no collision between the entity and any hazard is detected,
otherwise the first encountered hazard that collides with the entity is returned.
Sourcepub fn collect_collisions<T: QTQueryable>(
&self,
entity: &T,
detector: &mut impl HazardDetector,
)
pub fn collect_collisions<T: QTQueryable>( &self, entity: &T, detector: &mut impl HazardDetector, )
Gathers all hazards that collide with the entity and reports them to the detector
.
All hazards already present in the detector
are ignored.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for QTNode
impl RefUnwindSafe for QTNode
impl Send for QTNode
impl Sync for QTNode
impl Unpin for QTNode
impl UnwindSafe for QTNode
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
Mutably borrows from an owned value. Read more
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>
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 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>
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