19 #ifndef B2_BROAD_PHASE_H    20 #define B2_BROAD_PHASE_H    24 #include <Box2D/Collision/b2DynamicTree.h>    50     int32 CreateProxy(
const b2AABB& aabb, 
void* userData);
    53     void DestroyProxy(int32 proxyId);
    57     void MoveProxy(int32 proxyId, 
const b2AABB& aabb, 
const b2Vec2& displacement);
    60     void TouchProxy(int32 proxyId);
    63     const b2AABB& GetFatAABB(int32 proxyId) 
const;
    66     void* GetUserData(int32 proxyId) 
const;
    69     bool TestOverlap(int32 proxyIdA, int32 proxyIdB) 
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);
   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;
   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);
 Definition: b2DynamicTree.h:61
Definition: b2BroadPhase.h:36
bool TestOverlap(int32 proxyIdA, int32 proxyIdB) const 
Test overlap of fat AABBs. 
Definition: b2BroadPhase.h:152
int32 GetTreeBalance() const 
Get the balance of the embedded tree. 
Definition: b2BroadPhase.h:174
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
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
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
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:53
const b2AABB & GetFatAABB(int32 proxyId) const 
Get the fat AABB for a proxy. 
Definition: b2BroadPhase.h:159