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 : structType 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 = -1Field Value
_moveBuffer
The move buffer
private int[] _moveBufferField Value
- int[]
_moveCapacity
The move capacity
private int _moveCapacityField Value
_moveCount
The move count
private int _moveCountField Value
_pairBuffer
The pair buffer
private Pair[] _pairBufferField Value
- Pair[]
_pairCapacity
The pair capacity
private int _pairCapacityField Value
_pairCount
The pair count
private int _pairCountField Value
_queryCallbackCache
The query callback cache
private readonly BroadPhaseQueryCallback _queryCallbackCacheField Value
_queryProxyId
The query proxy id
private int _queryProxyIdField Value
_tree
The node
private readonly DynamicTree<TNode> _treeField Value
- DynamicTree<TNode>
Properties
ProxyCount
Get the number of proxies.
public int ProxyCount { get; private set; }Property Value
TreeBalance
Gets the balance of the tree.
public int TreeBalance { get; }Property Value
TreeHeight
Gets the height of the tree.
public int TreeHeight { get; }Property Value
TreeQuality
Get the tree quality based on the area of the tree.
public float TreeQuality { get; }Property Value
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
aabbAABB
Returns
BufferMove(int)
Buffers the move using the specified proxy id
private void BufferMove(int proxyId)Parameters
proxyIdint-
The proxy id
GetFatAABB(int, out AABB)
Get the AABB for a proxy.
public void GetFatAABB(int proxyId, out AABB aabb)Parameters
GetProxy(int)
Get user data from a proxy. Returns null if the id is invalid.
public TNode GetProxy(int proxyId)Parameters
proxyIdint-
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
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
callbackBroadPhaseQueryCallback-
The callback.
aabbAABB-
The aabb.
QueryCallback(int)
This is called from DynamicTree.Query when we are gathering pairs.
private bool QueryCallback(int proxyId)Parameters
proxyIdint
Returns
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
callbackBroadPhaseRayCastCallback-
A callback class that is called for each proxy that is hit by the ray.
inputRayCastInput-
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
proxyIdint-
The proxy id.
SetProxy(int, ref TNode)
Sets the proxy using the specified proxy id
public void SetProxy(int proxyId, ref TNode proxy)Parameters
proxyIdint-
The proxy id
proxyTNode-
The proxy
ShiftOrigin(Vector2)
Shifts the origin using the specified new origin
public void ShiftOrigin(Vector2 newOrigin)Parameters
newOriginVector2-
The new origin
TestOverlap(int, int)
Test overlap of fat AABBs.
public bool TestOverlap(int proxyIdA, int proxyIdB)Parameters
Returns
TouchProxy(int)
Touches the proxy using the specified proxy id
public void TouchProxy(int proxyId)Parameters
proxyIdint-
The proxy id
UnBufferMove(int)
Uns the buffer move using the specified proxy id
private void UnBufferMove(int proxyId)Parameters
proxyIdint-
The proxy id
UpdatePairs(BroadphaseDelegate)
Update the pairs. This results in pair callbacks. This can only add pairs.
public void UpdatePairs(BroadphaseDelegate callback)Parameters
callbackBroadphaseDelegate-
The callback.