#[repr(C)]pub struct CwBvhNode {
pub p: Vec3,
pub e: [u8; 3],
pub imask: u8,
pub child_base_idx: u32,
pub primitive_base_idx: u32,
pub child_meta: [u8; 8],
pub child_min_x: [u8; 8],
pub child_max_x: [u8; 8],
pub child_min_y: [u8; 8],
pub child_max_y: [u8; 8],
pub child_min_z: [u8; 8],
pub child_max_z: [u8; 8],
}Expand description
A Compressed Wide BVH8 Node. repr(C), Pod, 80 bytes.
Fields§
§p: Vec3Min point of node AABB
e: [u8; 3]Exponent of child bounding box compression
Max point of node AABB could be calculated ex: p.x + bitcast<f32>(e[0] << 23) * 255.0
imask: u8Bitmask indicating which children are internal nodes. 1 for internal, 0 for leaf
child_base_idx: u32Index of first child into Vec<CwBvhNode>
primitive_base_idx: u32Index of first primitive into primitive_indices Vec<u32>
child_meta: [u8; 8]Meta data for each child Empty child slot: The field is set to 00000000
For leaves nodes: the low 5 bits store the primitive offset [0..24) from primitive_base_idx. And the high 3 bits store the number of primitives in that leaf in a unary encoding. A child leaf with 2 primitives with the first primitive starting at primitive_base_idx would be 0b01100000 A child leaf with 3 primitives with the first primitive starting at primitive_base_idx + 2 would be 0b11100010 A child leaf with 1 primitive with the first primitive starting at primitive_base_idx + 1 would be 0b00100001
For internal nodes: The high 3 bits are set to 001 while the low 5 bits store the child slot index plus 24 i.e., the values range [24..32)
child_min_x: [u8; 8]Axis planes for each child.
The plane position could be calculated, for example, with p.x + bitcast<f32>(e[0] << 23) * child_min_x[0]
But in the actual intersection implementation the ray is transformed instead.
child_max_x: [u8; 8]§child_min_y: [u8; 8]§child_max_y: [u8; 8]§child_min_z: [u8; 8]§child_max_z: [u8; 8]Implementations§
Source§impl CwBvhNode
impl CwBvhNode
pub fn intersect_ray(&self, ray: &Ray, oct_inv4: u32) -> u32
Sourcepub fn intersect_ray_basic(&self, ray: &Ray, oct_inv4: u32) -> u32
pub fn intersect_ray_basic(&self, ray: &Ray, oct_inv4: u32) -> u32
Intersects only one child at a time with the given ray. Limited simd usage on platforms that support it. Exists for reference & compatibility. Traversal times with CwBvhNode::intersect_ray_simd take less than half the time vs intersect_ray_basic.
pub fn intersect_aabb(&self, aabb: &Aabb, oct_inv4: u32) -> u32
pub fn contains_point(&self, point: &Vec3A, oct_inv4: u32) -> u32
pub fn get_child_and_index_bits(&self, oct_inv4: u32) -> (u64, u64)
Sourcepub fn local_child_aabb(&self, child: usize) -> Aabb
pub fn local_child_aabb(&self, child: usize) -> Aabb
Get local child aabb position relative to the parent
pub fn child_aabb(&self, child: usize) -> Aabb
pub fn aabb(&self) -> Aabb
Sourcepub fn compute_extent(&self) -> Vec3A
pub fn compute_extent(&self) -> Vec3A
Convert stored extent exponent into float vector
pub fn is_leaf(&self, child: usize) -> bool
pub fn is_child_empty(&self, child: usize) -> bool
Sourcepub fn child_primitives(&self, child: usize) -> (u32, u32)
pub fn child_primitives(&self, child: usize) -> (u32, u32)
Returns the primitive starting index and primitive count for the given child.
Sourcepub fn child_node_index(&self, child: usize) -> u32
pub fn child_node_index(&self, child: usize) -> u32
Returns the node index of the given child.
Trait Implementations§
impl Copy for CwBvhNode
impl Pod for CwBvhNode
impl StructuralPartialEq for CwBvhNode
Auto Trait Implementations§
impl Freeze for CwBvhNode
impl RefUnwindSafe for CwBvhNode
impl Send for CwBvhNode
impl Sync for CwBvhNode
impl Unpin for CwBvhNode
impl UnwindSafe for CwBvhNode
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.