EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
Classes | Namespaces | Typedefs | Enumerations | Functions | Variables
EBGeometry_BVH.hpp File Reference

Declaration of bounding volume hierarchy (BVH) classes. More...

#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <iterator>
#include <limits>
#include <memory>
#include <type_traits>
#include <utility>
#include <vector>
#include "EBGeometry_BoundingVolumes.hpp"
#include "EBGeometry_Macros.hpp"
#include "EBGeometry_SFC.hpp"
#include "EBGeometry_Vec.hpp"
#include "EBGeometry_BVHImplem.hpp"
Include dependency graph for EBGeometry_BVH.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  EBGeometry::BVH::ClusterSpec
 Configuration for the ClusterSAH direct PackedBVH construction path. More...
 
struct  EBGeometry::BVH::SharedPtrStorage< P >
 Default storage policy for PackedBVH: primitives stored as std::shared_ptr<const P>, exactly as PackedBVH has always stored them. More...
 
struct  EBGeometry::BVH::ValueStorage< P >
 Storage policy that stores primitives directly by value, with no pointer indirection at all. More...
 
class  EBGeometry::BVH::TreeBVH< T, P, BV, K >
 Forward declaration of the tree-structured BVH. Needed by LeafPredicate and the default-partitioner lambdas defined below. More...
 
class  EBGeometry::BVH::PackedBVH< T, P, K, StoragePolicy >
 Forward declaration of the linearised BVH. Needed so that TreeBVH::pack() and TreeBVH::packWith() can name their return types before PackedBVH is fully defined. More...
 
struct  EBGeometry::BVH::PackedBVH< T, P, K, StoragePolicy >::Node
 Compact BVH node stored in the flat node array. More...
 
struct  EBGeometry::BVH::PackedBVH< T, P, K, StoragePolicy >::ChildAABBSoA
 SoA layout of K children's AABBs for a single interior node. More...
 

Namespaces

namespace  EBGeometry
 Namespace containing all of EBGeometry's functionality.
 
namespace  EBGeometry::BVH
 Namespace for various bounding volume hierarchy (BVH) functionalities.
 

Typedefs

template<class P >
using EBGeometry::BVH::PrimitiveList = std::vector< std::shared_ptr< const P > >
 Convenience alias for a list of shared primitive pointers.
 
template<class P , class BV >
using EBGeometry::BVH::PrimAndBV = std::pair< std::shared_ptr< const P >, BV >
 Convenience alias for a (primitive, bounding-volume) pair.
 
template<class P , class BV >
using EBGeometry::BVH::PrimAndBVList = std::vector< PrimAndBV< P, BV > >
 Convenience alias for a list of (primitive, bounding-volume) pairs.
 
template<class P , class BV , size_t K>
using EBGeometry::BVH::Partitioner = std::function< std::array< PrimAndBVList< P, BV >, K >(PrimAndBVList< P, BV > a_primsAndBVs)>
 Polymorphic partitioner: splits a list of (primitive, BV) pairs into K sub-lists.
 
template<class T , class P , class BV , size_t K>
using EBGeometry::BVH::LeafPredicate = std::function< bool(const TreeBVH< T, P, BV, K > &a_node)>
 Predicate for deciding when a TreeBVH node should become a leaf (i.e., no further splitting).
 
template<class P >
using EBGeometry::BVH::LeafEvaluator = std::function< void(const PrimitiveList< P > &a_primitives)>
 Leaf-evaluation callback for TreeBVH::traverse.
 
template<class P , class StoragePolicy = SharedPtrStorage<P>>
using EBGeometry::BVH::PackedLeafEvaluator = std::function< void(const std::vector< typename StoragePolicy::StorageType > &a_primitives, size_t a_offset, size_t a_count)>
 Leaf-evaluation callback for PackedBVH::traverse.
 
template<class NodeType , class NodeKey >
using EBGeometry::BVH::PrunePredicate = std::function< bool(const NodeType &a_node, const NodeKey &a_nodeKey)>
 Node-visit predicate for BVH traversal.
 
