1#ifndef BVH_V2_BINNED_SAH_BUILDER_H
2#define BVH_V2_BINNED_SAH_BUILDER_H
18template <
typename Node,
size_t BinCount = 8>
33 std::span<const BBox> bboxes,
34 std::span<const Vec> centers,
65 using Bins = std::array<Bin, BinCount>;
71 std::span<const BBox> bboxes,
72 std::span<const Vec> centers,
91 for (
size_t i = begin; i < end; ++i) {
104 for (
size_t i =
BinCount - 1; i > 0; --i) {
110 for (
size_t i = 0; i <
BinCount - 1; ++i) {
119 size_t mid = (begin + end + 1) / 2;
124 [&] (
size_t i,
size_t j) { return centers_[i][axis] < centers_[j][axis]; });
128 std::optional<size_t>
try_split(
const BBox& bbox,
size_t begin,
size_t end)
override {
140 if (end - begin <=
config_.max_leaf_size)
151 [&] (
size_t i) { return centers_[i][best_split.axis] < split_pos; }) -
prim_ids_.begin();
155 return std::make_optional(
index);
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Single-threaded top-down builder that partitions primitives based on a binned approximation of the Su...
size_t fallback_split(size_t axis, size_t begin, size_t end)
std::array< Bin, BinCount > Bins
BVH_ALWAYS_INLINE void fill_bins(PerAxisBins &per_axis_bins, const BBox &bbox, size_t begin, size_t end)
std::array< Bins, Node::dimension > PerAxisBins
std::optional< size_t > try_split(const BBox &bbox, size_t begin, size_t end) override
void find_best_split(size_t axis, const Bins &bins, Split &best_split)
static BVH_ALWAYS_INLINE Bvh< Node > build(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_
BVH_ALWAYS_INLINE BinnedSahBuilder(std::span< const BBox > bboxes, std::span< const Vec > centers, const Config &config)
Base class for all SAH-based, top-down builders.
bvh::v2::Vec< Scalar, Node::dimension > Vec
std::span< const Vec > centers_
typename Node::Scalar Scalar
std::span< const BBox > bboxes_
BVH_ALWAYS_INLINE T robust_max(T a, T b)
BVH_ALWAYS_INLINE T fast_mul_add(T a, T b, T c)
Fast multiply-add operation.
BVH_ALWAYS_INLINE Vec< T, N > get_diagonal() const
BVH_ALWAYS_INLINE BBox & extend(const Vec< T, N > &point)
static BVH_ALWAYS_INLINE constexpr BBox make_empty()
BVH_ALWAYS_INLINE void add(const BBox &bbox, size_t prim_count=1)
BVH_ALWAYS_INLINE Scalar get_cost(const SplitHeuristic< Scalar > &sah) const
BVH_ALWAYS_INLINE void add(const Bin &bin)
Binary BVH node, containing its bounds and an index into its children or the primitives it contains.
static constexpr size_t dimension