Skip to main content

BvhBuild

Struct BvhBuild 

Source
pub struct BvhBuild { /* private fields */ }
Expand description

Bvh::build cut into steps, so that a caller can yield between them: the triangles’ boxes are collected, then the tree is built a bounded amount of work per step, then its treelets are assigned (subtree counts, roots and costs), also a bounded amount per step.

The tree is the same, slot for slot and bit for bit, as from Bvh::build, with or without the parallel feature (with it, a step builds several small subtrees at once). The build is tied to the mesh state it started from (BvhBuild::is_for).

Implementations§

Source§

impl BvhBuild

Source

pub fn new(mesh: &Mesh, options: &BuildOptions) -> Result<BvhBuild>

A build of a BVH over the alive triangles of mesh as it is now, with nothing done yet. Only memory is reserved here: the leaf table (tri_leaf, one entry per triangle slot) is zeroed by the prim scan in BvhBuild::step instead, so one call of new stays short even on a large mesh (a background add runs it inside a step).

§Errors

BvhError::InvalidOptions; out of memory.

Source

pub fn is_for(&self, mesh: &Mesh) -> bool

Whether the build started from mesh as it is now.

Source

pub fn is_done(&self) -> bool

Whether the BVH is built.

Source

pub fn step(&mut self, mesh: &Mesh, budget: usize) -> Result<bool>

Builds about budget more units of work (at least some, unless done): a triangle’s box collected, a triangle visited while the tree is built (each triangle about once per tree level), 64 nodes’ subtree counts, or 32 triangles of a treelet’s cost. Returns whether the BVH is built.

§Errors

BvhError::InvalidOptions when mesh is not the state the build started from; out of memory. The build is unusable after an error.

Source

pub fn finish(self) -> Option<Bvh>

The BVH, once built; None before.

Trait Implementations§

Source§

impl Debug for BvhBuild

Source§

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

Formats the value using the given formatter. Read more

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> 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, 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.