CwBvhNode

Struct CwBvhNode 

Source
#[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: Vec3

Min 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: u8

Bitmask indicating which children are internal nodes. 1 for internal, 0 for leaf

§child_base_idx: u32

Index of first child into Vec<CwBvhNode>

§primitive_base_idx: u32

Index 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

Source

pub fn intersect_ray(&self, ray: &Ray, oct_inv4: u32) -> u32

Source

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.

Source

pub fn intersect_aabb(&self, aabb: &Aabb, oct_inv4: u32) -> u32

Source

pub fn contains_point(&self, point: &Vec3A, oct_inv4: u32) -> u32

Source

pub fn get_child_and_index_bits(&self, oct_inv4: u32) -> (u64, u64)

Source

pub fn local_child_aabb(&self, child: usize) -> Aabb

Get local child aabb position relative to the parent

Source

pub fn child_aabb(&self, child: usize) -> Aabb

Source

pub fn aabb(&self) -> Aabb

Source

pub fn compute_extent(&self) -> Vec3A

Convert stored extent exponent into float vector

Source

pub fn is_leaf(&self, child: usize) -> bool

Source

pub fn is_child_empty(&self, child: usize) -> bool

Source

pub fn child_primitives(&self, child: usize) -> (u32, u32)

Returns the primitive starting index and primitive count for the given child.

Source

pub fn child_node_index(&self, child: usize) -> u32

Returns the node index of the given child.

Source§

impl CwBvhNode

Source

pub fn intersect_ray_simd(&self, ray: &Ray, oct_inv4: u32) -> u32

Trait Implementations§

Source§

impl Clone for CwBvhNode

Source§

fn clone(&self) -> CwBvhNode

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CwBvhNode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CwBvhNode

Source§

fn default() -> CwBvhNode

Returns the “default value” for a type. Read more
Source§

impl PartialEq for CwBvhNode

Source§

fn eq(&self, other: &CwBvhNode) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Zeroable for CwBvhNode

Source§

fn zeroed() -> Self

Source§

impl Copy for CwBvhNode

Source§

impl Pod for CwBvhNode

Source§

impl StructuralPartialEq for CwBvhNode

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CheckedBitPattern for T
where T: AnyBitPattern,

Source§

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

If this function returns true, then it must be valid to reinterpret bits as &Self.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> AnyBitPattern for T
where T: Pod,

Source§

impl<T> NoUninit for T
where T: Pod,