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: GPL-3.0-or-later
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
127inline constexpr size_t HostTraversalDepth = 256;
128
135inline constexpr size_t DeviceTraversalDepth = 32;
136
152template <typename T>
153[[nodiscard]] constexpr size_t
155{
156 static_assert(std::is_floating_point_v<T>, "BVH::DefaultBranchingRatio requires a floating-point T");
157
158 return 4;
159}
160
179template <typename T>
180[[nodiscard]] constexpr size_t
182{
183 static_assert(std::is_floating_point_v<T>, "BVH::HostBranchingRatio requires a floating-point T");
184#if defined(__AVX512F__)
185 if constexpr (std::is_same_v<T, double>) {
186 return 8;
187 }
188 else {
189 return 16;
190 }
191#elif defined(__AVX__)
192 if constexpr (std::is_same_v<T, double>) {
193 return 4;
194 }
195 else {
196 return 8;
197 }
198#else
199 return 4;
200#endif
201}
202
207template <class T, class P, class BV, size_t K>
208class TreeBVH;
209
214template <class P>
215using PrimitiveList = std::vector<std::shared_ptr<const P>>;
216
220template <class T, class P, size_t K>
221class PackedBVH;
222
228template <class P, class BV>
229using PrimAndBV = std::pair<std::shared_ptr<const P>, BV>;
230
236template <class P, class BV>
237using PrimAndBVList = std::vector<PrimAndBV<P, BV>>;
238
252template <class P, class BV, size_t K>
253using Partitioner = std::function<Array<PrimAndBVList<P, BV>, K>(PrimAndBVList<P, BV> a_primsAndBVs)>;
254
264template <class T, class P, class BV, size_t K>
265using LeafPredicate = std::function<bool(const TreeBVH<T, P, BV, K>& a_node)>;
266
273template <class P>
274using LeafEvaluator = std::function<void(const PrimitiveList<P>& a_primitives)>;
275
287template <class NodeType, class NodeKey>
288using PrunePredicate = std::function<bool(const NodeType& a_node, const NodeKey& a_nodeKey)>;
289
299template <class NodeType, class NodeKey, size_t K>
300using ChildOrderer = std::function<void(Array<std::pair<std::shared_ptr<const NodeType>, NodeKey>, K>& a_children)>;
301
311template <class NodeType, class NodeKey>
312using NodeKeyFactory = std::function<NodeKey(const NodeType& a_node)>;
313
355template <class T, class P, size_t K>
356class PackedBVH final : public PoolHandle
357{
358 static_assert(std::is_floating_point_v<T>, "PackedBVH: T must be a floating-point type");
359 static_assert(K >= 2, "PackedBVH: branching factor K must be at least 2");
360 static_assert(K <= 256, "PackedBVH: branching factor K must be at most 256, so a child slot fits in a byte");
361 static_assert(!isPoolHandle<P>,
362 "PackedBVH: a primitive stored in a pool must hold no location; store the handle's Layout "
363 "and pair it with this BVH's location() (see PoolHandle)");
364
365public:
370
380 struct Node
381 {
385 uint32_t m_primOff{};
386
390 uint32_t m_numPrims{};
391
396
403 uint32_t m_childBoxRow{};
404
410 uint32_t m_boxSlot{};
411
417 inline void
418 setPrimitivesOffset(uint32_t a_off) noexcept
419 {
420 m_primOff = a_off;
421 }
422
428 inline void
429 setNumPrimitives(uint32_t a_n) noexcept
430 {
431 m_numPrims = a_n;
432 }
433
440 inline void
441 setChildOffset(uint32_t a_off, size_t a_k) noexcept
442 {
443 EBGEOMETRY_EXPECT(a_k < K);
444 m_childOff[a_k] = a_off;
445 }
446
451 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
452 inline uint32_t
453 getPrimitivesOffset() const noexcept
454 {
455 return m_primOff;
456 }
457
462 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
463 inline uint32_t
464 getNumPrimitives() const noexcept
465 {
466 return m_numPrims;
467 }
468
473 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
474 inline const Array<uint32_t, K>&
475 getChildOffsets() const noexcept
476 {
477 return m_childOff;
478 }
479
484 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
485 inline uint32_t
486 getChildBoxRow() const noexcept
487 {
488 return m_childBoxRow;
489 }
490
495 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
496 inline uint32_t
497 getBoxSlot() const noexcept
498 {
499 return m_boxSlot;
500 }
501
506 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
507 inline bool
508 isLeaf() const noexcept
509 {
510 return m_numPrims > 0;
511 }
512 };
513
517 static constexpr uint32_t RootBoxSlot = UINT32_MAX;
518
523 PackedBVH() = delete;
524
529 struct Layout;
530
540 inline PackedBVH(const Layout& a_layout, const PoolLocation& a_location) noexcept;
541
546 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
547 inline Layout
548 layout() const noexcept;
549
559 inline PackedBVH(Pool& a_pool, const TreeBVH<T, P, BV, K>& a_tree);
560
590 template <class Q, class Converter>
592 inline PackedBVH(Pool& a_pool, const TreeBVH<T, Q, BV, K>& a_tree, Converter&& a_converter);
593
601 [[nodiscard]] EBGEOMETRY_HOST
602 static inline BVH::ConstructionOptions
604 {
605 return BVH::ConstructionOptions{K - 1, K, BVH::ClusterSpec{}};
606 }
607
621 [[nodiscard]] EBGEOMETRY_HOST
622 static inline PackedBVH
623 build(Pool& a_pool,
624 std::vector<std::pair<P, BV>> a_primsAndBVs,
625 BVH::Construction a_construction,
627
654 template <class S = SFC::Morton>
655 [[nodiscard]] EBGEOMETRY_HOST
656 static inline PackedBVH
657 buildBottomUp(Pool& a_pool, std::vector<std::pair<P, BV>> a_primsAndBVs, size_t a_targetLeafSize);
658
689 [[nodiscard]] EBGEOMETRY_HOST
690 static inline PackedBVH
692 std::vector<std::pair<P, BV>> a_primsAndBVs,
693 const BVH::Partitioner<P, BV, K>& a_partitioner,
694 const BVH::LeafPredicate<T, P, BV, K>& a_stopCrit);
695
706 [[nodiscard]] EBGEOMETRY_HOST
707 static inline PackedBVH
709 std::vector<std::pair<P, BV>> a_primsAndBVs,
710 const BVH::Partitioner<P, BV, K>& a_partitioner);
711
730 [[nodiscard]] EBGEOMETRY_HOST
731 static inline PackedBVH
732 buildClusterSAH(Pool& a_pool, std::vector<std::pair<P, BV>> a_primsAndBVs, BVH::ClusterSpec a_spec);
733
755 inline PackedBVH(Pool& a_pool,
756 const std::vector<Node>& a_linearNodes,
757 const std::vector<BV>& a_nodeBoxes,
758 const std::vector<P>& a_primitives)
759 {
760 this->finalize(a_pool, a_linearNodes, a_nodeBoxes, a_primitives);
761 }
762
768 inline ~PackedBVH() = default;
769
778 PackedBVH(const PackedBVH& a_other) = default;
779
785 PackedBVH&
786 operator=(const PackedBVH& a_other) = default;
787
794 PackedBVH(PackedBVH&& a_other) noexcept = default;
795
801 PackedBVH&
802 operator=(PackedBVH&& a_other) noexcept = default;
803
811 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
812 inline PODSpan<const P>
813 getPrimitives() const noexcept;
814
829 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
830 inline PODSpan<P>
831 getPrimitives() noexcept;
832
841 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
842 inline PODSpan<const Node>
843 getNodes() const noexcept;
844
855 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
856 static constexpr size_t
858 {
859#if defined(EBGEOMETRY_DEVICE_COMPILE)
860 return PackedBVH::stackEntriesFor(DeviceTraversalDepth);
861#else
862 return PackedBVH::stackEntriesFor(HostTraversalDepth);
863#endif
864 }
865
870 using PoolHandle::base;
871
889 [[nodiscard]] EBGEOMETRY_HOST
890 inline PackedBVH
891 rebasedView(const Pool& a_pool) const noexcept;
892
900 [[nodiscard]] EBGEOMETRY_HOST
901 inline PackedBVH
902 deepCopy(Pool& a_dstPool) const;
903
910 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
911 inline const BV&
912 getBoundingVolume() const noexcept;
913
923 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
924 inline BV
925 getBoundingVolume(const Node& a_node) const noexcept;
926
937 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
938 inline T
939 getDistanceToBoundingVolume2(const Node& a_node, const Vec3T<T>& a_point) const noexcept;
940
953 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
954 inline T
955 getDistanceToChildBoundingVolume2(const Node& a_parent, size_t a_k, const Vec3T<T>& a_point) const noexcept;
956
964 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
965 inline BV
966 computeBoundingVolume() const noexcept;
967
1012 template <class Query,
1013 class State,
1014 class LeafEvaluator,
1015 class BoundFn,
1016 class VisitFn = DescendAll,
1017 class Order = NearestFirst>
1019 inline void
1020 traverse(const Query& a_query,
1021 State& a_state,
1022 LeafEvaluator&& a_leaf,
1023 BoundFn&& a_bound,
1024 VisitFn&& a_visit = DescendAll(),
1025 Order a_order = Order()) const noexcept;
1026
1046 template <class BVConstructor>
1047 inline void
1048 refit(const BVConstructor& a_bvConstructor);
1049
1050private:
1066 inline void
1067 finalize(Pool& a_pool,
1068 const std::vector<Node>& a_linearNodes,
1069 const std::vector<BV>& a_nodeBoxes,
1070 const std::vector<P>& a_primitives);
1071
1075 PODVector<Node> m_linearNodes;
1076
1080 PODVector<P> m_primitives;
1081
1086 using ChildAABBSoA = ChildBoxes<T, K>;
1087
1092 PODVector<ChildAABBSoA> m_childAabbSoA;
1093
1098 PODVector<BV> m_rootBox;
1099
1100public:
1126
1127private:
1139 struct StackEntry
1140 {
1142 uint32_t m_node;
1143
1145 uint8_t m_slots[K - 1];
1146
1148 uint8_t m_count;
1149 };
1150
1151 static_assert(K != 4 || sizeof(StackEntry) == 8, "PackedBVH: a stack entry is 8 bytes at K = 4");
1152
1160 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1161 static constexpr size_t
1162 stackEntriesFor(const size_t a_depth) noexcept
1163 {
1164 return a_depth - 1;
1165 }
1166
1175 [[nodiscard]] EBGEOMETRY_HOST
1176 inline size_t
1177 maxNodeDepth(const void* a_base) const;
1178
1189 inline void
1190 requireDepthFits(const void* a_base, const size_t a_maxDepth, const char* a_context) const;
1191
1205 static inline void
1206 requireWellFormed(const std::vector<Node>& a_linearNodes, const size_t a_numPrimitives);
1207
1217 inline void
1218 buildSoA(Pool& a_pool, const std::vector<BV>& a_nodeBoxes);
1219
1227 static inline void
1228 setRowBox(ChildAABBSoA& a_soa, size_t a_slot, const BV& a_bv) noexcept;
1229
1236 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
1237 static inline BV
1238 rowBox(const ChildAABBSoA& a_soa, size_t a_slot) noexcept;
1239};
1240
1246static_assert(std::is_trivially_copyable_v<PackedBVH<float, Vec3T<float>, 4>>,
1247 "PackedBVH<float, ...> must be trivially copyable");
1248static_assert(std::is_trivially_copyable_v<PackedBVH<double, Vec3T<double>, 4>>,
1249 "PackedBVH<double, ...> must be trivially copyable");
1250
1251} // namespace BVH
1252
1253} // namespace EBGeometry
1254
1255#include "EBGeometry_PackedBVHImplem.hpp"
1256
1257#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:155
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:357
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:517
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:369
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:857
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:755
~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.
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:603
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:499
void * base() noexcept
The base address this handle's offsets resolve against; see PoolLocation::base().
Definition EBGeometry_Pool.hpp:575
Growable bump arena over a MemoryResource.
Definition EBGeometry_Pool.hpp:183
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:127
std::vector< std::shared_ptr< const P > > PrimitiveList
Convenience alias for a list of shared primitive pointers.
Definition EBGeometry_PackedBVH.hpp:215
std::function< bool(const NodeType &a_node, const NodeKey &a_nodeKey)> PrunePredicate
Node-visit predicate for TreeBVH::traverse().
Definition EBGeometry_PackedBVH.hpp:288
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:253
std::vector< PrimAndBV< P, BV > > PrimAndBVList
Convenience alias for a list of (primitive, bounding-volume) pairs.
Definition EBGeometry_PackedBVH.hpp:237
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:265
std::pair< std::shared_ptr< const P >, BV > PrimAndBV
Convenience alias for a (primitive, bounding-volume) pair.
Definition EBGeometry_PackedBVH.hpp:229
std::function< void(const PrimitiveList< P > &a_primitives)> LeafEvaluator
Leaf-evaluation callback for TreeBVH::traverse.
Definition EBGeometry_PackedBVH.hpp:274
std::function< NodeKey(const NodeType &a_node)> NodeKeyFactory
Node-key factory called once per node during TreeBVH::traverse().
Definition EBGeometry_PackedBVH.hpp:312
constexpr size_t DeviceTraversalDepth
Deepest tree, in node levels, that a device traversal handles.
Definition EBGeometry_PackedBVH.hpp:135
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:181
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:300
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:154
Namespace containing all of EBGeometry's functionality.
Definition EBGeometry_Affine.hpp:26
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:1105
PODVector< ChildAABBSoA > m_childAabbSoA
SoA child-box rows, one per interior node.
Definition EBGeometry_PackedBVH.hpp:1119
PODVector< BV > m_rootBox
The root's bounding volume (one element, or none for an empty BVH).
Definition EBGeometry_PackedBVH.hpp:1124
PODVector< P > m_primitives
Global primitive list in leaf-traversal order.
Definition EBGeometry_PackedBVH.hpp:1114
PODVector< Node > m_linearNodes
Flat depth-first node array.
Definition EBGeometry_PackedBVH.hpp:1109
Compact BVH node stored in the flat node array.
Definition EBGeometry_PackedBVH.hpp:381
void setNumPrimitives(uint32_t a_n) noexcept
Set the primitive count for this leaf node.
Definition EBGeometry_PackedBVH.hpp:429
void setPrimitivesOffset(uint32_t a_off) noexcept
Set the primitive offset for this leaf node.
Definition EBGeometry_PackedBVH.hpp:418
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:410
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:441
uint32_t m_childBoxRow
Row of this interior node's children's boxes in PackedBVH's SIMD box array.
Definition EBGeometry_PackedBVH.hpp:403
const Array< uint32_t, K > & getChildOffsets() const noexcept
Get the child index table.
Definition EBGeometry_PackedBVH.hpp:475
uint32_t getPrimitivesOffset() const noexcept
Get the primitive offset (leaf nodes only).
Definition EBGeometry_PackedBVH.hpp:453
uint32_t getBoxSlot() const noexcept
Get where this node's own box is stored; see m_boxSlot.
Definition EBGeometry_PackedBVH.hpp:497
uint32_t m_primOff
Index of the first primitive in the global primitive list (leaf nodes only).
Definition EBGeometry_PackedBVH.hpp:385
bool isLeaf() const noexcept
Return true if this is a leaf node.
Definition EBGeometry_PackedBVH.hpp:508
uint32_t getNumPrimitives() const noexcept
Get the primitive count.
Definition EBGeometry_PackedBVH.hpp:464
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:486
Array< uint32_t, K > m_childOff
Depth-first indices of the K child nodes (interior nodes only).
Definition EBGeometry_PackedBVH.hpp:395
uint32_t m_numPrims
Number of primitives in this leaf (zero for interior nodes).
Definition EBGeometry_PackedBVH.hpp:390
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:119
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:72