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 AABBs of its children.

Variants

Leaf

Leaf node.

Show fields

Fields of Leaf

parent_index: usize

The node’s parent.

depth: u32

The node’s depth.

shape_index: usize

The shape contained in this leaf.

Node

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’ AABBs 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’ AABBs in child_r.

Implementations

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 AABBs 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]

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]

Traverses the BVH recursively and returns all shapes whose AABB is intersected by the given Ray.

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]

Flattens the BVH, so that it can be traversed in an iterative manner. This method constructs custom flat nodes using the constructor.

Trait Implementations

impl Clone for BVHNode[src]

impl Copy for BVHNode[src]

impl Debug for BVHNode[src]

impl PartialEq<BVHNode> for BVHNode[src]

Auto Trait Implementations

impl RefUnwindSafe for BVHNode

impl Send for BVHNode

impl Sync for BVHNode

impl Unpin for BVHNode

impl UnwindSafe for BVHNode

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Scalar for T where
    T: Copy + PartialEq<T> + Debug + Any
[src]

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,