pub struct SparseVoxelOctree {
pub root: OctreeNode,
pub depth: usize,
pub origin: Vec3,
pub size: f32,
}Fields§
§root: OctreeNode§depth: usize§origin: Vec3§size: f32Implementations§
Source§impl SparseVoxelOctree
impl SparseVoxelOctree
pub fn new(origin: Vec3, size: f32, depth: usize) -> Self
Sourcepub fn world_to_leaf(&self, pos: Vec3) -> Option<(i32, i32, i32)>
pub fn world_to_leaf(&self, pos: Vec3) -> Option<(i32, i32, i32)>
Convert a world position to leaf coordinates [0, 2^depth).
pub fn leaf_to_world(&self, lx: i32, ly: i32, lz: i32) -> Vec3
Sourcepub fn aabb_query(&self, min: Vec3, max: Vec3, out: &mut Vec<(Vec3, Voxel)>)
pub fn aabb_query(&self, min: Vec3, max: Vec3, out: &mut Vec<(Vec3, Voxel)>)
AABB intersection: returns positions of all leaves within the AABB.
Sourcepub fn ray_intersect(
&self,
ray_origin: Vec3,
ray_dir: Vec3,
) -> Option<(Vec3, Voxel, f32)>
pub fn ray_intersect( &self, ray_origin: Vec3, ray_dir: Vec3, ) -> Option<(Vec3, Voxel, f32)>
Ray traversal using DDA on octree.
Sourcepub fn voxel_count(&self) -> usize
pub fn voxel_count(&self) -> usize
Count all non-empty leaves.
Trait Implementations§
Source§impl Clone for SparseVoxelOctree
impl Clone for SparseVoxelOctree
Auto Trait Implementations§
impl Freeze for SparseVoxelOctree
impl RefUnwindSafe for SparseVoxelOctree
impl Send for SparseVoxelOctree
impl Sync for SparseVoxelOctree
impl Unpin for SparseVoxelOctree
impl UnsafeUnpin for SparseVoxelOctree
impl UnwindSafe for SparseVoxelOctree
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.