Bvh2Node

Struct Bvh2Node 

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

The bounding box for the primitive(s) contained in this node

§prim_count: u32

Number 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: u32

The 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:

  1. Layout the primitives in the order of the primitive_indices mapping so that this can index directly into the primitive list.
  2. Only allow one primitive per node and write back the original mapping to the bvh node list.
§meta1: u32

With 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: u32

With 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

Source

pub fn new(aabb: Aabb, prim_count: u32, first_index: u32) -> Self

Source

pub fn aabb(&self) -> &Aabb

Source

pub fn set_aabb(&mut self, aabb: Aabb)

Source

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)

Source

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.

Source

pub fn set_invalid(&mut self)

Used internally for partial BVH rebuilds.

Source

pub fn set_valid(&mut self)

Used internally for partial BVH rebuilds.

Source

pub fn is_left_sibling(node_id: usize) -> bool

Source

pub fn get_sibling_id(node_id: usize) -> usize

Source

pub fn get_left_sibling_id(node_id: usize) -> usize

Source

pub fn get_right_sibling_id(node_id: usize) -> usize

Source

pub fn is_left_sibling32(node_id: u32) -> bool

Source

pub fn get_sibling_id32(node_id: u32) -> u32

Source

pub fn get_left_sibling_id32(node_id: u32) -> u32

Source

pub fn get_right_sibling_id32(node_id: u32) -> u32

Source

pub fn make_inner(&mut self, first_index: u32)

Trait Implementations§

Source§

impl Clone for Bvh2Node

Source§

fn clone(&self) -> Bvh2Node

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 Bvh2Node

Source§

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

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

impl Default for Bvh2Node

Source§

fn default() -> Bvh2Node

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

impl Zeroable for Bvh2Node

Source§

fn zeroed() -> Self

Source§

impl Copy for Bvh2Node

Source§

impl Pod for Bvh2Node

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,