23 #ifndef B2_BROAD_PHASE_H 24 #define B2_BROAD_PHASE_H 54 int32 CreateProxy(
const b2AABB& aabb,
void* userData);
57 void DestroyProxy(
int32 proxyId);
64 void TouchProxy(
int32 proxyId);
70 void* GetUserData(
int32 proxyId)
const;
73 bool TestOverlap(
int32 proxyIdA,
int32 proxyIdB)
const;
76 int32 GetProxyCount()
const;
80 void UpdatePairs(T* callback);
85 void Query(T* callback,
const b2AABB& aabb)
const;
98 int32 GetTreeHeight()
const;
101 int32 GetTreeBalance()
const;
104 float GetTreeQuality()
const;
109 void ShiftOrigin(
const b2Vec2& newOrigin);
115 void BufferMove(
int32 proxyId);
116 void UnBufferMove(
int32 proxyId);
137 return m_tree.GetUserData(proxyId);
142 const b2AABB& aabbA = m_tree.GetFatAABB(proxyIdA);
143 const b2AABB& aabbB = m_tree.GetFatAABB(proxyIdB);
149 return m_tree.GetFatAABB(proxyId);
159 return m_tree.GetHeight();
164 return m_tree.GetMaxBalance();
169 return m_tree.GetAreaRatio();
172 template <
typename T>
179 for (
int32 i = 0; i < m_moveCount; ++i)
181 m_queryProxyId = m_moveBuffer[i];
182 if (m_queryProxyId == e_nullProxy)
189 const b2AABB& fatAABB = m_tree.GetFatAABB(m_queryProxyId);
192 m_tree.Query(
this, fatAABB);
196 for (
int32 i = 0; i < m_pairCount; ++i)
198 b2Pair* primaryPair = m_pairBuffer + i;
199 void* userDataA = m_tree.GetUserData(primaryPair->
proxyIdA);
200 void* userDataB = m_tree.GetUserData(primaryPair->
proxyIdB);
202 callback->AddPair(userDataA, userDataB);
206 for (
int32 i = 0; i < m_moveCount; ++i)
208 int32 proxyId = m_moveBuffer[i];
209 if (proxyId == e_nullProxy)
214 m_tree.ClearMoved(proxyId);
221 template <
typename T>
224 m_tree.Query(callback, aabb);
227 template <
typename T>
230 m_tree.RayCast(callback, input);
235 m_tree.ShiftOrigin(newOrigin);
float GetTreeQuality() const
Get the quality metric of the embedded tree.
B2_API 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
bool TestOverlap(int32 proxyIdA, int32 proxyIdB) const
Test overlap of fat AABBs.
int32 GetProxyCount() const
Get the number of proxies.
int32 GetTreeHeight() const
Get the height of the embedded tree.
void UpdatePairs(T *callback)
Update the pairs. This results in pair callbacks. This can only add pairs.
int32 GetTreeBalance() const
Get the balance of the embedded tree.
void * GetUserData(int32 proxyId) const
Get user data from a proxy. Returns nullptr if the id is invalid.
void ShiftOrigin(const b2Vec2 &newOrigin)
const b2AABB & GetFatAABB(int32 proxyId) const
Get the fat AABB for a proxy.
An axis aligned bounding box.
void Query(T *callback, const b2AABB &aabb) const