Jazz2::Collisions::DynamicTreeBroadPhase class

Broad-phase for collision detection.

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.

Constructors, destructors, conversion operators

DynamicTreeBroadPhase()
~DynamicTreeBroadPhase()

Public functions

auto CreateProxy(const AABBf& aabb, void* userData) -> std::int32_t
Creates a proxy with an initial AABB.
void DestroyProxy(std::int32_t proxyId)
Destroys a proxy.
void MoveProxy(std::int32_t proxyId, const AABBf& aabb, Vector2f displacement)
Moves a proxy with a swepted AABB.
void TouchProxy(std::int32_t proxyId)
Triggers a re-processing of it's pairs on the next call to UpdatePairs()
auto GetFatAABB(std::int32_t proxyId) const -> const AABBf&
Returns the fat AABB for a proxy.
auto GetUserData(std::int32_t proxyId) const -> void*
Returns a user data from a proxy.
auto TestOverlap(std::int32_t proxyIdA, std::int32_t proxyIdB) const -> bool
Tests overlap of fat AABBs.
auto GetProxyCount() const -> std::int32_t
Returns the number of proxies.
template<typename T>
void UpdatePairs(T* callback)
Updates the pairs.
template<typename T>
void Query(T* callback, const AABBf& aabb) const
Queries an AABB for overlapping proxies.
auto GetTreeHeight() const -> std::int32_t
Returns the height of the embedded tree.
auto GetTreeBalance() const -> std::int32_t
Returns the balance of the embedded tree.
auto GetTreeQuality() const -> float
Returns the quality metric of the embedded tree.
void ShiftOrigin(Vector2f newOrigin)
Shift the world origin.

Function documentation

std::int32_t Jazz2::Collisions::DynamicTreeBroadPhase::CreateProxy(const AABBf& aabb, void* userData)

Creates a proxy with an initial AABB.

Pairs are not reported until UpdatePairs() is called

void Jazz2::Collisions::DynamicTreeBroadPhase::MoveProxy(std::int32_t proxyId, const AABBf& aabb, Vector2f displacement)

Moves a proxy with a swepted AABB.

Returns true if the proxy was re-inserted.

If the proxy has moved outside of its fattened AABB, then the proxy is removed from the tree and re-inserted. Otherwise the function returns immediately.

template<typename T>
void Jazz2::Collisions::DynamicTreeBroadPhase::Query(T* callback, const AABBf& aabb) const

Queries an AABB for overlapping proxies.

The callback class is called for each proxy that overlaps the supplied AABB.

void Jazz2::Collisions::DynamicTreeBroadPhase::ShiftOrigin(Vector2f newOrigin)

Shift the world origin.

Parameters
newOrigin the new origin with respect to the old origin

Useful for large worlds. The shift formula is: position -= newOrigin