pub struct LooseOctree<T: Clone> {
pub center: [f64; 3],
pub half_size: f64,
pub depth: u32,
pub items: Vec<(usize, [f64; 3], T)>,
pub children: Option<Box<[LooseOctree<T>; 8]>>,
}Expand description
A loose octree node that stores items at every level.
Fields§
§center: [f64; 3]World-space centre of this node.
half_size: f64Half-size of the tight cell (the loose cell is 2 * half_size).
depth: u32Remaining subdivision depth (0 = leaf).
items: Vec<(usize, [f64; 3], T)>Items stored at this node (not yet pushed to children).
children: Option<Box<[LooseOctree<T>; 8]>>Eight children, present after the first subdivision.
Implementations§
Source§impl<T: Clone> LooseOctree<T>
impl<T: Clone> LooseOctree<T>
Sourcepub fn child_index(&self, pos: [f64; 3]) -> usize
pub fn child_index(&self, pos: [f64; 3]) -> usize
Returns the octant index (0..7) for pos relative to self.center.
Sourcepub fn insert(&mut self, id: usize, pos: [f64; 3], data: T, max_items: usize)
pub fn insert(&mut self, id: usize, pos: [f64; 3], data: T, max_items: usize)
Inserts (id, pos, data) into the tree.
Sourcepub fn query_sphere(&self, center: [f64; 3], radius: f64) -> Vec<(usize, &T)>
pub fn query_sphere(&self, center: [f64; 3], radius: f64) -> Vec<(usize, &T)>
Returns all items whose stored position is within radius of center.
Sourcepub fn query_aabb(&self, min: [f64; 3], max: [f64; 3]) -> Vec<(usize, &T)>
pub fn query_aabb(&self, min: [f64; 3], max: [f64; 3]) -> Vec<(usize, &T)>
Returns all items within an axis-aligned box.
Sourcepub fn item_count(&self) -> usize
pub fn item_count(&self) -> usize
Counts all items stored in this node and all descendants.
Sourcepub fn max_depth_reached(&self) -> u32
pub fn max_depth_reached(&self) -> u32
Returns the maximum depth reached in the tree.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Count the total number of nodes in the tree.
Auto Trait Implementations§
impl<T> Freeze for LooseOctree<T>
impl<T> RefUnwindSafe for LooseOctree<T>where
T: RefUnwindSafe,
impl<T> Send for LooseOctree<T>where
T: Send,
impl<T> Sync for LooseOctree<T>where
T: Sync,
impl<T> Unpin for LooseOctree<T>where
T: Unpin,
impl<T> UnsafeUnpin for LooseOctree<T>
impl<T> UnwindSafe for LooseOctree<T>where
T: UnwindSafe,
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<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.