19 #ifndef B2_BROAD_PHASE_H
20 #define B2_BROAD_PHASE_H
24 #include <Box2D/Collision/b2DynamicTree.h>
69 bool TestOverlap(int32 proxyIdA, int32 proxyIdB)
const;
111 void BufferMove(int32 proxyId);
112 void UnBufferMove(int32 proxyId);
114 bool QueryCallback(int32 proxyId);
121 int32 m_moveCapacity;
125 int32 m_pairCapacity;
128 int32 m_queryProxyId;
132 inline bool b2PairLessThan(
const b2Pair& pair1,
const b2Pair& pair2)
134 if (pair1.proxyIdA < pair2.proxyIdA)
139 if (pair1.proxyIdA == pair2.proxyIdA)
141 return pair1.proxyIdB < pair2.proxyIdB;
184 template <
typename T>
191 for (int32 i = 0; i < m_moveCount; ++i)
193 m_queryProxyId = m_moveBuffer[i];
194 if (m_queryProxyId == e_nullProxy)
204 m_tree.
Query(
this, fatAABB);
211 std::sort(m_pairBuffer, m_pairBuffer + m_pairCount, b2PairLessThan);
215 while (i < m_pairCount)
217 b2Pair* primaryPair = m_pairBuffer + i;
218 void* userDataA = m_tree.
GetUserData(primaryPair->proxyIdA);
219 void* userDataB = m_tree.
GetUserData(primaryPair->proxyIdB);
221 callback->AddPair(userDataA, userDataB);
225 while (i < m_pairCount)
227 b2Pair* pair = m_pairBuffer + i;
228 if (pair->proxyIdA != primaryPair->proxyIdA || pair->proxyIdB != primaryPair->proxyIdB)
240 template <
typename T>
243 m_tree.
Query(callback, aabb);
246 template <
typename T>
249 m_tree.
RayCast(callback, input);
int32 CreateProxy(const b2AABB &aabb, void *userData)
Definition: b2BroadPhase.cpp:40
Definition: b2DynamicTree.h:61
void RayCast(T *callback, const b2RayCastInput &input) const
Definition: b2DynamicTree.h:204
Definition: b2BroadPhase.h:36
void MoveProxy(int32 proxyId, const b2AABB &aabb, const b2Vec2 &displacement)
Definition: b2BroadPhase.cpp:55
bool TestOverlap(int32 proxyIdA, int32 proxyIdB) const
Test overlap of fat AABBs.
Definition: b2BroadPhase.h:152
int32 GetHeight() const
Definition: b2DynamicTree.cpp:522
int32 GetTreeBalance() const
Get the balance of the embedded tree.
Definition: b2BroadPhase.h:174
void TouchProxy(int32 proxyId)
Call to trigger a re-processing of it's pairs on the next call to UpdatePairs.
Definition: b2BroadPhase.cpp:64
void ShiftOrigin(const b2Vec2 &newOrigin)
Definition: b2DynamicTree.cpp:776
float32 GetAreaRatio() const
Get the ratio of the sum of the node areas to the root area.
Definition: b2DynamicTree.cpp:533
void UpdatePairs(T *callback)
Update the pairs. This results in pair callbacks. This can only add pairs.
Definition: b2BroadPhase.h:185
An axis aligned bounding box.
Definition: b2Collision.h:162
void * GetUserData(int32 proxyId) const
Definition: b2DynamicTree.h:156
void DestroyProxy(int32 proxyId)
Destroy a proxy. It is up to the client to remove any pairs.
Definition: b2BroadPhase.cpp:48
bool b2TestOverlap(const b2Shape *shapeA, int32 indexA, const b2Shape *shapeB, int32 indexB, const b2Transform &xfA, const b2Transform &xfB)
Determine if two generic shapes overlap.
Definition: b2Collision.cpp:233
void ShiftOrigin(const b2Vec2 &newOrigin)
Definition: b2BroadPhase.h:252
void * GetUserData(int32 proxyId) const
Get user data from a proxy. Returns NULL if the id is invalid.
Definition: b2BroadPhase.h:147
void Query(T *callback, const b2AABB &aabb) const
Definition: b2DynamicTree.h:169
float32 GetTreeQuality() const
Get the quality metric of the embedded tree.
Definition: b2BroadPhase.h:179
int32 GetTreeHeight() const
Get the height of the embedded tree.
Definition: b2BroadPhase.h:169
int32 GetMaxBalance() const
Definition: b2DynamicTree.cpp:678
void RayCast(T *callback, const b2RayCastInput &input) const
Definition: b2BroadPhase.h:247
void Query(T *callback, const b2AABB &aabb) const
Definition: b2BroadPhase.h:241
Definition: b2BroadPhase.h:27
int32 GetProxyCount() const
Get the number of proxies.
Definition: b2BroadPhase.h:164
A 2D column vector.
Definition: b2Math.h:56
const b2AABB & GetFatAABB(int32 proxyId) const
Get the fat AABB for a proxy.
Definition: b2BroadPhase.h:159
const b2AABB & GetFatAABB(int32 proxyId) const
Get the fat AABB for a proxy.
Definition: b2DynamicTree.h:162