Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
b2BroadPhase Class Reference

#include <b2_broad_phase.h>

Public Types

enum  { e_nullProxy = -1 }
 

Public Member Functions

 b2BroadPhase ()
 
int32 CreateProxy (const b2AABB &aabb, void *userData)
 
void DestroyProxy (int32 proxyId)
 Destroy a proxy. It is up to the client to remove any pairs. More...
 
const b2AABBGetFatAABB (int32 proxyId) const
 Get the fat AABB for a proxy. More...
 
int32 GetProxyCount () const
 Get the number of proxies. More...
 
int32 GetTreeBalance () const
 Get the balance of the embedded tree. More...
 
int32 GetTreeHeight () const
 Get the height of the embedded tree. More...
 
float GetTreeQuality () const
 Get the quality metric of the embedded tree. More...
 
voidGetUserData (int32 proxyId) const
 Get user data from a proxy. Returns nullptr if the id is invalid. More...
 
void MoveProxy (int32 proxyId, const b2AABB &aabb, const b2Vec2 &displacement)
 
template<typename T >
void Query (T *callback, const b2AABB &aabb) const
 
template<typename T >
void RayCast (T *callback, const b2RayCastInput &input) const
 
void ShiftOrigin (const b2Vec2 &newOrigin)
 
bool TestOverlap (int32 proxyIdA, int32 proxyIdB) const
 Test overlap of fat AABBs. More...
 
void TouchProxy (int32 proxyId)
 Call to trigger a re-processing of it's pairs on the next call to UpdatePairs. More...
 
template<typename T >
void UpdatePairs (T *callback)
 Update the pairs. This results in pair callbacks. This can only add pairs. More...
 
 ~b2BroadPhase ()
 

Private Member Functions

void BufferMove (int32 proxyId)
 
bool QueryCallback (int32 proxyId)
 
void UnBufferMove (int32 proxyId)
 

Private Attributes

int32m_moveBuffer
 
int32 m_moveCapacity
 
int32 m_moveCount
 
b2Pairm_pairBuffer
 
int32 m_pairCapacity
 
int32 m_pairCount
 
int32 m_proxyCount
 
int32 m_queryProxyId
 
b2DynamicTree m_tree
 

Friends

class b2DynamicTree
 

Detailed Description

The broad-phase is used for computing pairs and performing volume queries and ray casts. This broad-phase does not persist pairs. Instead, this reports potentially new pairs. It is up to the client to consume the new pairs and to track subsequent overlap.

Definition at line 40 of file b2_broad_phase.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
e_nullProxy 

Definition at line 44 of file b2_broad_phase.h.

Constructor & Destructor Documentation

◆ b2BroadPhase()

b2BroadPhase::b2BroadPhase ( )

Definition at line 26 of file b2_broad_phase.cpp.

◆ ~b2BroadPhase()

b2BroadPhase::~b2BroadPhase ( )

Definition at line 39 of file b2_broad_phase.cpp.

Member Function Documentation

◆ BufferMove()

void b2BroadPhase::BufferMove ( int32  proxyId)
private

Definition at line 74 of file b2_broad_phase.cpp.

◆ CreateProxy()

int32 b2BroadPhase::CreateProxy ( const b2AABB aabb,
void userData 
)

Create a proxy with an initial AABB. Pairs are not reported until UpdatePairs is called.

Definition at line 45 of file b2_broad_phase.cpp.

◆ DestroyProxy()

void b2BroadPhase::DestroyProxy ( int32  proxyId)

Destroy a proxy. It is up to the client to remove any pairs.

Definition at line 53 of file b2_broad_phase.cpp.

◆ GetFatAABB()

const b2AABB & b2BroadPhase::GetFatAABB ( int32  proxyId) const
inline

Get the fat AABB for a proxy.

Definition at line 147 of file b2_broad_phase.h.

◆ GetProxyCount()

int32 b2BroadPhase::GetProxyCount ( ) const
inline

Get the number of proxies.

Definition at line 152 of file b2_broad_phase.h.

◆ GetTreeBalance()

int32 b2BroadPhase::GetTreeBalance ( ) const
inline

Get the balance of the embedded tree.

Definition at line 162 of file b2_broad_phase.h.

◆ GetTreeHeight()

int32 b2BroadPhase::GetTreeHeight ( ) const
inline

Get the height of the embedded tree.

Definition at line 157 of file b2_broad_phase.h.

◆ GetTreeQuality()

