Table of Contents

Class DynamicTreeBroadPhase<TNode>

Namespace
Alis.Core.Physic.Collision
Assembly
Alis.dll

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.

public class DynamicTreeBroadPhase<TNode> : IBroadPhase<TNode> where TNode : struct

Type Parameters

TNode

Inheritance

Implements

Inherited Members

Constructors

DynamicTreeBroadPhase()

Constructs a new broad phase based on the dynamic tree implementation

public DynamicTreeBroadPhase()

Fields

NullProxy

The null proxy

private const int NullProxy = -1

Field Value

int

_moveBuffer

The move buffer

private int[] _moveBuffer

Field Value

int[]

_moveCapacity

The move capacity

private int _moveCapacity

Field Value

int

_moveCount

The move count

private int _moveCount

Field Value

int

_pairBuffer

The pair buffer

private Pair[] _pairBuffer

Field Value

Pair[]

_pairCapacity

The pair capacity

private int _pairCapacity

Field Value

int

_pairCount

The pair count

private int _pairCount

Field Value

int

_queryCallbackCache

The query callback cache

private readonly BroadPhaseQueryCallback _queryCallbackCache

Field Value

BroadPhaseQueryCallback

_queryProxyId

The query proxy id

private int _queryProxyId

Field Value

int

_tree

The node

private readonly DynamicTree<TNode> _tree

Field Value

DynamicTree<TNode>

Properties

ProxyCount

Get the number of proxies.

public int ProxyCount { get; private set; }

Property Value

int

TreeBalance

Gets the balance of the tree.

public int TreeBalance { get; }

Property Value

int

TreeHeight

Gets the height of the tree.

public int TreeHeight { get; }

Property Value

int

TreeQuality

Get the tree quality based on the area of the tree.

public float TreeQuality { get; }

Property Value

float

Methods

AddProxy(ref AABB)

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

public int AddProxy(ref AABB aabb)

Parameters

aabb AABB

Returns

int

BufferMove(int)

Buffers the move using the specified proxy id

private void BufferMove(int proxyId)

Parameters

proxyId int

The proxy id

GetFatAABB(int, out AABB)

Get the AABB for a proxy.

public void GetFatAABB(int proxyId, out AABB aabb)

Parameters

proxyId int

The proxy id.

aabb AABB

The aabb.

GetProxy(int)

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

public TNode GetProxy(int proxyId)

Parameters

proxyId int

The proxy id.

Returns

TNode

MoveProxy(int, ref AABB, Vector2)

Moves the proxy using the specified proxy id

public void MoveProxy(int proxyId, ref AABB aabb, Vector2 displacement)

Parameters

proxyId int

The proxy id

aabb AABB

The aabb

displacement Vector2

The displacement

Query(BroadPhaseQueryCallback, ref AABB)

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

public void Query(BroadPhaseQueryCallback callback, ref AABB aabb)

Parameters

callback BroadPhaseQueryCallback

The callback.

aabb AABB

The aabb.

QueryCallback(int)

This is called from DynamicTree.Query when we are gathering pairs.

private bool QueryCallback(int proxyId)

Parameters

proxyId int

Returns

bool

RayCast(BroadPhaseRayCastCallback, ref RayCastInput)

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.

public void RayCast(BroadPhaseRayCastCallback callback, ref RayCastInput input)

Parameters

callback BroadPhaseRayCastCallback

A callback class that is called for each proxy that is hit by the ray.

input RayCastInput

The ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1).

RemoveProxy(int)

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

public void RemoveProxy(int proxyId)

Parameters

proxyId int

The proxy id.

SetProxy(int, ref TNode)

Sets the proxy using the specified proxy id

public void SetProxy(int proxyId, ref TNode proxy)

Parameters

proxyId int

The proxy id

proxy TNode

The proxy

ShiftOrigin(Vector2)

Shifts the origin using the specified new origin

public void ShiftOrigin(Vector2 newOrigin)

Parameters

newOrigin Vector2

The new origin

TestOverlap(int, int)

Test overlap of fat AABBs.

public bool TestOverlap(int proxyIdA, int proxyIdB)

Parameters

proxyIdA int

The proxy id A.

proxyIdB int

The proxy id B.

Returns

bool

TouchProxy(int)

Touches the proxy using the specified proxy id

public void TouchProxy(int proxyId)

Parameters

proxyId int

The proxy id

UnBufferMove(int)

Uns the buffer move using the specified proxy id

private void UnBufferMove(int proxyId)

Parameters

proxyId int

The proxy id

UpdatePairs(BroadphaseDelegate)

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

public void UpdatePairs(BroadphaseDelegate callback)

Parameters

callback BroadphaseDelegate

The callback.