pub struct PlocBuilder {
pub current_nodes: Vec<Bvh2Node>,
pub next_nodes: Vec<Bvh2Node>,
pub mortons: Vec<[u128; 2]>,
}Fields§
§current_nodes: Vec<Bvh2Node>§next_nodes: Vec<Bvh2Node>§mortons: Vec<[u128; 2]>Implementations§
Source§impl PlocBuilder
impl PlocBuilder
Sourcepub fn full_rebuild(
&mut self,
bvh: &mut Bvh2,
search_distance: PlocSearchDistance,
sort_precision: SortPrecision,
search_depth_threshold: usize,
)
pub fn full_rebuild( &mut self, bvh: &mut Bvh2, search_distance: PlocSearchDistance, sort_precision: SortPrecision, search_depth_threshold: usize, )
Fully rebuild the bvh from its current leaves.
§Arguments
bvh- An existing bvh with valid leaves. Inner nodes are ignored.search_distance- Which search distance should be used when building the ploc.sort_precision- Bits used for ploc radix sort. More bits results in a more accurate but slower sort.search_depth_threshold- Below this depth a search distance of 1 will be used. Set to 0 to bypass and just use search_distance.
Sourcepub fn partial_rebuild(
&mut self,
bvh: &mut Bvh2,
should_remove: impl Fn(usize) -> bool,
search_distance: PlocSearchDistance,
sort_precision: SortPrecision,
search_depth_threshold: usize,
)
pub fn partial_rebuild( &mut self, bvh: &mut Bvh2, should_remove: impl Fn(usize) -> bool, search_distance: PlocSearchDistance, sort_precision: SortPrecision, search_depth_threshold: usize, )
Partially rebuild the bvh. The given set of leaves and the subtrees that do not include any of the given leaves will be built into a new bvh. If the set of leaves is a small enough proportion of the total this can be faster since there may be large portions of the BVH that don’t need to be updated. If the proportion is very high it can be faster to build from scratch instead, avoiding the overhead of doing a partial rebuild. If only a few nodes need to be updated it might be faster and produce a better BVH to selectively reinsert them.
§Arguments
bvh- An existing bvh with valid layout (AABBs in the tree above nodes that are to be rebuilt does not need to be correct)should_remove()- should return true for any node that should be include in the rebuild. This includes the entire chain up from any leaves that need to be updated. Use PlocBuilder::compute_rebuild_path_flags() or similar to compute. The leaves should have their new AABB before calling partial_rebuild() but the BVH does not need to be refit to accommodate them.search_distance- Which search distance should be used when building the ploc.sort_precision- Bits used for ploc radix sort. More bits results in a more accurate but slower sort.search_depth_threshold- Below this depth a search distance of 1 will be used. Set to 0 to bypass and just use search_distance.
Source§impl PlocBuilder
impl PlocBuilder
Sourcepub fn new() -> PlocBuilder
pub fn new() -> PlocBuilder
Initialize a ploc builder. After initial building, keep around this builder to reuse the associated allocations.
Sourcepub fn with_capacity(prim_count: usize) -> PlocBuilder
pub fn with_capacity(prim_count: usize) -> PlocBuilder
Initialize a ploc builder with pre-allocated capacity for building a bvh with prim_count. After initial building, keep around this builder to reuse the associated allocations.
Sourcepub fn build<T: Boundable>(
&mut self,
search_distance: PlocSearchDistance,
aabbs: &[T],
indices: Vec<u32>,
sort_precision: SortPrecision,
search_depth_threshold: usize,
) -> Bvh2
pub fn build<T: Boundable>( &mut self, search_distance: PlocSearchDistance, aabbs: &[T], indices: Vec<u32>, sort_precision: SortPrecision, search_depth_threshold: usize, ) -> Bvh2
§Arguments
search_distance- Which search distance should be used when building the ploc.aabbs- A list of bounding boxes. Should correspond to the number and order of primitives.indices- The list indices used to index into the list of primitives. This allows for flexibility in which primitives are included in the bvh and in what order they are referenced. Often this would just be equivalent to: (0..aabbs.len() as u32).collect::<Vec<_>>()sort_precision- Bits used for ploc radix sort. More bits results in a more accurate but slower sort.search_depth_threshold- Below this depth a search distance of 1 will be used. Set to 0 to bypass and just use PlocSearchDistance. When trying to optimize build time it can be beneficial to limit the search distance for the first few passes as that is when the largest number of primitives are being considered. This pairs are initially found more quickly since it doesn’t need to search as far, and they are also found more often, since the nodes need to both agree to become paired. This also seems to occasionally result in an overall better bvh structure.
Sourcepub fn build_with_bvh<T: Boundable>(
&mut self,
bvh: &mut Bvh2,
search_distance: PlocSearchDistance,
aabbs: &[T],
indices: Vec<u32>,
sort_precision: SortPrecision,
search_depth_threshold: usize,
)
pub fn build_with_bvh<T: Boundable>( &mut self, bvh: &mut Bvh2, search_distance: PlocSearchDistance, aabbs: &[T], indices: Vec<u32>, sort_precision: SortPrecision, search_depth_threshold: usize, )
§Arguments
bvh- An existing bvh. The builder will clear this bvh and reuse its allocations.search_distance- Which search distance should be used when building the ploc.aabbs- A list of bounding boxes. Should correspond to the number and order of primitives.indices- The list indices used to index into the list of primitives. This allows for flexibility in which primitives are included in the bvh and in what order they are referenced. Often this would just be equivalent to: (0..aabbs.len() as u32).collect::<Vec<_>>()sort_precision- Bits used for ploc radix sort. More bits results in a more accurate but slower sort.search_depth_threshold- Below this depth a search distance of 1 will be used. Set to 0 to bypass and just use PlocSearchDistance. When trying to optimize build time it can be beneficial to limit the search distance for the first few passes as that is when the largest number of primitives are being considered. This pairs are initially found more quickly since it doesn’t need to search as far, and they are also found more often, since the nodes need to both agree to become paired. This also seems to occasionally result in an overall better bvh structure.
Sourcepub fn build_ploc<const SEARCH_DISTANCE: usize, T: Boundable>(
&mut self,
bvh: &mut Bvh2,
aabbs: &[T],
indices: Vec<u32>,
sort_precision: SortPrecision,
search_depth_threshold: usize,
)
pub fn build_ploc<const SEARCH_DISTANCE: usize, T: Boundable>( &mut self, bvh: &mut Bvh2, aabbs: &[T], indices: Vec<u32>, sort_precision: SortPrecision, search_depth_threshold: usize, )
§Arguments
bvh- An existing bvh. The builder will clear this bvh and reuse its allocations.aabbs- A list of bounding boxes. Should correspond to the number and order of primitives.sort_precision- Bits used for ploc radix sort. More bits results in a more accurate but slower sort.search_depth_threshold- Below this depth a search distance of 1 will be used. Set to 0 to bypass and just use SEARCH_DISTANCE.
SEARCH_DISTANCE should be <= 32
Sourcepub fn build_ploc_from_leaves<const SEARCH_DISTANCE: usize, const REBUILD: bool>(
&mut self,
bvh: &mut Bvh2,
total_aabb: Aabb,
sort_precision: SortPrecision,
search_depth_threshold: usize,
)
pub fn build_ploc_from_leaves<const SEARCH_DISTANCE: usize, const REBUILD: bool>( &mut self, bvh: &mut Bvh2, total_aabb: Aabb, sort_precision: SortPrecision, search_depth_threshold: usize, )
Prefer using Bvh2::build(), Bvh2::build_with_bvh(), Bvh2::build_ploc(), Bvh2::partial_rebuild(), or Bvh2::full_rebuild(). This is only public for non-typical usages. REBUILD is for partial BVH rebuilds. In that case inner nodes should be freed by setting them to invalid (with Bvh2Node::set_invalid()) and both respective inner and leaf nodes moved on to PlocBuilder::current_nodes. They must always be removed in pairs with the starting on an odd number. See PlocBuilder::partial_rebuild()
Trait Implementations§
Source§impl Clone for PlocBuilder
impl Clone for PlocBuilder
Source§fn clone(&self) -> PlocBuilder
fn clone(&self) -> PlocBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more