19 #ifndef B2_DYNAMIC_TREE_H 20 #define B2_DYNAMIC_TREE_H 25 #define b2_nullNode (-1) 74 void DestroyProxy(
int32 proxyId);
84 void* GetUserData(
int32 proxyId)
const;
92 void Query(T* callback,
const b2AABB& aabb)
const;
101 template <
typename T>
105 void Validate()
const;
109 int32 GetHeight()
const;
113 int32 GetMaxBalance()
const;
119 void RebuildBottomUp();
124 void ShiftOrigin(
const b2Vec2& newOrigin);
128 int32 AllocateNode();
129 void FreeNode(
int32 node);
131 void InsertLeaf(
int32 node);
132 void RemoveLeaf(
int32 node);
136 int32 ComputeHeight()
const;
139 void ValidateStructure(
int32 index)
const;
140 void ValidateMetrics(
int32 index)
const;
158 b2Assert(0 <= proxyId && proxyId < m_nodeCapacity);
159 return m_nodes[proxyId].userData;
164 b2Assert(0 <= proxyId && proxyId < m_nodeCapacity);
165 return m_nodes[proxyId].aabb;
168 template <
typename T>
188 bool proceed = callback->QueryCallback(nodeId);
189 if (proceed ==
false)
203 template <
typename T>
224 b2Vec2 t = p1 + maxFraction * (p2 - p1);
252 if (separation > 0.0
f)
260 subInput.
p1 = input.
p1;
261 subInput.
p2 = input.
p2;
264 float32 value = callback->RayCastCallback(subInput, nodeId);
276 b2Vec2 t = p1 + maxFraction * (p2 - p1);
const b2AABB & GetFatAABB(int32 proxyId) const
Get the fat AABB for a proxy.
float32 b2Dot(const b2Vec2 &a, const b2Vec2 &b)
Perform the dot product on two vectors.
b2Vec2 GetCenter() const
Get the center of the AABB.
b2Vec2 lowerBound
the lower vertex
b2AABB aabb
Enlarged AABB.
float32 LengthSquared() const
b2Vec2 GetExtents() const
Get the extents of the AABB (half-widths).
float32 b2Cross(const b2Vec2 &a, const b2Vec2 &b)
Perform the cross product on two vectors. In 2D this produces a scalar.
uint32 m_path
This is used to incrementally traverse the tree for re-balancing.
void Push(const T &element)
void Query(T *callback, const b2AABB &aabb) const
A node in the dynamic tree. The client does not interact with this directly.
An axis aligned bounding box.
void * GetUserData(int32 proxyId) const
float32 Normalize()
Convert this vector into a unit vector. Returns the length.
bool b2TestOverlap(const b2Shape *shapeA, int32 indexA, const b2Shape *shapeB, int32 indexB, const b2Transform &xfA, const b2Transform &xfB)
Determine if two generic shapes overlap.
void RayCast(T *callback, const b2RayCastInput &input) const
b2Vec2 upperBound
the upper vertex