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;
109 friend class b2DynamicTree;
111 void BufferMove(int32 proxyId);
112 void UnBufferMove(int32 proxyId);
114 bool QueryCallback(int32 proxyId);
116 b2DynamicTree m_tree;
121 int32 m_moveCapacity;
124 b2Pair* m_pairBuffer;
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;
149 return m_tree.GetUserData(proxyId);
154 const b2AABB& aabbA = m_tree.GetFatAABB(proxyIdA);
155 const b2AABB& aabbB = m_tree.GetFatAABB(proxyIdB);
161 return m_tree.GetFatAABB(proxyId);
171 return m_tree.GetHeight();
176 return m_tree.GetMaxBalance();
181 return m_tree.GetAreaRatio();
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)
201 const b2AABB& fatAABB = m_tree.GetFatAABB(m_queryProxyId);
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);
254 m_tree.ShiftOrigin(newOrigin);