pub trait Bvh2Ext {
// Required methods
fn sweep_traverse<F: FnMut(&Sweep, usize) -> f32>(
&self,
sweep: Sweep,
hit: &mut SweepHit,
intersection_fn: F,
) -> bool;
fn sweep_traverse_miss<F: FnMut(&Sweep, usize) -> f32>(
&self,
sweep: Sweep,
intersection_fn: F,
) -> bool;
fn sweep_traverse_anyhit<F: FnMut(&Sweep, usize)>(
&self,
sweep: Sweep,
intersection_fn: F,
);
fn sweep_traverse_dynamic<F: FnMut(&Bvh2Node, &mut Sweep, &mut SweepHit) -> bool, Stack: FastStack<u32>>(
&self,
stack: &mut Stack,
sweep: Sweep,
hit: &mut SweepHit,
intersection_fn: F,
);
fn squared_distance_traverse<F: FnMut(Vec3A, usize) -> f32>(
&self,
point: Vec3A,
max_dist_sq: f32,
visit_fn: F,
) -> Option<(u32, f32)>;
fn squared_distance_traverse_dynamic<F: FnMut(&Bvh2Node, &mut f32, &mut Option<(u32, f32)>) -> bool, Stack: FastStack<u32>>(
&self,
stack: &mut Stack,
point: Vec3A,
max_dist_sq: f32,
closest_leaf: &mut Option<(u32, f32)>,
visit_fn: F,
);
}Expand description
Extension trait for obvhs::bvh2::Bvh2 to add additional traversal methods.
Required Methods§
Sourcefn sweep_traverse<F: FnMut(&Sweep, usize) -> f32>(
&self,
sweep: Sweep,
hit: &mut SweepHit,
intersection_fn: F,
) -> bool
fn sweep_traverse<F: FnMut(&Sweep, usize) -> f32>( &self, sweep: Sweep, hit: &mut SweepHit, intersection_fn: F, ) -> bool
Traverse the BVH by sweeping an AABB along a velocity vector. Returns the closest intersected primitive.
§Arguments
sweep- The sweep to be tested for intersection.hit- Assweep_traverse_dynamicintersects primitives, it will updatehitwith the closest.intersection_fn- should take the given sweep and primitive index and return the distance to the intersection, if any.
Note the primitive index should index first into Bvh2::primitive_indices then that will be index of original primitive.
Various parts of the BVH building process might reorder the primitives. To avoid this indirection, reorder your
original primitives per primitive_indices.
Sourcefn sweep_traverse_miss<F: FnMut(&Sweep, usize) -> f32>(
&self,
sweep: Sweep,
intersection_fn: F,
) -> bool
fn sweep_traverse_miss<F: FnMut(&Sweep, usize) -> f32>( &self, sweep: Sweep, intersection_fn: F, ) -> bool
Traverse the BVH by sweeping an AABB along a velocity vector. Returns true if the sweep missed all primitives.
§Arguments
sweep- The sweep to be tested for intersection.intersection_fn- should take the given sweep and primitive index and return the distance to the intersection, if any.
Note the primitive index should index first into Bvh2::primitive_indices then that will be index of original primitive.
Various parts of the BVH building process might reorder the primitives. To avoid this indirection, reorder your
original primitives per primitive_indices.
Sourcefn sweep_traverse_anyhit<F: FnMut(&Sweep, usize)>(
&self,
sweep: Sweep,
intersection_fn: F,
)
fn sweep_traverse_anyhit<F: FnMut(&Sweep, usize)>( &self, sweep: Sweep, intersection_fn: F, )
Traverse the BVH by sweeping an AABB along a velocity vector. Intersects all primitives along the sweep
and calls intersection_fn for each hit. The sweep is not updated, to allow for evaluating at every hit.
§Arguments
sweep- The sweep to be tested for intersection.intersection_fn- should take the given sweep and primitive index.
Note the primitive index should index first into Bvh2::primitive_indices then that will be index of original primitive.
Various parts of the BVH building process might reorder the primitives. To avoid this indirection, reorder your
original primitives per primitive_indices.
Sourcefn sweep_traverse_dynamic<F: FnMut(&Bvh2Node, &mut Sweep, &mut SweepHit) -> bool, Stack: FastStack<u32>>(
&self,
stack: &mut Stack,
sweep: Sweep,
hit: &mut SweepHit,
intersection_fn: F,
)
fn sweep_traverse_dynamic<F: FnMut(&Bvh2Node, &mut Sweep, &mut SweepHit) -> bool, Stack: FastStack<u32>>( &self, stack: &mut Stack, sweep: Sweep, hit: &mut SweepHit, intersection_fn: F, )
Traverse the BVH by sweeping an AABB along a velocity vector.
Terminates when no hits are found or when intersection_fn returns false for a hit.
§Arguments
stack- Stack for traversal state.sweep- The sweep to be tested for intersection.hit- Assweep_traverse_dynamicintersects primitives, it will updatehitwith the closest.intersection_fn- should test the primitives in the given node, update the ray.tmax, and hit info. Return false to halt traversal.
Note the primitive index should index first into Bvh2::primitive_indices then that will be index of original primitive.
Various parts of the BVH building process might reorder the primitives. To avoid this indirection, reorder your
original primitives per primitive_indices.
Sourcefn squared_distance_traverse<F: FnMut(Vec3A, usize) -> f32>(
&self,
point: Vec3A,
max_dist_sq: f32,
visit_fn: F,
) -> Option<(u32, f32)>
fn squared_distance_traverse<F: FnMut(Vec3A, usize) -> f32>( &self, point: Vec3A, max_dist_sq: f32, visit_fn: F, ) -> Option<(u32, f32)>
Traverse the BVH to find the closest leaf node to a point.
Returns the primitive index and squared distance of the closest leaf, or None if no leaf is within max_dist_sq.
§Arguments
stack- Stack for traversal state.point- The query point.max_dist_sq- Maximum squared distance to search (usef32::INFINITYfor unlimited).closest_leaf- Will be updated with the closest leaf node and distance found.visit_fn- Called for each leaf node within range. Should take the given ray and primitive index and return the squared distance to the primitive, if any.
Note the primitive index should index first into Bvh2::primitive_indices then that will be index of original primitive.
Various parts of the BVH building process might reorder the primitives. To avoid this indirection, reorder your
original primitives per primitive_indices.
Sourcefn squared_distance_traverse_dynamic<F: FnMut(&Bvh2Node, &mut f32, &mut Option<(u32, f32)>) -> bool, Stack: FastStack<u32>>(
&self,
stack: &mut Stack,
point: Vec3A,
max_dist_sq: f32,
closest_leaf: &mut Option<(u32, f32)>,
visit_fn: F,
)
fn squared_distance_traverse_dynamic<F: FnMut(&Bvh2Node, &mut f32, &mut Option<(u32, f32)>) -> bool, Stack: FastStack<u32>>( &self, stack: &mut Stack, point: Vec3A, max_dist_sq: f32, closest_leaf: &mut Option<(u32, f32)>, visit_fn: F, )
Traverse the BVH with a point, calling visit_fn for each leaf node within max_dist_sq of the point.
Terminates when all nodes within max_dist_sq have been visited or when visit_fn returns false for a node.
§Arguments
stack- Stack for traversal state.point- The query point.max_dist_sq- Maximum squared distance to search (usef32::INFINITYfor unlimited).closest_leaf- Will be updated with the closest leaf node and distance found.visit_fn- Called for each leaf node within range. Should updatemax_dist_sqandclosest_leaf. Return false to halt traversal early.
Note the primitive index should index first into Bvh2::primitive_indices then that will be index of original primitive.
Various parts of the BVH building process might reorder the primitives. To avoid this indirection, reorder your
original primitives per primitive_indices.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.