1#ifndef _DYNAMIC_AABB_TREE_HPP_
2#define _DYNAMIC_AABB_TREE_HPP_
42 void Query(
const AABB& queryAABB,
const std::function<
bool(
int)>& callback)
const;
45 const std::function<
bool(
int)>& callback)
const;
47 const AABB&
GetFatAABB(
int proxyId)
const {
return m_nodes[proxyId].fatAABB; }
48 void*
GetUserData(
int proxyId)
const {
return m_nodes[proxyId].userData; }
52 void FreeNode(
int nodeId);
53 void InsertLeaf(
int leaf);
54 void RemoveLeaf(
int leaf);
55 int Balance(
int nodeId);
57 std::vector<TreeNode> m_nodes;
61 int m_nodeCapacity = 0;
void Query(const AABB &queryAABB, const std::function< bool(int)> &callback) const
Visits every leaf whose fat AABB overlaps queryAABB; stop early by returning false from callback.
int Insert(const AABB &aabb, void *userData)
Adds a new proxy with a fattened AABB and returns its id.
const AABB & GetFatAABB(int proxyId) const
~DynamicAABBTree()=default
bool MoveProxy(int proxyId, const AABB &newAABB, const Vector3D &displacement)
Refits a proxy's fat AABB to newAABB, re-inserting it only if it moved outside the fat margin.
void Remove(int proxyId)
Removes a proxy and rebalances the tree around it.
void * GetUserData(int proxyId) const
void RayCast(const Vector3D &origin, const Vector3D &direction, float maxDist, const std::function< bool(int)> &callback) const
Walks the tree along a ray, visiting candidate leaves within maxDist.
Collision shapes, the broadphase tree, and the world that steps them.
static constexpr int NULL_NODE
static constexpr float FAT_AABB_MARGIN
Root namespace for everything the engine exposes.