pub struct Bvh {
pub nodes: Vec<BvhNode>,
pub primitive_indices: Vec<u32>,
pub escape: Vec<u32>,
}Expand description
Flat hierarchy and stable source-primitive permutation.
Fields§
§nodes: Vec<BvhNode>Root-first compact nodes.
primitive_indices: Vec<u32>Source primitive indices addressed by leaves.
escape: Vec<u32>Per-node stackless-traversal successor, parallel to nodes.
Implementations§
Source§impl Bvh
impl Bvh
Sourcepub fn ray_candidates(
&self,
origin: Vec3,
direction: Vec3,
traversal: &mut Vec<u32>,
output: &mut Vec<u32>,
)
pub fn ray_candidates( &self, origin: Vec3, direction: Vec3, traversal: &mut Vec<u32>, output: &mut Vec<u32>, )
Appends source indices whose bounds overlap a ray. Both vectors are cleared and reused; results follow deterministic hierarchy order.
Source§impl Bvh
impl Bvh
Sourcepub const ESCAPE_END: u32 = u32::MAX
pub const ESCAPE_END: u32 = u32::MAX
Escape value that ends a stackless traversal.
Sourcepub fn build<S: BvhSource + ?Sized>(source: &S) -> Result<Self, BvhBuildError>
pub fn build<S: BvhSource + ?Sized>(source: &S) -> Result<Self, BvhBuildError>
Builds a hierarchy over finite, non-empty bounds. Invalid primitives are omitted instead of poisoning the structure-wide bounds.
§Errors
Returns BvhBuildError when a source row, node or primitive offset
cannot fit the compact GPU representation.
Sourcepub fn rebuild<S: BvhSource + ?Sized>(
&mut self,
source: &S,
scratch: &mut BvhBuildScratch,
) -> Result<(), BvhBuildError>
pub fn rebuild<S: BvhSource + ?Sized>( &mut self, source: &S, scratch: &mut BvhBuildScratch, ) -> Result<(), BvhBuildError>
Rebuilds in existing storage, retaining node, permutation and sort capacities for moving coordinates.
§Errors
Returns BvhBuildError when a source row, node or primitive offset
cannot fit the compact GPU representation.
Sourcepub fn refit<S: BvhSource + ?Sized>(
&mut self,
source: &S,
) -> Result<(), BvhBuildError>
pub fn refit<S: BvhSource + ?Sized>( &mut self, source: &S, ) -> Result<(), BvhBuildError>
Refits leaf and branch bounds without changing topology or primitive
order. The work is O(resident primitives + nodes) and reuses every
allocation retained by the hierarchy.
§Errors
Returns BvhBuildError when a primitive used by the existing
topology is absent or no longer has finite, ordered bounds.
Trait Implementations§
impl StructuralPartialEq for Bvh
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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> ⓘ
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