19 #ifndef B2_BROAD_PHASE_H 20 #define B2_BROAD_PHASE_H 50 int32 CreateProxy(
const b2AABB& aabb,
void* userData);
53 void DestroyProxy(
int32 proxyId);
60 void TouchProxy(
int32 proxyId);
66 void* GetUserData(
int32 proxyId)
const;
72 int32 GetProxyCount()
const;
76 void UpdatePairs(T* callback);
81 void Query(T* callback,
const b2AABB& aabb)
const;
94 int32 GetTreeHeight()
const;
97 int32 GetTreeBalance()
const;
100 float32 GetTreeQuality()
const;
105 void ShiftOrigin(
const b2Vec2& newOrigin);
111 void BufferMove(
int32 proxyId);
112 void UnBufferMove(
int32 proxyId);
114 bool QueryCallback(
int32 proxyId);
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;
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);
int32 GetTreeBalance() const
Get the balance of the embedded tree.
float32 GetTreeQuality() const
Get the quality metric of the embedded tree.
void Query(T *callback, const b2AABB &aabb) const
int32 GetProxyCount() const
Get the number of proxies.
void UpdatePairs(T *callback)
Update the pairs. This results in pair callbacks. This can only add pairs.
void RayCast(T *callback, const b2RayCastInput &input) const
void ShiftOrigin(const b2Vec2 &newOrigin)
int32 GetTreeHeight() const
Get the height of the embedded tree.
const b2AABB & GetFatAABB(int32 proxyId) const
Get the fat AABB for a proxy.
An axis aligned bounding box.
void * GetUserData(int32 proxyId) const
Get user data from a proxy. Returns NULL if the id is invalid.
bool b2TestOverlap(const b2Shape *shapeA, int32 indexA, const b2Shape *shapeB, int32 indexB, const b2Transform &xfA, const b2Transform &xfB)
Determine if two generic shapes overlap.
bool b2PairLessThan(const b2Pair &pair1, const b2Pair &pair2)
This is used to sort pairs.
bool TestOverlap(int32 proxyIdA, int32 proxyIdB) const
Test overlap of fat AABBs.