21template<
class Tmorton,
class Tvec, u32 dim>
23 make_empty(sham::DeviceScheduler_ptr dev_sched) {
26 MortonReducedSet<Tmorton, Tvec, dim>::make_empty(dev_sched),
27 KarrasRadixTree::make_empty(dev_sched),
28 KarrasRadixTreeAABB<Tvec>::make_empty(dev_sched)};
31template<
class Tmorton,
class Tvec, u32 dim>
32void shamtree::CompressedLeafBVH<Tmorton, Tvec, dim>::internal_rebuild_from_positions_no_aabb(
36 u32 compression_level) {
41 "obj_cnt is 0, cannot build a CompressedLeafBVH");
44 auto dev_sched = shamsys::instance::get_compute_scheduler_ptr();
54 std::move(reduced_morton_set.morton_codes_set.sorted_morton_codes));
59 std::move(reduced_morton_set.morton_codes_set.map_morton_id_to_obj_id));
63 std::move(sorted_set),
65 std::move(reduced_morton_set.buf_reduc_index_map),
66 std::move(reduced_morton_set.reduced_morton_codes));
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);
91 std::move(this->aabbs),
94 this->
aabbs = std::move(tree_aabbs);
97template<
class Tmorton,
class Tvec, u32 dim>
98void shamtree::CompressedLeafBVH<Tmorton, Tvec, dim>::rebuild_from_position_range(
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) {
125template<
class Tmorton,
class Tvec, u32 dim>
126void shamtree::CompressedLeafBVH<Tmorton, Tvec, dim>::rebuild_from_position_range(
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.
KarrasRadixTree karras_tree_from_morton_set(sham::DeviceScheduler_ptr dev_sched, u32 morton_count, sham::DeviceBuffer< Tmorton > &morton_codes, KarrasRadixTree &&recycled_tree)
Constructs a KarrasRadixTree from a set of reduced Morton codes.
MortonCodeSet< Tmorton, Tvec, dim > morton_code_set_from_positions(const sham::DeviceScheduler_ptr &dev_sched, shammath::AABB< Tvec > bounding_box, sham::DeviceBuffer< Tvec > &pos_buf, u32 cnt_obj, u32 morton_count, sham::DeviceBuffer< Tmorton > &&cache_buf_morton_codes)
Generate a set of Morton codes from a buffer of positions.
MortonCodeSortedSet< Tmorton, Tvec, dim > sort_morton_set(const sham::DeviceScheduler_ptr &dev_sched, MortonCodeSet< Tmorton, Tvec, dim > &&morton_codes_set)
Sorts a set of Morton codes and creates a new MortonCodeSortedSet object with the sorted codes and th...
MortonReducedSet< Tmorton, Tvec, dim > reduce_morton_set(const sham::DeviceScheduler_ptr &dev_sched, MortonCodeSortedSet< Tmorton, Tvec, dim > &&morton_codes_set, u32 reduction_level)
Reduces the given Morton code set by grouping together Morton codes that are close to each other in t...
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.
KarrasRadixTreeAABB< Tvec > aabbs
The bounding box of the tree cells.
MortonReducedSet< Tmorton, Tvec, dim > reduced_morton_set
The reduced set of Morton codes.
void rebuild_from_positions(sham::DeviceBuffer< Tvec > &positions, const shammath::AABB< Tvec > &bounding_box, u32 compression_level)
rebuild the BVH from the given positions
KarrasRadixTree structure
The tree structure.
static CompressedLeafBVH make_empty(sham::DeviceScheduler_ptr dev_sched)
make an empty BVH
This header file contains utility functions related to exception handling in the code.
constexpr T roundup_pow2(T v) noexcept
round up to the next power of two Source : https://graphics.stanford.edu/~seander/bithacks....
ExcptTypes make_except_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Create an exception with a message and a location.
This file contains the definition for the stacktrace related functionality.
#define __shamrock_stack_entry()
Macro to create a stack entry.
shambase::details::BasicStackEntry StackEntry
Alias for shambase::details::BasicStackEntry.
Axis-Aligned bounding box.