pub struct Bvh {
pub root: Option<BvhNode>,
pub primitives: Vec<BvhPrimitive>,
}Expand description
A BVH tree built from a flat list of BvhPrimitives.
Fields§
§root: Option<BvhNode>Tree root (if there is at least one primitive).
primitives: Vec<BvhPrimitive>All primitives passed to Bvh::build.
Implementations§
Source§impl Bvh
impl Bvh
Sourcepub fn build(primitives: Vec<BvhPrimitive>) -> Self
pub fn build(primitives: Vec<BvhPrimitive>) -> Self
Build a BVH from a list of primitives using a median-split strategy guided by the longest axis (SAH-inspired).
Sourcepub fn query_aabb(&self, query: &Aabb) -> Vec<usize>
pub fn query_aabb(&self, query: &Aabb) -> Vec<usize>
Return the object_ids of all primitives whose AABB overlaps query.
Sourcepub fn query_ray(
&self,
origin: [f32; 3],
direction: [f32; 3],
max_t: f32,
) -> Vec<usize>
pub fn query_ray( &self, origin: [f32; 3], direction: [f32; 3], max_t: f32, ) -> Vec<usize>
Return the object_ids of all primitives hit by the given ray within
distance max_t.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Total number of nodes in the tree.
Auto Trait Implementations§
impl Freeze for Bvh
impl RefUnwindSafe for Bvh
impl Send for Bvh
impl Sync for Bvh
impl Unpin for Bvh
impl UnsafeUnpin for Bvh
impl UnwindSafe for Bvh
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more