21template<
class Tmorton,
class Tvec, u32 dim>
23 make_empty(sham::DeviceScheduler_ptr dev_sched) {
27 KarrasRadixTree::make_empty(dev_sched),
31template<
class Tmorton,
class Tvec, u32 dim>
36 u32 compression_level) {
41 "obj_cnt is 0, cannot build a CompressedLeafBVH");
44 auto dev_sched = shamsys::instance::get_compute_scheduler_ptr();
48 auto set = shamtree::morton_code_set_from_positions<Tmorton, Tvec, dim>(
54 std::move(reduced_morton_set.morton_codes_set.sorted_morton_codes));
56 auto sorted_set = shamtree::sort_morton_set(
59 std::move(reduced_morton_set.morton_codes_set.map_morton_id_to_obj_id));
61 auto reduced_set = shamtree::reduce_morton_set(
63 std::move(sorted_set),
65 std::move(reduced_morton_set.buf_reduc_index_map),
66 std::move(reduced_morton_set.reduced_morton_codes));
68 auto tree = shamtree::karras_tree_from_morton_set(
70 reduced_set.reduced_morton_codes.get_size(),
71 reduced_set.reduced_morton_codes,
72 std::move(structure));
74 this->reduced_morton_set = std::move(reduced_set);
75 this->structure = std::move(tree);
78template<
class Tmorton,
class Tvec, u32 dim>
83 u32 compression_level) {
85 this->internal_rebuild_from_positions_no_aabb(
86 positions, obj_cnt, bounding_box, compression_level);
90 this->reduced_morton_set.get_leaf_cell_iterator(),
91 std::move(this->aabbs),
94 this->aabbs = std::move(tree_aabbs);
97template<
class Tmorton,
class Tvec, u32 dim>
103 u32 compression_level) {
105 this->internal_rebuild_from_positions_no_aabb(min, obj_cnt, bounding_box, compression_level);
109 this->reduced_morton_set.get_leaf_cell_iterator(),
110 std::move(this->aabbs),
114 this->aabbs = std::move(tree_aabbs);
117template<
class Tmorton,
class Tvec, u32 dim>
121 u32 compression_level) {
122 this->rebuild_from_positions(positions, positions.
get_size(), bounding_box, compression_level);
125template<
class Tmorton,
class Tvec, u32 dim>
130 u32 compression_level) {
131 if (min.get_size() != max.get_size()) {
133 "min and max must have the same size");
135 this->rebuild_from_position_range(min, max, min.get_size(), bounding_box, compression_level);
KarrasRadixTreeAABB< Tvec > compute_tree_aabb_from_position_ranges(const KarrasRadixTree &tree, const LeafCellIterator &cell_it, KarrasRadixTreeAABB< Tvec > &&recycled_tree_aabb, sham::DeviceBuffer< Tvec > &min, sham::DeviceBuffer< Tvec > &max)
same but for position ranges
KarrasRadixTreeAABB< Tvec > compute_tree_aabb_from_positions(const KarrasRadixTree &tree, const LeafCellIterator &cell_it, KarrasRadixTreeAABB< Tvec > &&recycled_tree_aabb, sham::DeviceBuffer< Tvec > &positions)
Compute the AABB of all cells in the tree from positions.
std::uint32_t u32
32 bit unsigned integer
A buffer allocated in USM (Unified Shared Memory)
size_t get_size() const
Gets the number of elements in the buffer.
A Compressed Leaf Bounding Volume Hierarchy (CLBVH) for neighborhood queries.
void rebuild_from_positions(sham::DeviceBuffer< Tvec > &positions, const shammath::AABB< Tvec > &bounding_box, u32 compression_level)
rebuild the BVH from the given positions
static CompressedLeafBVH make_empty(sham::DeviceScheduler_ptr dev_sched)
make an empty BVH
Class representing a set of Morton codes with associated bounding box and position data that was redu...
This header file contains utility functions related to exception handling in the code.
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
constexpr T roundup_pow2(T v) noexcept
round up to the next power of two Source : https://graphics.stanford.edu/~seander/bithacks....
This file contains the definition for the stacktrace related functionality.
#define __shamrock_stack_entry()
Macro to create a stack entry.
Axis-Aligned bounding box.