Struct ami::Octree
[−]
[src]
pub struct Octree<T: Collider> { /* fields omitted */ }
An octree is a DAG that can quickly search for points in 3D space.
The bounding box of the root node contains all points in the octree. If a point outside the bounding box is added, a new root node is created which contains the old root as one of its octants. This process is repeated until the point is contained.
The nodes are stored in a vector, and are indexed using a 32-bit node ID. This saves memory over using pointers on 64-bit systems. Node ID 1 is the first node in the vector.
Methods
impl<T> Octree<T> where
T: Collider,
[src]
T: Collider,
pub fn new() -> Octree<T>
[src]
Create a new octree
pub fn add(&mut self, point: T) -> u32
[src]
Add a point in the octree
pub fn bounce_test(&self, point: u32, force: &mut Vec3) -> Option<u32>
[src]
Test before moving a point within the octree, to see if it collides. If it does, returns with what and a new force vector.
TODO: doesn't work yet.
pub fn remove(&mut self, hnd: u32) -> T
[src]
Remove a point from the octree
pub fn nearest(&mut self, sorted: &mut Vec<u32>, frustum: Frustum)
[src]
Sort the octree nearest to farthest, while culling all outside of view frustum.
pub fn farthest(&mut self, sorted: &mut Vec<u32>, frustum: Frustum)
[src]
Sort the octree farthest to nearest, while culling all outside of view frustum.
pub fn print(&self)
[src]
Print the octree
pub fn len(&self) -> usize
[src]
Get the number of points in the octree.
pub fn check_corrupt(&self)
[src]
Abort program on error if the octree is corrupt!
Trait Implementations
impl<T> Index<u32> for Octree<T> where
T: Collider,
[src]
T: Collider,
type Output = T
The returned type after indexing.
fn index<'a>(&'a self, index: u32) -> &'a T
[src]
Performs the indexing (container[index]
) operation.
impl<T> IndexMut<u32> for Octree<T> where
T: Collider,
[src]
T: Collider,
fn index_mut<'a>(&'a mut self, index: u32) -> &'a mut T
[src]
Performs the mutable indexing (container[index]
) operation.
impl<T> Debug for Octree<T> where
T: Collider,
[src]
T: Collider,