template<class NodeType , class NodeKey , size_t K>
using EBGeometry::BVH::ChildOrderer = std::function< void(std::array< std::pair< std::shared_ptr< const NodeType >, NodeKey >, K > &a_children)>
 Child-ordering callback for TreeBVH traversal.
 
template<class NodeKey , size_t K>
using EBGeometry::BVH::PackedChildOrderer = std::function< void(std::array< std::pair< uint32_t, NodeKey >, K > &a_children)>
 Child-ordering callback for PackedBVH traversal.
 
template<class NodeType , class NodeKey >
using EBGeometry::BVH::NodeKeyFactory = std::function< NodeKey(const NodeType &a_node)>
 Node-key factory called once per node during BVH traversal.
 

Enumerations

enum class  EBGeometry::BVH::Build { EBGeometry::BVH::TopDown , EBGeometry::BVH::Morton , EBGeometry::BVH::Nested , EBGeometry::BVH::SAH }
 Enum for specifying the BVH construction strategy. More...
 

Functions

template<typename T >
constexpr size_t EBGeometry::BVH::DefaultBranchingRatio () noexcept
 Returns the SIMD-optimal BVH branching factor for type T on the current target ISA.
 
template<class T , class P , class BV >
size_t EBGeometry::BVH::SAH2WaySplit (PrimAndBVList< P, BV > &a_list, const size_t a_begin, const size_t a_end, const bool a_longestAxisOnly=false) noexcept
 Internal helper: 2-way binned SAH split on the sub-range [a_begin, a_end).
 
template<class T , class P , class BV >
void EBGeometry::BVH::SAHKWaySplit (PrimAndBVList< P, BV > &a_list, const size_t a_begin, const size_t a_end, const size_t a_K, std::vector< std::pair< size_t, size_t > > &a_groups, const bool a_longestAxisOnly=false) noexcept
 Internal helper: recursively split [a_begin, a_end) into a_K groups via 2-way SAH.
 
template<class T , class P , class BV >
size_t EBGeometry::BVH::Midpoint2WaySplit (PrimAndBVList< P, BV > &a_list, const size_t a_begin, const size_t a_end) noexcept
 Internal helper: 2-way spatial-midpoint split on the sub-range [a_begin, a_end).
 
template<class T , class P , class BV >
void EBGeometry::BVH::MidpointKWaySplit (PrimAndBVList< P, BV > &a_list, const size_t a_begin, const size_t a_end, const size_t a_K, std::vector< std::pair< size_t, size_t > > &a_groups) noexcept
 Internal helper: recursively split [a_begin, a_end) into a_K groups via 2-way midpoint splits.
 

Variables

template<class X , size_t K>
auto EBGeometry::BVH::EqualCounts
 Utility: split a vector into K almost-equal contiguous chunks.
 
template<class T , class P , class BV , size_t K>
auto EBGeometry::BVH::PrimitiveCentroidPartitioner
 Partitioner that sorts primitives by centroid along the longest axis and splits into K pieces.
 
template<class T , class P , class BV , size_t K>
auto EBGeometry::BVH::BVCentroidPartitioner
 Partitioner that sorts primitives by bounding-volume centroid along the longest axis and splits into K pieces.
 
template<class T , class P , class BV , size_t K, bool LongestAxisOnly = false>
auto EBGeometry::BVH::BinnedSAHPartitioner
 Partitioner using binned SAH with recursive 2-way subdivision into K groups.
 
template<class T , class P , class BV , size_t K>
auto EBGeometry::BVH::MidpointPartitioner
 Partitioner that recursively bisects primitives by spatial midpoint (no sorting).
 
template<class T , class P , class BV , size_t K>
auto EBGeometry::BVH::DefaultLeafPredicate
 Default stop function: stop partitioning when the node holds fewer than K primitives.
 

Detailed Description

Declaration of bounding volume hierarchy (BVH) classes.

Author
Robert Marskar