pub enum BvhNode<T: Clone> {
Leaf {
bounds: Aabb,
item: T,
},
Branch {
bounds: Aabb,
left: Box<BvhNode<T>>,
right: Box<BvhNode<T>>,
},
}Expand description
A node in a Bounding Volume Hierarchy.
BVH provides O(log n) ray queries and O(log n) sphere overlap queries.
Build using Bvh::build(items) where each item is an (Aabb, T) pair.
Variants§
Implementations§
Source§impl<T: Clone> BvhNode<T>
impl<T: Clone> BvhNode<T>
pub fn bounds(&self) -> Aabb
Sourcepub fn query_sphere(&self, center: Vec3, radius: f32, out: &mut Vec<T>)
pub fn query_sphere(&self, center: Vec3, radius: f32, out: &mut Vec<T>)
Query all items whose AABB overlaps sphere(center, radius).
Sourcepub fn query_ray(
&self,
origin: Vec3,
dir: Vec3,
max_t: f32,
out: &mut Vec<(T, f32)>,
)
pub fn query_ray( &self, origin: Vec3, dir: Vec3, max_t: f32, out: &mut Vec<(T, f32)>, )
Ray query — returns all items whose AABB the ray intersects.
Sourcepub fn query_aabb(&self, query: &Aabb, out: &mut Vec<T>)
pub fn query_aabb(&self, query: &Aabb, out: &mut Vec<T>)
AABB overlap query.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for BvhNode<T>where
T: Freeze,
impl<T> RefUnwindSafe for BvhNode<T>where
T: RefUnwindSafe,
impl<T> Send for BvhNode<T>where
T: Send,
impl<T> Sync for BvhNode<T>where
T: Sync,
impl<T> Unpin for BvhNode<T>where
T: Unpin,
impl<T> UnsafeUnpin for BvhNode<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for BvhNode<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<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.