#[repr(C, align(16))]pub struct Bvh2Node {
pub aabb: Aabb,
pub prim_count: u32,
pub first_index: u32,
pub meta1: u32,
pub meta2: u32,
}Expand description
A node in the Bvh2, can be an inner node or leaf.
Fields§
§aabb: AabbThe bounding box for the primitive(s) contained in this node
prim_count: u32Number of primitives contained in this node. If prim_count is 0, this is a inner node. If prim_count > 0 this node is a leaf node. Note: CwBvh will clamp to max 3, Bvh2 will clamp to max 255 partial rebuilds uses u32::MAX to temporarily designate a subtree root.
first_index: u32The index of the first child Aabb or primitive.
If this node is an inner node the first child will be at nodes[first_index], and the second at nodes[first_index + 1].
If this node is a leaf node the first index typically indexes into a primitive_indices list that contains the actual index of the primitive.
The reason for this mapping is that if multiple primitives are contained in this node, they need to have their indices layed out contiguously.
To avoid this indirection we have two options:
- Layout the primitives in the order of the primitive_indices mapping so that this can index directly into the primitive list.
- Only allow one primitive per node and write back the original mapping to the bvh node list.
meta1: u32With the aabb, prim_count, and first_index, this struct was already padded out to 48 bytes. These meta fields allow the user to access this otherwise unused space.
meta2: u32With the aabb, prim_count, and first_index, this struct was already padded out to 48 bytes. These meta fields allow the user to access this otherwise unused space.
Implementations§
Source§impl Bvh2Node
impl Bvh2Node
pub fn new(aabb: Aabb, prim_count: u32, first_index: u32) -> Self
pub fn aabb(&self) -> &Aabb
pub fn set_aabb(&mut self, aabb: Aabb)
Sourcepub fn is_leaf(&self) -> bool
pub fn is_leaf(&self) -> bool
Also returns true for invalid nodes. If that matters in the context you are using this also check Bvh2::is_invalid (used internally for partial BVH rebuilds)
Sourcepub fn valid(&self) -> bool
pub fn valid(&self) -> bool
Used internally for partial BVH rebuilds. Does not usually need to be checked. Currently, a bvh will only temporarily contain any invalid nodes.
Sourcepub fn set_invalid(&mut self)
pub fn set_invalid(&mut self)
Used internally for partial BVH rebuilds.
pub fn is_left_sibling(node_id: usize) -> bool
pub fn get_sibling_id(node_id: usize) -> usize
pub fn get_left_sibling_id(node_id: usize) -> usize
pub fn get_right_sibling_id(node_id: usize) -> usize
pub fn is_left_sibling32(node_id: u32) -> bool
pub fn get_sibling_id32(node_id: u32) -> u32
pub fn get_left_sibling_id32(node_id: u32) -> u32
pub fn get_right_sibling_id32(node_id: u32) -> u32
pub fn make_inner(&mut self, first_index: u32)
Trait Implementations§
impl Copy for Bvh2Node
impl Pod for Bvh2Node
Auto Trait Implementations§
impl Freeze for Bvh2Node
impl RefUnwindSafe for Bvh2Node
impl Send for Bvh2Node
impl Sync for Bvh2Node
impl Unpin for Bvh2Node
impl UnwindSafe for Bvh2Node
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> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self.