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