pub struct QTNode {
pub level: u8,
pub bbox: AARectangle,
pub children: Option<Box<[QTNode; 4]>>,
pub hazards: QTHazardVec,
}
Expand description
A node in the quadtree
Fields§
§level: u8
The level of the node in the tree, 0 being the bottom-most level
bbox: AARectangle
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
Implementations§
Source§impl QTNode
impl QTNode
pub fn new(level: u8, bbox: AARectangle) -> 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)
pub fn get_number_of_children(&self) -> usize
pub fn has_children(&self) -> bool
Sourcepub fn collides<T>(
&self,
entity: &T,
irrelevant_hazards: &[HazardEntity],
) -> Option<&HazardEntity>where
T: QTQueryable,
pub fn collides<T>(
&self,
entity: &T,
irrelevant_hazards: &[HazardEntity],
) -> Option<&HazardEntity>where
T: QTQueryable,
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>(
&self,
entity: &T,
detector: &mut impl HazardDetector,
)where
T: QTQueryable,
pub fn collect_collisions<T>(
&self,
entity: &T,
detector: &mut impl HazardDetector,
)where
T: QTQueryable,
Gathers all hazards that collide with the entity and reports them to the detector
.
All hazards already present in the detector
are ignored.
Sourcepub fn definitely_collides<T>(
&self,
entity: &T,
irrelevant_hazards: &[HazardEntity],
) -> Triboolwhere
T: CollidesWith<AARectangle>,
pub fn definitely_collides<T>(
&self,
entity: &T,
irrelevant_hazards: &[HazardEntity],
) -> Triboolwhere
T: CollidesWith<AARectangle>,
Used to detect collisions in a broad fashion:
Returns Tribool::True
if the entity definitely collides with a hazard,
Tribool::False
if the entity definitely does not collide with any hazard,
and Tribool::Indeterminate
if it is not possible to determine whether the entity collides with any hazard.
Sourcepub fn definitely_collides_with<T>(
&self,
entity: &T,
hazard_entity: HazardEntity,
) -> Triboolwhere
T: CollidesWith<AARectangle>,
pub fn definitely_collides_with<T>(
&self,
entity: &T,
hazard_entity: HazardEntity,
) -> Triboolwhere
T: CollidesWith<AARectangle>,
Used to detect collisions with a single hazard in a broad fashion:
Returns Tribool::True
if the entity definitely collides with a hazard,
Tribool::False
if the entity definitely does not collide with any hazard,
and Tribool::Indeterminate
if it is not possible to determine whether the entity collides with any hazard.
Sourcepub fn collect_potential_hazards_within(
&self,
bbox: &AARectangle,
detector: &mut impl HazardDetector,
)
pub fn collect_potential_hazards_within( &self, bbox: &AARectangle, detector: &mut impl HazardDetector, )
Used to gather all hazards that within a given bounding box. May overestimate the hazards that are present in the bounding box, since it is limited by the resolution of the quadtree.
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
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