Enum bvh::bvh::BVHNode [−][src]
pub enum BVHNode { Leaf { parent_index: usize, depth: u32, shape_index: usize, }, Node { parent_index: usize, depth: u32, child_l_index: usize, child_l_aabb: AABB, child_r_index: usize, child_r_aabb: AABB, }, }
The BVHNode
enum that describes a node in a BVH
.
It’s either a leaf node and references a shape (by holding its index)
or a regular node that has two child nodes.
The non-leaf node stores the AABB
s of its children.
Variants
Leaf node.
Show fields
Inner node.
Show fields
Fields of Node
parent_index: usize
The node’s parent.
depth: u32
The node’s depth.
child_l_index: usize
Index of the left subtree’s root node.
child_l_aabb: AABB
The convex hull of the shapes’ AABB
s in child_l.
child_r_index: usize
Index of the right subtree’s root node.
child_r_aabb: AABB
The convex hull of the shapes’ AABB
s in child_r.
Implementations
impl BVHNode
[src]
impl BVHNode
[src]pub fn parent(&self) -> usize
[src]
Returns the index of the parent node.
pub fn parent_mut(&mut self) -> &mut usize
[src]
Returns a mutable reference to the parent node index.
pub fn child_l(&self) -> usize
[src]
Returns the index of the left child node.
pub fn child_l_aabb(&self) -> AABB
[src]
Returns the AABB
of the right child node.
pub fn child_l_aabb_mut(&mut self) -> &mut AABB
[src]
Returns a mutable reference to the AABB
of the left child node.
pub fn child_r(&self) -> usize
[src]
Returns the index of the right child node.
pub fn child_r_aabb(&self) -> AABB
[src]
Returns the AABB
of the right child node.
pub fn child_r_aabb_mut(&mut self) -> &mut AABB
[src]
Returns a mutable reference to the AABB
of the right child node.
pub fn depth(&self) -> u32
[src]
Returns the depth of the node. The root node has depth 0
.
pub fn get_node_aabb<Shape: BHShape>(&self, shapes: &[Shape]) -> AABB
[src]
Gets the AABB
for a BVHNode
.
Returns the shape’s AABB
for leaves, and the joined AABB
of
the two children’s AABB
s for non-leaves.
pub fn shape_index(&self) -> Option<usize>
[src]
Returns the index of the shape contained within the node if is a leaf,
or None
if it is an interior node.
pub fn build<T: BHShape>(
shapes: &mut [T],
indices: &[usize],
nodes: &mut Vec<BVHNode>,
parent_index: usize,
depth: u32
) -> usize
[src]
shapes: &mut [T],
indices: &[usize],
nodes: &mut Vec<BVHNode>,
parent_index: usize,
depth: u32
) -> usize
Builds a BVHNode
recursively using SAH partitioning.
Returns the index of the new node in the nodes vector.
pub fn traverse_recursive(
nodes: &[BVHNode],
node_index: usize,
ray: &Ray,
indices: &mut Vec<usize>
)
[src]
nodes: &[BVHNode],
node_index: usize,
ray: &Ray,
indices: &mut Vec<usize>
)
impl BVHNode
[src]
impl BVHNode
[src]pub fn flatten_custom<F, FNodeType>(
&self,
nodes: &[BVHNode],
vec: &mut Vec<FNodeType>,
next_free: usize,
constructor: &F
) -> usize where
F: Fn(&AABB, u32, u32, u32) -> FNodeType,
[src]
&self,
nodes: &[BVHNode],
vec: &mut Vec<FNodeType>,
next_free: usize,
constructor: &F
) -> usize where
F: Fn(&AABB, u32, u32, u32) -> FNodeType,
Flattens the BVH
, so that it can be traversed in an iterative manner.
This method constructs custom flat nodes using the constructor
.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for BVHNode
impl RefUnwindSafe for BVHNode
impl UnwindSafe for BVHNode
impl UnwindSafe for BVHNode
Blanket Implementations
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
pub fn to_subset(&self) -> Option<SS>
pub fn is_in_subset(&self) -> bool
pub fn to_subset_unchecked(&self) -> SS
pub fn from_subset(element: &SS) -> SP
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,