1#ifndef BVH_V2_SWEEP_SAH_BUILDER_H
2#define BVH_V2_SWEEP_SAH_BUILDER_H
17template <
typename Node>
31 std::span<const BBox> bboxes,
32 std::span<const Vec> centers,
50 std::span<const BBox> bboxes,
51 std::span<const Vec> centers,
55 marks_.resize(bboxes.size());
56 accum_.resize(bboxes.size());
61 return centers[i][axis] < centers[
j][axis];
73 for (
size_t i = end - 1; i > begin;) {
74 static constexpr size_t chunk_size = 32;
75 size_t next = i - std::min(i - begin, chunk_size);
77 for (; i > next; --i) {
108 std::optional<size_t>
try_split(
const BBox& bbox,
size_t begin,
size_t end)
override {
117 if (end - begin <=
config_.max_leaf_size)
132 std::stable_partition(
135 [&] (
size_t i) {
return marks_[i]; });
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Single-threaded top-down builder that partitions primitives based on the Surface Area Heuristic (SAH)...
BVH_ALWAYS_INLINE SweepSahBuilder(std::span< const BBox > bboxes, std::span< const Vec > centers, const Config &config)
std::vector< size_t > & get_prim_ids() override
std::vector< size_t > prim_ids_[Node::dimension]
void find_best_split(size_t axis, size_t begin, size_t end, Split &best_split)
static BVH_ALWAYS_INLINE Bvh< Node > build(std::span< const BBox > bboxes, std::span< const Vec > centers, const Config &config={})
BVH_ALWAYS_INLINE void mark_primitives(size_t axis, size_t begin, size_t split_pos, size_t end)
std::vector< Scalar > accum_
std::optional< size_t > try_split(const BBox &bbox, size_t begin, size_t end) override
std::vector< bool > marks_
Base class for all SAH-based, top-down builders.
typename Node::Scalar Scalar
std::span< const BBox > bboxes_
BVH_ALWAYS_INLINE Vec< T, N > get_diagonal() const
static BVH_ALWAYS_INLINE constexpr BBox make_empty()
Binary BVH node, containing its bounds and an index into its children or the primitives it contains.
static constexpr size_t dimension