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: u8The level of the node in the tree, 0 being the bottom-most level
bbox: RectThe bounding box of the node
children: Option<Box<[QTNode; 4]>>The children of the node, if any
hazards: QTHazardVecThe hazards present in the node
cd_threshold: u8Stop 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, new_qt_haz: QTHazard, haz_map: &SlotMap<HazKey, Hazard>, )
pub fn deregister_hazard(&mut self, hkey: HazKey)
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,
collector: &mut impl HazardCollector,
)
pub fn collect_collisions<T: QTQueryable>( &self, entity: &T, collector: &mut impl HazardCollector, )
Gathers all hazards that collide with the entity and reports them to the collector.
All hazards already present in the collector 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