float b2BroadPhase::GetTreeQuality ( ) const
inline

Get the quality metric of the embedded tree.

Definition at line 167 of file b2_broad_phase.h.

◆ GetUserData()

void * b2BroadPhase::GetUserData ( int32  proxyId) const
inline

Get user data from a proxy. Returns nullptr if the id is invalid.

Definition at line 135 of file b2_broad_phase.h.

◆ MoveProxy()

void b2BroadPhase::MoveProxy ( int32  proxyId,
const b2AABB aabb,
const b2Vec2 displacement 
)

Call MoveProxy as many times as you like, then when you are done call UpdatePairs to finalized the proxy pairs (for your time step).

Definition at line 60 of file b2_broad_phase.cpp.

◆ Query()

template<typename T >
void b2BroadPhase::Query ( T *  callback,
const b2AABB aabb 
) const
inline

Query an AABB for overlapping proxies. The callback class is called for each proxy that overlaps the supplied AABB.

Definition at line 222 of file b2_broad_phase.h.

◆ QueryCallback()

bool b2BroadPhase::QueryCallback ( int32  proxyId)
private

Definition at line 101 of file b2_broad_phase.cpp.

◆ RayCast()

template<typename T >
void b2BroadPhase::RayCast ( T *  callback,
const b2RayCastInput input 
) const
inline

Ray-cast against the proxies in the tree. This relies on the callback to perform a exact ray-cast in the case were the proxy contains a shape. The callback also performs the any collision filtering. This has performance roughly equal to k * log(n), where k is the number of collisions and n is the number of proxies in the tree.

Parameters
inputthe ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1).
callbacka callback class that is called for each proxy that is hit by the ray.

Definition at line 228 of file b2_broad_phase.h.

◆ ShiftOrigin()

void b2BroadPhase::ShiftOrigin ( const b2Vec2 newOrigin)
inline

Shift the world origin. Useful for large worlds. The shift formula is: position -= newOrigin

Parameters
newOriginthe new origin with respect to the old origin

Definition at line 233 of file b2_broad_phase.h.

◆ TestOverlap()

bool b2BroadPhase::TestOverlap ( int32  proxyIdA,
int32  proxyIdB 
) const
inline

Test overlap of fat AABBs.

Definition at line 140 of file b2_broad_phase.h.

◆ TouchProxy()

void b2BroadPhase::TouchProxy ( int32  proxyId)

Call to trigger a re-processing of it's pairs on the next call to UpdatePairs.

Definition at line 69 of file b2_broad_phase.cpp.

◆ UnBufferMove()

void b2BroadPhase::UnBufferMove ( int32  proxyId)
private

Definition at line 89 of file b2_broad_phase.cpp.

◆ UpdatePairs()

template<typename T >
void b2BroadPhase::UpdatePairs ( T *  callback)

Update the pairs. This results in pair callbacks. This can only add pairs.

Definition at line 173 of file b2_broad_phase.h.

Friends And Related Function Documentation

◆ b2DynamicTree

friend class b2DynamicTree
friend

Definition at line 113 of file b2_broad_phase.h.

Member Data Documentation

◆ m_moveBuffer

int32* b2BroadPhase::m_moveBuffer
private

Definition at line 124 of file b2_broad_phase.h.

◆ m_moveCapacity

int32 b2BroadPhase::m_moveCapacity
private

Definition at line 125 of file b2_broad_phase.h.

◆ m_moveCount

int32 b2BroadPhase::m_moveCount
private

Definition at line 126 of file b2_broad_phase.h.

◆ m_pairBuffer

b2Pair* b2BroadPhase::m_pairBuffer
private

Definition at line 128 of file b2_broad_phase.h.

◆ m_pairCapacity

int32 b2BroadPhase::m_pairCapacity
private

Definition at line 129 of file b2_broad_phase.h.

◆ m_pairCount

int32 b2BroadPhase::m_pairCount
private

Definition at line 130 of file b2_broad_phase.h.

◆ m_proxyCount

int32 b2BroadPhase::m_proxyCount
private

Definition at line 122 of file b2_broad_phase.h.

◆ m_queryProxyId

int32 b2BroadPhase::m_queryProxyId
private

Definition at line 132 of file b2_broad_phase.h.

◆ m_tree

b2DynamicTree b2BroadPhase::m_tree
private

Definition at line 120 of file b2_broad_phase.h.


The documentation for this class was generated from the following files:


mvsim
Author(s):
autogenerated on Tue Jul 4 2023 03:08:22