[−][src]Struct bvh::bvh::BVH
Fields
nodes: Vec<BVHNode>
The list of nodes of the BVH
.
Methods
impl BVH
[src]
pub fn build<Shape: BHShape>(shapes: &mut [Shape]) -> BVH
[src]
Creates a new BVH
from the shapes
slice.
pub fn traverse<'a, Shape: Bounded>(
&'a self,
ray: &Ray,
shapes: &'a [Shape]
) -> Vec<&Shape>
[src]
&'a self,
ray: &Ray,
shapes: &'a [Shape]
) -> Vec<&Shape>
pub fn pretty_print(&self)
[src]
Prints the BVH
in a tree-like visualization.
pub fn is_consistent<Shape: BHShape>(&self, shapes: &[Shape]) -> bool
[src]
Checks if all children of a node have the correct parent index, and that there is no
detached subtree. Also checks if the AABB
hierarchy is consistent.
pub fn assert_consistent<Shape: BHShape>(&self, shapes: &[Shape])
[src]
Assert version of is_consistent
.
pub fn assert_tight_subtree<Shape: BHShape>(
&self,
node_index: usize,
outer_aabb: &AABB,
shapes: &[Shape]
)
[src]
&self,
node_index: usize,
outer_aabb: &AABB,
shapes: &[Shape]
)
Check that the AABB
s in the BVH
are tight, which means, that parent AABB
s are not
larger than they should be. This function checks, whether the children of node node_index
lie inside outer_aabb
.
pub fn assert_tight<Shape: BHShape>(&self, shapes: &[Shape])
[src]
Check that the AABB
s in the BVH
are tight, which means, that parent AABB
s are not
larger than they should be.
impl BVH
[src]
pub fn optimize<Shape: BHShape>(
&mut self,
refit_shape_indices: &HashSet<usize>,
shapes: &[Shape]
)
[src]
&mut self,
refit_shape_indices: &HashSet<usize>,
shapes: &[Shape]
)
Optimizes the BVH
by batch-reorganizing updated nodes.
Based on https://github.com/jeske/SimpleScene/blob/master/SimpleScene/Util/ssBVH/ssBVH.cs
Needs all the scene's shapes, plus the indices of the shapes that were updated.
impl BVH
[src]
pub fn flatten_custom<F, FNodeType>(&self, constructor: &F) -> Vec<FNodeType> where
F: Fn(&AABB, u32, u32, u32) -> FNodeType,
[src]
F: Fn(&AABB, u32, u32, u32) -> FNodeType,
Flattens the BVH
so that it can be traversed iteratively.
Constructs the flat nodes using the supplied function.
This function can be used, when the flat bvh nodes should be of some particular
non-default structure.
The constructor
is fed the following arguments in this order:
1 - &AABB: The enclosing AABB
2 - u32: The index of the nested node
3 - u32: The exit index
4 - u32: The shape index
Example
use bvh::aabb::{AABB, Bounded}; use bvh::bvh::BVH; use bvh::nalgebra::{Point3, Vector3}; use bvh::ray::Ray; struct CustomStruct { aabb: AABB, entry_index: u32, exit_index: u32, shape_index: u32, } let custom_constructor = |aabb: &AABB, entry, exit, shape_index| { CustomStruct { aabb: *aabb, entry_index: entry, exit_index: exit, shape_index: shape_index, } }; let mut shapes = create_bhshapes(); let bvh = BVH::build(&mut shapes); let custom_flat_bvh = bvh.flatten_custom(&custom_constructor);
pub fn flatten(&self) -> FlatBVH
[src]
Trait Implementations
impl BoundingHierarchy for BVH
[src]
fn build<Shape: BHShape>(shapes: &mut [Shape]) -> BVH
[src]
fn traverse<'a, Shape: Bounded>(
&'a self,
ray: &Ray,
shapes: &'a [Shape]
) -> Vec<&Shape>
[src]
&'a self,
ray: &Ray,
shapes: &'a [Shape]
) -> Vec<&Shape>
fn pretty_print(&self)
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Same for T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf for SP where
SS: SubsetOf<SP>,
SS: SubsetOf<SP>,