EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
EBGeometry_PackedBVH.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2022 Robert Marskar <robert.marskar@sintef.no>
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
15#ifndef EBGEOMETRY_PACKEDBVH_HPP
16#define EBGEOMETRY_PACKEDBVH_HPP
17
18// Std includes
19#include <cmath>
20#include <cstddef>
21#include <cstdint>
22#include <functional>
23#include <memory>
24#include <type_traits>
25#include <utility>
26#include <vector>
27
28#if defined(__SSE4_1__) || defined(__AVX__)
29#include <immintrin.h>
30#endif
31
32// Our includes
33#include "EBGeometry_Array.hpp"
36#include "EBGeometry_Macros.hpp"
37#include "EBGeometry_Math.hpp"
39#include "EBGeometry_Pool.hpp"
40#include "EBGeometry_Vec.hpp"
41
42namespace EBGeometry {
43
44namespace SFC {
45struct Morton;
46} // namespace SFC
47
51namespace BVH {
52
64enum class Construction
65{
71 SAH,
76 Morton,
77 Nested,
78 Hilbert
79};
80
94{
95 size_t maxClusterSize = 8;
96};
97
120
128inline constexpr size_t HostTraversalDepth = 256;
129
138inline constexpr size_t DeviceTraversalDepth = 32;
139
155template <typename T>
156[[nodiscard]] constexpr size_t
158{
159 static_assert(std::is_floating_point_v<T>, "BVH::DefaultBranchingRatio requires a floating-point T");
160
161 return 4;
162}
163
182template <typename T>
183[[nodiscard]] constexpr size_t
185{
186 static_assert(std::is_floating_point_v<T>, "BVH::HostBranchingRatio requires a floating-point T");
187#if defined(__AVX512F__)
188 if constexpr (std::is_same_v<T, double>) {
189 return 8;
190 }
191 else {
192 return 16;
193 }
194#elif defined(__AVX__)
195 if constexpr (std::is_same_v<T, double>) {
196 return 4;
197 }
198 else {
199 return 8;
200 }
201#else
202 return 4;
203#endif
204}
205
210template <class T, class P, class BV, size_t K>
211class TreeBVH;
212
217template <class P>
218using PrimitiveList = std::vector<std::shared_ptr<const P>>;
219
223template <class T, class P, size_t K>
224class PackedBVH;
225
229namespace RefitDetail {
230template <class Bvh, class BVConstructor>
231struct Level;
232} // namespace RefitDetail
233
239template <class P, class BV>
240using PrimAndBV = std::pair<std::shared_ptr<const P>, BV>;
241
247template <class P, class BV>
248using PrimAndBVList = std::vector<PrimAndBV<P, BV>>;
249
263template <class P, class BV, size_t K>
264using Partitioner = std::function<Array<PrimAndBVList<P, BV>, K>(PrimAndBVList<P, BV> a_primsAndBVs)>;
265
275template <class T, class P, class BV, size_t K>
276using LeafPredicate = std::function<bool(const TreeBVH<T, P, BV, K>& a_node)>;
277
284template <class P>
285using LeafEvaluator = std::function<void(const PrimitiveList<P>& a_primitives)>;
286
298template <class NodeType, class NodeKey>
299using PrunePredicate = std::function<bool(const NodeType& a_node, const NodeKey& a_nodeKey)>;
300
310template <class NodeType, class NodeKey, size_t K>
311using ChildOrderer = std::function<void(Array<std::pair<std::shared_ptr<const NodeType>, NodeKey>, K>& a_children)>;
312
322template <class NodeType, class NodeKey>
323using NodeKeyFactory = std::function<NodeKey(const NodeType& a_node)>;
324
367template <class T, class P, size_t K>
368class PackedBVH final : public PoolHandle
369{
370 static_assert(std::is_floating_point_v<T>, "PackedBVH: T must be a floating-point type");
371 static_assert(K >= 2, "PackedBVH: branching factor K must be at least 2");
372 static_assert(K <= 256, "PackedBVH: branching factor K must be at most 256, so a child slot fits in a byte");
373 static_assert(!isPoolHandle<P>,
374 "PackedBVH: a primitive stored in a pool must hold no location; store the handle's Layout "
375 "and pair it with this BVH's location() (see PoolHandle)");
376
377public:
382
392 struct Node
393 {
397 uint32_t m_primOff{};
398
402 uint32_t m_numPrims{};
403
408
415 uint32_t m_childBoxRow{};
416
422 uint32_t m_boxSlot{};
423
429 inline void
430 setPrimitivesOffset(uint32_t a_off) noexcept
431 {
432 m_primOff = a_off;
433 }
434
440 inline void
441 setNumPrimitives(uint32_t a_n) noexcept
442 {
443 m_numPrims = a_n;
444 }
445
452 inline void
453 setChildOffset(uint32_t a_off, size_t a_k) noexcept
454 {
455 EBGEOMETRY_EXPECT(a_k < K);
456 m_childOff[a_k] = a_off;
457 }
458
463 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
464 inline uint32_t
465 getPrimitivesOffset() const noexcept
466 {
467 return m_primOff;
468 }
469
474 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
475 inline uint32_t
476 getNumPrimitives() const noexcept
477 {
478 return m_numPrims;
479 }
480
485 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
486 inline const Array<uint32_t, K>&
487 getChildOffsets() const noexcept
488 {
489 return m_childOff;
490 }
491
496 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
497 inline uint32_t
498 getChildBoxRow() const noexcept
499 {
500 return m_childBoxRow;
501 }
502
507 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
508 inline uint32_t
509 getBoxSlot() const noexcept
510 {
511 return m_boxSlot;
512 }
513
518 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
519 inline bool
520 isLeaf() const noexcept
521 {
522 return m_numPrims > 0;
523 }
524 };
525
529 static constexpr uint32_t RootBoxSlot = UINT32_MAX;
530
535 PackedBVH() = delete;
536
541 struct Layout;
542
553 inline PackedBVH(const Layout& a_layout, const PoolLocation& a_location) noexcept;
554
559 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
560 inline Layout
561 layout() const noexcept;
562
572 inline PackedBVH(Pool& a_pool, const TreeBVH<T, P, BV, K>& a_tree);
573
603 template <class Q, class Converter>
605 inline PackedBVH(Pool& a_pool, const TreeBVH<T, Q, BV, K>& a_tree, Converter&& a_converter);
606
614 [[nodiscard]] EBGEOMETRY_HOST
615 static inline BVH::ConstructionOptions
617 {
618 return BVH::ConstructionOptions{K - 1, K, BVH::ClusterSpec{}};
619 }
620
634 [[nodiscard]] EBGEOMETRY_HOST
635 static inline PackedBVH
636 build(Pool& a_pool,
637 std::vector<std::pair<P, BV>> a_primsAndBVs,
638 BVH::Construction a_construction,
640
667 template <class S = SFC::Morton>
668 [[nodiscard]] EBGEOMETRY_HOST
669 static inline PackedBVH
670 buildBottomUp(Pool& a_pool, std::vector<std::pair<P, BV>> a_primsAndBVs, size_t a_targetLeafSize);
671
702 [[nodiscard]] EBGEOMETRY_HOST
703 static inline PackedBVH
705 std::vector<std::pair<P, BV>> a_primsAndBVs,
706 const BVH::Partitioner<P, BV, K>& a_partitioner,
707 const BVH::LeafPredicate<T, P, BV, K>& a_stopCrit);
708
719 [[nodiscard]] EBGEOMETRY_HOST
720 static inline PackedBVH
722 std::vector<std::pair<P, BV>> a_primsAndBVs,
723 const BVH::Partitioner<P, BV, K>& a_partitioner);
724
743 [[nodiscard]] EBGEOMETRY_HOST
744 static inline PackedBVH
745 buildClusterSAH(Pool& a_pool, std::vector<std::pair<P, BV>> a_primsAndBVs, BVH::ClusterSpec a_spec);
746
767 inline PackedBVH(Pool& a_pool,
768 const std::vector<Node>& a_linearNodes,
769 const std::vector<BV>& a_nodeBoxes,
770 const std::vector<P>& a_primitives)
771 {
772 this->finalize(a_pool, a_linearNodes, a_nodeBoxes, a_primitives);
773 }
774
780 inline ~PackedBVH() = default;
781
790 PackedBVH(const PackedBVH& a_other) = default;
791
797 PackedBVH&
798 operator=(const PackedBVH& a_other) = default;
799
806 PackedBVH(PackedBVH&& a_other) noexcept = default;
807
813 PackedBVH&
814 operator=(PackedBVH&& a_other) noexcept = default;
815
823 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
824 inline PODSpan<const P>
825 getPrimitives() const noexcept;
826
841 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
842 inline PODSpan<P>
843 getPrimitives() noexcept;
844
853 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
854 inline PODSpan<const Node>
855 getNodes() const noexcept;
856
867 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
868 static constexpr size_t
870 {
871#if defined(EBGEOMETRY_DEVICE_COMPILE)
872 return PackedBVH::stackEntriesFor(DeviceTraversalDepth);
873#else
874 return PackedBVH::stackEntriesFor(HostTraversalDepth);
875#endif
876 }
877
882 using PoolHandle::base;
883
901 [[nodiscard]] EBGEOMETRY_HOST
902 inline PackedBVH
903 rebasedView(const Pool& a_pool) const noexcept;
904
912 [[nodiscard]] EBGEOMETRY_HOST
913 inline PackedBVH
914 deepCopy(Pool& a_dstPool) const;
915
922 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
923 inline const BV&
924 getBoundingVolume() const noexcept;
925
935 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
936 inline BV
937 getBoundingVolume(const Node& a_node) const noexcept;
938
949 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
950 inline T
951 getDistanceToBoundingVolume2(const Node& a_node, const Vec3T<T>& a_point) const noexcept;
952
965 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
966 inline T
967 getDistanceToChildBoundingVolume2(const Node& a_parent, size_t a_k, const Vec3T<T>& a_point) const noexcept;
968
976 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
977 inline BV
978 computeBoundingVolume() const noexcept;
979
1024 template <class Query,
1025 class State,
1026 class LeafEvaluator,
1027 class BoundFn,
1028 class VisitFn = DescendAll,
1029 class Order = NearestFirst>
1031 inline void
1032 traverse(const Query& a_query,
1033 State& a_state,
1034 LeafEvaluator&& a_leaf,
1035 BoundFn&& a_bound,
1036 VisitFn&& a_visit = DescendAll(),
1037 Order a_order = Order()) const noexcept;
1038
1058 template <class BVConstructor>
1059 inline void
1060 refit(const BVConstructor& a_bvConstructor);
1061
1062private:
1066 template <class Bvh, class BVConstructor>
1067 friend struct RefitDetail::Level;
1068
1081 template <class BVConstructor>
1083 inline void
1084 refitNode(void* a_base, uint32_t a_node, const BVConstructor& a_bvConstructor) const;
1085
1101 inline void
1102 finalize(Pool& a_pool,
1103 const std::vector<Node>& a_linearNodes,
1104 const std::vector<BV>& a_nodeBoxes,
1105 const std::vector<P>& a_primitives);
1106
1110 PODVector<Node> m_linearNodes;
1111
1115 PODVector<P> m_primitives;
1116
1121 using ChildAABBSoA = ChildBoxes<T, K>;
1122
1127 PODVector<ChildAABBSoA> m_childAabbSoA;
1128
1133 PODVector<BV> m_rootBox;
1134
1135public:
1161
1162private:
1174 struct StackEntry
1175 {
1177 uint32_t m_node;
1178
1180 uint8_t m_slots[K - 1];
1181
1183 uint8_t m_count;
1184 };
1185
1186 static_assert(K != 4 || sizeof(StackEntry) == 8, "PackedBVH: a stack entry is 8 bytes at K = 4");
1187
1195 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1196 static constexpr size_t
1197 stackEntriesFor(const size_t a_depth) noexcept
1198 {
1199 return a_depth - 1;
1200 }
1201
1210 [[nodiscard]] EBGEOMETRY_HOST
1211 inline size_t
1212 maxNodeDepth(const void* a_base) const;
1213
1224 inline void
1225 requireDepthFits(const void* a_base, const size_t a_maxDepth, const char* a_context) const;
1226
1240 static inline void
1241 requireWellFormed(const std::vector<Node>& a_linearNodes, const size_t a_numPrimitives);
1242
1260 static inline void
1261 boundDepth(std::vector<Node>& a_linearNodes, std::vector<BV>& a_nodeBoxes, std::vector<P>& a_primitives);
1262
1272 inline void
1273 buildSoA(Pool& a_pool, const std::vector<BV>& a_nodeBoxes);
1274
1282 static inline void
1283 setRowBox(ChildAABBSoA& a_soa, size_t a_slot, const BV& a_bv) noexcept;
1284
1291 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1292 static inline BV
1293 rowBox(const ChildAABBSoA& a_soa, size_t a_slot) noexcept;
1294};
1295
1301static_assert(std::is_trivially_copyable_v<PackedBVH<float, Vec3T<float>, 4>>,
1302 "PackedBVH<float, ...> must be trivially copyable");
1303static_assert(std::is_trivially_copyable_v<PackedBVH<double, Vec3T<double>, 4>>,
1304 "PackedBVH<double, ...> must be trivially copyable");
1305
1306} // namespace BVH
1307
1308} // namespace EBGeometry
1309
1310#include "EBGeometry_PackedBVHImplem.hpp"
1311
1312#endif
A fixed-size array that compiles for both host and device.
What PackedBVH::traverse() tracks through a tree: query types, the child-box rows they test,...
Declarations of bounding volume types used in bounding volume hierarchies.
#define EBGEOMETRY_HOST_DEVICE
Mark a function as callable from both host and device code (no-op on host compilers).
Definition EBGeometry_GPU.hpp:80
#define EBGEOMETRY_HOST
Mark a function as callable from host code only (no-op on host compilers).
Definition EBGeometry_GPU.hpp:83
Utility macros for EBGeometry.
#define EBGEOMETRY_EXPECT(cond)
Runtime precondition assertion for EBGeometry.
Definition EBGeometry_Macros.hpp:269
Scalar helpers and numeric limits that compile for both host and device.
Placement-independent POD array views for the GPU memory foundation.
Growable bump arena for the GPU memory foundation.
Declaration of 2D and 3D point/vector classes with templated precision, and free functions on them.
Forward declaration of the linearised BVH, defined below.
Definition EBGeometry_PackedBVH.hpp:369
static PackedBVH buildClusterSAH(Pool &a_pool, std::vector< std::pair< P, BV > > a_primsAndBVs, BVH::ClusterSpec a_spec)
Build directly via ClusterSAH: cluster primitives, then SAH over the clusters.
PODSpan< const P > getPrimitives() const noexcept
Get the global primitive list (in leaf-traversal order).
Layout layout() const noexcept
The BVH's arrays without its location, for storing it inside another pool-resident object.
static constexpr uint32_t RootBoxSlot
The box slot of the root, which has no parent row: its box is the BVH's own.
Definition EBGeometry_PackedBVH.hpp:529
T getDistanceToBoundingVolume2(const Node &a_node, const Vec3T< T > &a_point) const noexcept
Get the squared distance from a_point to one of this BVH's nodes' bounding volume.
EBGeometry::BoundingVolumes::AABBT< T > BV
AABB type used for all bounding volumes in this BVH.
Definition EBGeometry_PackedBVH.hpp:381
PackedBVH()=delete
Deleted default constructor. Use build() (or another static build), TreeBVH::pack() or TreeBVH::packW...
T getDistanceToChildBoundingVolume2(const Node &a_parent, size_t a_k, const Vec3T< T > &a_point) const noexcept
Get the squared distance from a_point to the bounding volume of child a_k of an interior node.
static constexpr size_t traversalStackDepth() noexcept
Traversal stack size, in entries, for the current compilation pass.
Definition EBGeometry_PackedBVH.hpp:869
BV computeBoundingVolume() const noexcept
Compute and return the bounding volume of this BVH.
void refit(const BVConstructor &a_bvConstructor)
Refit every node's bounding volume in place after the primitives have moved.
PackedBVH(Pool &a_pool, const std::vector< Node > &a_linearNodes, const std::vector< BV > &a_nodeBoxes, const std::vector< P > &a_primitives)
Adopt a node array, its boxes and a primitive array built elsewhere.
Definition EBGeometry_PackedBVH.hpp:767
~PackedBVH()=default
Destructor.
PackedBVH & operator=(const PackedBVH &a_other)=default
Copy assignment operator.
PackedBVH(const PackedBVH &a_other)=default
Copy constructor.
PackedBVH(PackedBVH &&a_other) noexcept=default
Move constructor.
PackedBVH & operator=(PackedBVH &&a_other) noexcept=default
Move assignment operator.
friend struct RefitDetail::Level
The per-level functor of BVH::refit(), which calls refitNode().
Definition EBGeometry_PackedBVH.hpp:1067
static PackedBVH buildBottomUp(Pool &a_pool, std::vector< std::pair< P, BV > > a_primsAndBVs, size_t a_targetLeafSize)
Build directly from a flat primitive list along a space-filling curve, without ever building a TreeBV...
void traverse(const Query &a_query, State &a_state, LeafEvaluator &&a_leaf, BoundFn &&a_bound, VisitFn &&a_visit=DescendAll(), Order a_order=Order()) const noexcept
Walk the tree with a query, depth first: the general traversal.
PODSpan< const Node > getNodes() const noexcept
Get the flat node array (depth-first pre-order, root at index 0).
PackedBVH rebasedView(const Pool &a_pool) const noexcept
Produce a copy of this BVH that resolves against a_pool.
PackedBVH deepCopy(Pool &a_dstPool) const
Duplicate this BVH's storage into a_dstPool.
PackedBVH(const Layout &a_layout, const PoolLocation &a_location) noexcept
Rebuild a handle from a stored layout and the location of the pool that holds it.
static PackedBVH buildTopDown(Pool &a_pool, std::vector< std::pair< P, BV > > a_primsAndBVs, const BVH::Partitioner< P, BV, K > &a_partitioner, const BVH::LeafPredicate< T, P, BV, K > &a_stopCrit)
Build directly from a flat primitive list via top-down (optionally SAH) recursive partitioning,...
const BV & getBoundingVolume() const noexcept
Get the bounding volume of the root node.
static PackedBVH buildTopDown(Pool &a_pool, std::vector< std::pair< P, BV > > a_primsAndBVs, const BVH::Partitioner< P, BV, K > &a_partitioner)
Build directly from a primitive list, top-down, with DefaultLeafPredicate.
static BVH::ConstructionOptions defaultConstructionOptions() noexcept
The leaf-size settings build() uses when it is given none.
Definition EBGeometry_PackedBVH.hpp:616
static PackedBVH build(Pool &a_pool, std::vector< std::pair< P, BV > > a_primsAndBVs, BVH::Construction a_construction, const BVH::ConstructionOptions &a_options=defaultConstructionOptions())
Build directly from a flat primitive list with one of the preset methods.
Forward declaration of the tree-structured BVH, defined in EBGeometry_TreeBVH.hpp....
Definition EBGeometry_TreeBVH.hpp:679
Axis-aligned bounding box (AABB) enclosing a set of 3D points.
Definition EBGeometry_BoundingVolumes.hpp:37
Base of every pool-resident handle: the one PoolLocation its arrays resolve against.
Definition EBGeometry_Pool.hpp:563
void * base() noexcept
The base address this handle's offsets resolve against; see PoolLocation::base().
Definition EBGeometry_Pool.hpp:639
Growable bump arena over a MemoryResource.
Definition EBGeometry_Pool.hpp:205
Three-dimensional vector class with arithmetic operators.
Definition EBGeometry_Vec.hpp:258
constexpr size_t HostTraversalDepth
Deepest tree, in node levels (the root alone is one level), that a host traversal handles.
Definition EBGeometry_PackedBVH.hpp:128
std::vector< std::shared_ptr< const P > > PrimitiveList
Convenience alias for a list of shared primitive pointers.
Definition EBGeometry_PackedBVH.hpp:218
std::function< bool(const NodeType &a_node, const NodeKey &a_nodeKey)> PrunePredicate
Node-visit predicate for TreeBVH::traverse().
Definition EBGeometry_PackedBVH.hpp:299
std::function< Array< PrimAndBVList< P, BV >, K >(PrimAndBVList< P, BV > a_primsAndBVs)> Partitioner
Polymorphic partitioner: splits a list of (primitive, BV) pairs into K sub-lists.
Definition EBGeometry_PackedBVH.hpp:264
std::vector< PrimAndBV< P, BV > > PrimAndBVList
Convenience alias for a list of (primitive, bounding-volume) pairs.
Definition EBGeometry_PackedBVH.hpp:248
std::function< bool(const TreeBVH< T, P, BV, K > &a_node)> LeafPredicate
Predicate for deciding when a TreeBVH node should become a leaf (i.e., no further splitting).
Definition EBGeometry_PackedBVH.hpp:276
std::pair< std::shared_ptr< const P >, BV > PrimAndBV
Convenience alias for a (primitive, bounding-volume) pair.
Definition EBGeometry_PackedBVH.hpp:240
std::function< void(const PrimitiveList< P > &a_primitives)> LeafEvaluator
Leaf-evaluation callback for TreeBVH::traverse.
Definition EBGeometry_PackedBVH.hpp:285
std::function< NodeKey(const NodeType &a_node)> NodeKeyFactory
Node-key factory called once per node during TreeBVH::traverse().
Definition EBGeometry_PackedBVH.hpp:323
constexpr size_t DeviceTraversalDepth
Deepest tree, in node levels, that a device traversal handles.
Definition EBGeometry_PackedBVH.hpp:138
constexpr size_t HostBranchingRatio() noexcept
The branching factor K that fills one SIMD register for type T under the compiler's SIMD flags.
Definition EBGeometry_PackedBVH.hpp:184
std::function< void(Array< std::pair< std::shared_ptr< const NodeType >, NodeKey >, K > &a_children)> ChildOrderer
Child-ordering callback for TreeBVH traversal.
Definition EBGeometry_PackedBVH.hpp:311
Construction
The preset BVH construction methods that the library's own BVH users accept.
Definition EBGeometry_PackedBVH.hpp:65
@ Nested
Bottom-up: leaves of consecutive primitives along a Nested (row-major) curve.
@ Hilbert
Bottom-up: leaves of consecutive primitives along a Hilbert curve.
@ Morton
Bottom-up: leaves of consecutive primitives along a Morton (Z-order) curve.
constexpr size_t DefaultBranchingRatio() noexcept
The default branching factor K: 4, for both float and double, in every translation unit.
Definition EBGeometry_PackedBVH.hpp:157
Namespace containing all of EBGeometry's functionality.
Definition EBGeometry_Affine.hpp:26
@ BVH
Through a BVH over the operands' boxes, however many there are.
Fixed-size array with host- and device-callable members.
Definition EBGeometry_Array.hpp:33
The boxes of the K children of one interior node, in SoA layout: m_lo[axis][child] and m_hi[axis][chi...
Definition EBGeometry_BVHQuery.hpp:47
Configuration for the ClusterSAH direct PackedBVH construction path.
Definition EBGeometry_PackedBVH.hpp:94
size_t maxClusterSize
Maximum primitives per cluster (bucket); a leaf holds 1 to K-1 clusters. Must be > 0.
Definition EBGeometry_PackedBVH.hpp:95
Leaf-size settings for the preset construction methods, one per family of methods.
Definition EBGeometry_PackedBVH.hpp:115
size_t targetLeafSize
Morton, Nested, Hilbert: target primitives per leaf. Must be > 0.
Definition EBGeometry_PackedBVH.hpp:117
size_t maxLeafSize
SAH, CentroidSplit, MidpointSplit: most primitives in a leaf. Must be > 0.
Definition EBGeometry_PackedBVH.hpp:116
ClusterSpec cluster
ClusterSAH: the cluster size.
Definition EBGeometry_PackedBVH.hpp:118
The default visit callback of PackedBVH::traverse(): enter every node that passes the bound.
Definition EBGeometry_BVHQuery.hpp:101
Visit the children within the bound nearest first (smallest key first). The default: a nearest-primit...
Definition EBGeometry_BVHQuery.hpp:77
The BVH's arrays as offsets into its pool, and its root box: a PackedBVH minus its location.
Definition EBGeometry_PackedBVH.hpp:1140
PODVector< ChildAABBSoA > m_childAabbSoA
SoA child-box rows, one per interior node.
Definition EBGeometry_PackedBVH.hpp:1154
PODVector< BV > m_rootBox
The root's bounding volume (one element, or none for an empty BVH).
Definition EBGeometry_PackedBVH.hpp:1159
PODVector< P > m_primitives
Global primitive list in leaf-traversal order.
Definition EBGeometry_PackedBVH.hpp:1149
PODVector< Node > m_linearNodes
Flat depth-first node array.
Definition EBGeometry_PackedBVH.hpp:1144
Compact BVH node stored in the flat node array.
Definition EBGeometry_PackedBVH.hpp:393
void setNumPrimitives(uint32_t a_n) noexcept
Set the primitive count for this leaf node.
Definition EBGeometry_PackedBVH.hpp:441
void setPrimitivesOffset(uint32_t a_off) noexcept
Set the primitive offset for this leaf node.
Definition EBGeometry_PackedBVH.hpp:430
uint32_t m_boxSlot
Where this node's own box is stored: row * K + slot in the SIMD box array, the row being its parent's...
Definition EBGeometry_PackedBVH.hpp:422
void setChildOffset(uint32_t a_off, size_t a_k) noexcept
Set the depth-first index of the k-th child.
Definition EBGeometry_PackedBVH.hpp:453
uint32_t m_childBoxRow
Row of this interior node's children's boxes in PackedBVH's SIMD box array.
Definition EBGeometry_PackedBVH.hpp:415
const Array< uint32_t, K > & getChildOffsets() const noexcept
Get the child index table.
Definition EBGeometry_PackedBVH.hpp:487
uint32_t getPrimitivesOffset() const noexcept
Get the primitive offset (leaf nodes only).
Definition EBGeometry_PackedBVH.hpp:465
uint32_t getBoxSlot() const noexcept
Get where this node's own box is stored; see m_boxSlot.
Definition EBGeometry_PackedBVH.hpp:509
uint32_t m_primOff
Index of the first primitive in the global primitive list (leaf nodes only).
Definition EBGeometry_PackedBVH.hpp:397
bool isLeaf() const noexcept
Return true if this is a leaf node.
Definition EBGeometry_PackedBVH.hpp:520
uint32_t getNumPrimitives() const noexcept
Get the primitive count.
Definition EBGeometry_PackedBVH.hpp:476
uint32_t getChildBoxRow() const noexcept
Get the row of this interior node's children's boxes in the SIMD box array.
Definition EBGeometry_PackedBVH.hpp:498
Array< uint32_t, K > m_childOff
Depth-first indices of the K child nodes (interior nodes only).
Definition EBGeometry_PackedBVH.hpp:407
uint32_t m_numPrims
Number of primitives in this leaf (zero for interior nodes).
Definition EBGeometry_PackedBVH.hpp:402
Raw pointer + size view into a Pool block, for hot inner loops.
Definition EBGeometry_PODVector.hpp:52
Placement-independent descriptor of a POD array inside a Pool.
Definition EBGeometry_PODVector.hpp:131
Where a pool-resident descriptor resolves its offsets, and the rules for moving it.
Definition EBGeometry_Pool.hpp:99
Implementation of the Morton SFC.
Definition EBGeometry_SFC.hpp:74