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
impl BvhBuild
Sourcepub fn new(mesh: &Mesh, options: &BuildOptions) -> Result<BvhBuild>
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.
Sourcepub fn step(&mut self, mesh: &Mesh, budget: usize) -> Result<bool>
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.