23#ifndef B2_BROAD_PHASE_H
24#define B2_BROAD_PHASE_H
29#include "b2_dynamic_tree.h"
40class B2_API b2BroadPhase
73 bool TestOverlap(int32 proxyIdA, int32 proxyIdB)
const;
113 friend class b2DynamicTree;
115 void BufferMove(int32 proxyId);
116 void UnBufferMove(int32 proxyId);
118 bool QueryCallback(int32 proxyId);
120 b2DynamicTree m_tree;
125 int32 m_moveCapacity;
129 int32 m_pairCapacity;
132 int32 m_queryProxyId;
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();
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);
224 m_tree.Query(callback, aabb);
230 m_tree.RayCast(callback, input);
235 m_tree.ShiftOrigin(newOrigin);
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 MoveProxy(int32 proxyId, const b2AABB &aabb, const b2Vec2 &displacement)
void UpdatePairs(T *callback)
Update the pairs. This results in pair callbacks. This can only add pairs.
Definition b2_broad_phase.h:173
void Query(T *callback, const b2AABB &aabb) const
Definition b2_broad_phase.h:222
bool TestOverlap(int32 proxyIdA, int32 proxyIdB) const
Test overlap of fat AABBs.
Definition b2_broad_phase.h:140
int32 GetTreeBalance() const
Get the balance of the embedded tree.
Definition b2_broad_phase.h:162
void * GetUserData(int32 proxyId) const
Get user data from a proxy. Returns nullptr if the id is invalid.
Definition b2_broad_phase.h:135
void ShiftOrigin(const b2Vec2 &newOrigin)
Definition b2_broad_phase.h:233
void TouchProxy(int32 proxyId)
Call to trigger a re-processing of it's pairs on the next call to UpdatePairs.
void DestroyProxy(int32 proxyId)
Destroy a proxy. It is up to the client to remove any pairs.
int32 GetTreeHeight() const
Get the height of the embedded tree.
Definition b2_broad_phase.h:157
int32 GetProxyCount() const
Get the number of proxies.
Definition b2_broad_phase.h:152
float GetTreeQuality() const
Get the quality metric of the embedded tree.
Definition b2_broad_phase.h:167
int32 CreateProxy(const b2AABB &aabb, void *userData)
void RayCast(T *callback, const b2RayCastInput &input) const
Definition b2_broad_phase.h:228
const b2AABB & GetFatAABB(int32 proxyId) const
Get the fat AABB for a proxy.
Definition b2_broad_phase.h:147
An axis aligned bounding box.
Definition b2_collision.h:169
Definition b2_broad_phase.h:32
A 2D column vector.
Definition b2_math.h:42