PhysicsBasedAnimationToolkit 0.0.10
Cross-platform C++20 library of algorithms and data structures commonly used in computer graphics research on physically-based simulation.
Loading...
Searching...
No Matches
Bvh.h
Go to the documentation of this file.
1
10
11#ifndef PBAT_GPU_GEOMETRY_BVH_H
12#define PBAT_GPU_GEOMETRY_BVH_H
13
14#include "Aabb.h"
15#include "PhysicsBasedAnimationToolkitExport.h"
17#include "pbat/gpu/Aliases.h"
19
20#include <Eigen/Core>
21#include <cstddef>
22#include <limits>
23
24namespace pbat::gpu::impl::geometry {
25class Bvh;
26} // namespace pbat::gpu::impl::geometry
27
28namespace pbat {
29namespace gpu {
30namespace geometry {
31
35class Bvh
36{
37 public:
39
45 PBAT_API Bvh(GpuIndex nBoxes, GpuIndex nOverlaps);
46 Bvh(Bvh const&) = delete;
47 Bvh& operator=(Bvh const&) = delete;
52 PBAT_API Bvh(Bvh&& other) noexcept;
58 PBAT_API Bvh& operator=(Bvh&& other) noexcept;
65 PBAT_API void Build(
66 Aabb& aabbs,
67 Eigen::Vector<GpuScalar, 3> const& min,
68 Eigen::Vector<GpuScalar, 3> const& max);
73 PBAT_API GpuIndexMatrixX DetectOverlaps(Aabb const& aabbs);
82 PBAT_API GpuIndexMatrixX DetectOverlaps(common::Buffer const& set, Aabb const& aabbs);
92 Aabb const& aabbs,
93 common::Buffer const& X,
94 common::Buffer const& V,
95 common::Buffer const& F);
105 Aabb const& aabbs,
106 common::Buffer const& X,
107 common::Buffer const& V,
108 common::Buffer const& T);
113 PBAT_API GpuMatrixX Min() const;
118 PBAT_API GpuMatrixX Max() const;
123 PBAT_API GpuIndexVectorX LeafOrdering() const;
128 PBAT_API Eigen::Vector<MortonCodeType, Eigen::Dynamic> MortonCodes() const;
133 PBAT_API GpuIndexMatrixX Child() const;
138 PBAT_API GpuIndexVectorX Parent() const;
143 PBAT_API GpuIndexMatrixX Rightmost() const;
148 PBAT_API GpuIndexVectorX Visits() const;
153 PBAT_API impl::geometry::Bvh* Impl();
158 PBAT_API impl::geometry::Bvh const* Impl() const;
162 PBAT_API ~Bvh();
163
164 private:
165 void Deallocate();
166
167 impl::geometry::Bvh* mImpl;
168 void* mOverlaps;
169};
170
171} // namespace geometry
172} // namespace gpu
173} // namespace pbat
174
175#endif // PBAT_GPU_GEOMETRY_BVH_H
Axis-aligned bounding box (AABB) buffer on the GPU.
This file contains the Buffer class for 1- or 2-dimensional GPU buffers of numeric types.
This file contains functions to compute Morton codes.
1- or 2-dimensional GPU buffer of numeric types
Definition Buffer.h:25
GPU axis-aligned bounding box (AABB) buffer public API.
Definition Aabb.h:25
PBAT_API GpuIndexVectorX Visits() const
Definition Bvh.cu:297
PBAT_API GpuIndexMatrixX PointTetrahedronNearestNeighbors(Aabb const &aabbs, common::Buffer const &X, common::Buffer const &V, common::Buffer const &T)
Compute nearest tets (V,T) to points X, given the tetrahedron AABBs.
Definition Bvh.cu:192
PBAT_API Eigen::Vector< MortonCodeType, Eigen::Dynamic > MortonCodes() const
Definition Bvh.cu:277
PBAT_API GpuIndexVectorX Parent() const
Definition Bvh.cu:287
PBAT_API GpuIndexMatrixX Rightmost() const
Definition Bvh.cu:292
pbat::geometry::MortonCodeType MortonCodeType
Type of the Morton codes.
Definition Bvh.h:38
PBAT_API GpuIndexMatrixX PointTriangleNearestNeighbors(Aabb const &aabbs, common::Buffer const &X, common::Buffer const &V, common::Buffer const &F)
Compute nearest triangles (V,F) to points X, given the triangle AABBs.
Definition Bvh.cu:123
PBAT_API GpuIndexVectorX LeafOrdering() const
Definition Bvh.cu:272
PBAT_API Bvh(GpuIndex nBoxes, GpuIndex nOverlaps)
Construct a new Bvh object with space allocated for nBoxes and at most nOverlaps.
Definition Bvh.cu:21
PBAT_API impl::geometry::Bvh * Impl()
Handle to the implementation.
Definition Bvh.cu:307
PBAT_API ~Bvh()
Destructor.
Definition Bvh.cu:302
PBAT_API GpuMatrixX Min() const
BVH nodes' box minimums.
Definition Bvh.cu:262
PBAT_API void Build(Aabb &aabbs, Eigen::Vector< GpuScalar, 3 > const &min, Eigen::Vector< GpuScalar, 3 > const &max)
Build the BVH from the given AABBs.
Definition Bvh.cu:50
PBAT_API GpuIndexMatrixX Child() const
Definition Bvh.cu:282
PBAT_API GpuMatrixX Max() const
BVH nodes' box maximums.
Definition Bvh.cu:267
PBAT_API GpuIndexMatrixX DetectOverlaps(Aabb const &aabbs)
Detect overlaps between the AABBs.
Definition Bvh.cu:68
Radix-tree linear BVH.
Definition Bvh.cuh:34
Type aliases for GPU code.
std::uint32_t MortonCodeType
Type used to represent Morton codes.
Definition Morton.h:24
Public geometry API for GPU.
Definition Aabb.cu:16
GPU related public functionality.
Definition Buffer.cu:16
The main namespace of the library.
Definition Aliases.h:15
Eigen::Vector< GpuIndex, Eigen::Dynamic > GpuIndexVectorX
Index vector type for GPU code.
Definition Aliases.h:28
Eigen::Matrix< GpuIndex, Eigen::Dynamic, Eigen::Dynamic > GpuIndexMatrixX
Index matrix type for GPU code.
Definition Aliases.h:24
Eigen::Matrix< GpuScalar, Eigen::Dynamic, Eigen::Dynamic > GpuMatrixX
Matrix type for GPU code.
Definition Aliases.h:22
std::int32_t GpuIndex
Index type for GPU code.
Definition Aliases.h:20