Box2D
3.0.0
A Real-Time-Oriented 2-D Physics Engine
|
Broad phase assistant. More...
#include <BroadPhase.hpp>
Classes | |
struct | Conf |
Public Types | |
enum | : size_type { e_nullProxy = static_cast<size_type>(-1) } |
using | size_type = std::remove_const< decltype(MaxContacts)>::type |
using | QueryCallback = std::function< bool(size_type)> |
using | RayCastCallback = std::function< RealNum(const RayCastInput &, size_type)> |
Public Member Functions | |
BroadPhase (const Conf conf=GetDefaultConf()) | |
~BroadPhase () noexcept | |
BroadPhase (const BroadPhase ©)=delete | |
BroadPhase & | operator= (const BroadPhase &)=delete |
size_type | CreateProxy (const AABB &aabb, void *userData) |
Creates a proxy with an initial AABB. More... | |
void | DestroyProxy (size_type proxyId) |
Destroys a proxy. It is up to the client to remove any pairs. More... | |
bool | UpdateProxy (const size_type proxyId, const AABB &aabb, const Length2D displacement, const RealNum multiplier=1, const Length extension=Length{0}) |
Updates the proxy. More... | |
void | TouchProxy (size_type proxyId) noexcept |
Call to trigger a re-processing of it's pairs on the next call to UpdatePairs. More... | |
AABB | GetFatAABB (size_type proxyId) const |
Gets the fat AABB for a proxy. More... | |
void * | GetUserData (size_type proxyId) const |
Gets user data from a proxy. More... | |
size_type | GetProxyCount () const noexcept |
Get the number of proxies. More... | |
size_type | UpdatePairs (std::function< bool(void *, void *)> callback) |
Updates the pairs. More... | |
void | Query (const AABB aabb, QueryCallback callback) const |
Query an AABB for overlapping proxies. The callback class is called for each proxy that overlaps the supplied AABB. More... | |
void | RayCast (const RayCastInput &input, RayCastCallback callback) const |
Ray-cast against the proxies in the tree. This relies on the callback to perform an 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. More... | |
size_type | GetTreeHeight () const noexcept |
Gets the height of the embedded tree. More... | |
size_type | GetTreeBalance () const |
Gets the balance of the embedded tree. More... | |
RealNum | GetTreeQuality () const |
Gets the quality metric of the embedded tree. More... | |
void | ShiftOrigin (const Length2D newOrigin) |
Shifts the world origin. Useful for large worlds. The shift formula is: position -= newOrigin. More... | |
size_type | GetPairCapacity () const noexcept |
size_type | GetMoveCapacity () const noexcept |
size_type | GetMoveCount () const noexcept |
size_type | GetPairCount () const noexcept |
Static Public Member Functions | |
static constexpr Conf | GetDefaultConf () noexcept |
Broad phase assistant.
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.
using box2d::BroadPhase::QueryCallback = std::function<bool(size_type)> |
using box2d::BroadPhase::RayCastCallback = std::function<RealNum(const RayCastInput&, size_type)> |
using box2d::BroadPhase::size_type = std::remove_const<decltype(MaxContacts)>::type |
anonymous enum : size_type |
BroadPhase::BroadPhase | ( | const Conf | conf = GetDefaultConf() | ) |
|
noexcept |
|
delete |
BroadPhase::size_type BroadPhase::CreateProxy | ( | const AABB & | aabb, |
void * | userData | ||
) |
Creates a proxy with an initial AABB.
void BroadPhase::DestroyProxy | ( | size_type | proxyId | ) |
Destroys a proxy. It is up to the client to remove any pairs.
|
inlinestaticnoexcept |
Gets the fat AABB for a proxy.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
noexcept |
|
inlinenoexcept |
Get the number of proxies.
|
inline |
Gets the balance of the embedded tree.
|
inlinenoexcept |
Gets the height of the embedded tree.
|
inline |
Gets the quality metric of the embedded tree.
|
inline |
Gets user data from a proxy.
|
delete |
|
inline |
|
inline |
Ray-cast against the proxies in the tree. This relies on the callback to perform an 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.
input | the ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1). |
callback | a callback class that is called for each proxy that is hit by the ray. |
|
inline |
Shifts the world origin. Useful for large worlds. The shift formula is: position -= newOrigin.
newOrigin | the new origin with respect to the old origin |
|
inlinenoexcept |
Call to trigger a re-processing of it's pairs on the next call to UpdatePairs.
BroadPhase::size_type BroadPhase::UpdatePairs | ( | std::function< bool(void *, void *)> | callback | ) |
Updates the pairs.
This results in pair callbacks. This can only add pairs.
callback | Callback that's called for AABB overlapping pairs. |
|
inline |
Updates the proxy.
Call this as many times as you like, then when you are done call UpdatePairs to finalize the proxy pairs (for your time step).
proxyId | Proxy ID. Behavior is undefined if this is the null proxy ID. |
aabb | Axis aligned bounding box. |
displacement | Displacement. Behavior is undefined if this is an invalid value. |
multiplier | Multiplier to displacement amount for new AABB. This is used to predict the future position based on the current displacement. This is a dimensionless multiplier. |
extension | Extension. Amount to extend the AABB by. This is used to fatten AABBs in the dynamic tree. |