23#ifndef B2_BROAD_PHASE_H
24#define B2_BROAD_PHASE_H
29#include "b2_dynamic_tree.h"
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;
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);
224 m_tree.
Query(callback, aabb);
230 m_tree.
RayCast(callback, input);
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:41
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
Definition b2_dynamic_tree.h:69
float GetAreaRatio() const
Get the ratio of the sum of the node areas to the root area.
void Query(T *callback, const b2AABB &aabb) const
Definition b2_dynamic_tree.h:188
int32 GetMaxBalance() const
const b2AABB & GetFatAABB(int32 proxyId) const
Get the fat AABB for a proxy.
Definition b2_dynamic_tree.h:181
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 ShiftOrigin(const b2Vec2 &newOrigin)
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