9#include <unordered_map>
21 BSPTree3D(
float minX,
float minY,
float minZ,
float maxX,
float maxY,
float maxZ,
22 int maxDepth = 12,
int maxPerNode = 8);
32 bool insert(
int id,
float minX,
float minY,
float minZ,
float maxX,
float maxY,
float maxZ);
36 bool update(
int id,
float minX,
float minY,
float minZ,
float maxX,
float maxY,
float maxZ);
38 bool contains(
int id)
const;
40 int getCount()
const {
return static_cast<int>(items_.size()); }
43 int queryPoint(
float x,
float y,
float z);
45 int queryAABB(
float minX,
float minY,
float minZ,
float maxX,
float maxY,
float maxZ);
47 int querySphere(
float cx,
float cy,
float cz,
float radius);
55 float getMinX()
const {
return rootBounds_.minX; }
57 float getMinY()
const {
return rootBounds_.minY; }
59 float getMinZ()
const {
return rootBounds_.minZ; }
61 float getMaxX()
const {
return rootBounds_.maxX; }
63 float getMaxY()
const {
return rootBounds_.maxY; }
65 float getMaxZ()
const {
return rootBounds_.maxZ; }
77 std::vector<int> itemIds;
78 std::unique_ptr<Node>
left;
79 std::unique_ptr<Node>
right;
80 bool isLeaf()
const {
return left ==
nullptr; }
84 bool insertInto(Node &
node,
int id,
const AABB3 &
bounds);
86 void collect(Node &
node,
const AABB3 *box,
float cx,
float cy,
float cz,
float radius,
93 std::unique_ptr<Node> root_;
94 std::unordered_map<int, AABB3> items_;
#define EVENGINE_API_FOUNDATION
每个链接组(link group)各自的导出宏。
Binary space partition tree (kd-style AABB splits) for 3D culling. Alternating X/Y/Z splits at node m...
float getMinY() const
Root/world minimum Y.
BSPTree3D & operator=(const BSPTree3D &)=delete
float getMinX() const
Root/world minimum X.
float getMinZ() const
Root/world minimum Z.
BSPTree3D(const BSPTree3D &)=delete
float getMaxZ() const
Root/world maximum Z.
float getMaxY() const
Root/world maximum Y.
int getResultCount() const
Number of hits from the last query*.
~BSPTree3D()=default
Releases tree nodes.
int getCount() const
Number of stored ids.
int getResultId(int index) const
Hit id at dense index from the last query*, or -1.
int getMaxPerNode() const
Item capacity before a node splits.
float getMaxX() const
Root/world maximum X.
int getMaxDepth() const
Maximum subdivision depth.
Axis-aligned 3D bounding box (min/max inclusive).