|
Box2D
2.4.1
A 2D physics engine for games
|
23 #ifndef B2_BROAD_PHASE_H
24 #define B2_BROAD_PHASE_H
29 #include "b2_dynamic_tree.h"
54 int32 CreateProxy(
const b2AABB& aabb,
void* userData);
57 void DestroyProxy(int32 proxyId);
61 void MoveProxy(int32 proxyId,
const b2AABB& aabb,
const b2Vec2& displacement);
64 void TouchProxy(int32 proxyId);
67 const b2AABB& GetFatAABB(int32 proxyId)
const;
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);
118 bool QueryCallback(int32 proxyId);
125 int32 m_moveCapacity;
129 int32 m_pairCapacity;
132 int32 m_queryProxyId;
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)
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);
A 2D column vector.
Definition: b2_math.h:41
Definition: b2_dynamic_tree.h:68
int32 GetTreeHeight() const
Get the height of the embedded tree.
Definition: b2_broad_phase.h:157
const b2AABB & GetFatAABB(int32 proxyId) const
Get the fat AABB for a proxy.
Definition: b2_dynamic_tree.h:181
const b2AABB & GetFatAABB(int32 proxyId) const
Get the fat AABB for a proxy.
Definition: b2_broad_phase.h:147
float GetAreaRatio() const
Get the ratio of the sum of the node areas to the root area.
float GetTreeQuality() const
Get the quality metric of the embedded tree.
Definition: b2_broad_phase.h:167
bool TestOverlap(int32 proxyIdA, int32 proxyIdB) const
Test overlap of fat AABBs.
Definition: b2_broad_phase.h:140
void * GetUserData(int32 proxyId) const
Definition: b2_dynamic_tree.h:163
void RayCast(T *callback, const b2RayCastInput &input) const
Definition: b2_dynamic_tree.h:223
void RayCast(T *callback, const b2RayCastInput &input) const
Definition: b2_broad_phase.h:228
void UpdatePairs(T *callback)
Update the pairs. This results in pair callbacks. This can only add pairs.
Definition: b2_broad_phase.h:173
An axis aligned bounding box.
Definition: b2_collision.h:168
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
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.
Definition: b2_broad_phase.h:40
Definition: b2_broad_phase.h:31
int32 GetProxyCount() const
Get the number of proxies.
Definition: b2_broad_phase.h:152
void Query(T *callback, const b2AABB &aabb) const
Definition: b2_dynamic_tree.h:188
int32 GetMaxBalance() const
void ShiftOrigin(const b2Vec2 &newOrigin)
void Query(T *callback, const b2AABB &aabb) const
Definition: b2_broad_phase.h:222
int32 GetTreeBalance() const
Get the balance of the embedded tree.
Definition: b2_broad_phase.h:162