Package org.jbox2d.collision.broadphase
Class DynamicTreeFlatNodes
java.lang.Object
org.jbox2d.collision.broadphase.DynamicTreeFlatNodes
- All Implemented Interfaces:
BroadPhaseStrategy
- Author:
- Daniel Murphy
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal intCompute the height of the tree.final intcreateProxy(AABB aabb, Object userData) Create a proxy.final voiddestroyProxy(int proxyId) Destroy a proxyvoidvoidfloatGet the ratio of the sum of the node areas to the root area.final AABBgetFatAABB(int proxyId) intCompute the height of the binary tree in O(N) time.intGet the maximum balance of a node in the tree.final ObjectgetUserData(int proxyId) final booleanMove a proxy with a swepted AABB.final voidquery(TreeCallback callback, AABB aabb) Query an AABB for overlapping proxies.voidraycast(TreeRayCastCallback callback, RayCastInput input) Ray-cast against the proxies in the tree.voidvalidate()Validate this tree.
-
Field Details
-
MAX_STACK_SIZE
public static final int MAX_STACK_SIZE- See Also:
-
NULL_NODE
public static final int NULL_NODE- See Also:
-
INITIAL_BUFFER_LENGTH
public static final int INITIAL_BUFFER_LENGTH- See Also:
-
root
public int root -
memberAabb
-
userData
-
parent
protected int[] parent -
child1
protected int[] child1 -
child2
protected int[] child2 -
height
protected int[] height
-
-
Constructor Details
-
DynamicTreeFlatNodes
public DynamicTreeFlatNodes()
-
-
Method Details
-
createProxy
Description copied from interface:BroadPhaseStrategyCreate a proxy. Provide a tight-fitting AABB and a userData pointer.- Specified by:
createProxyin interfaceBroadPhaseStrategy- Parameters:
aabb- The axis-aligned bounding box.
-
destroyProxy
public final void destroyProxy(int proxyId) Description copied from interface:BroadPhaseStrategyDestroy a proxy- Specified by:
destroyProxyin interfaceBroadPhaseStrategy
-
moveProxy
Description copied from interface:BroadPhaseStrategyMove a proxy with a swepted AABB. If the proxy has moved outside its fattened AABB, then the proxy is removed from the tree and re-inserted. Otherwise, the function returns immediately.- Specified by:
moveProxyin interfaceBroadPhaseStrategyaabb- The axis-aligned bounding box.- Returns:
- true if the proxy was re-inserted.
-
getUserData
- Specified by:
getUserDatain interfaceBroadPhaseStrategy
-
getFatAABB
- Specified by:
getFatAABBin interfaceBroadPhaseStrategy
-
query
Description copied from interface:BroadPhaseStrategyQuery an AABB for overlapping proxies. The callback class is called for each proxy that overlaps the supplied AABB.- Specified by:
queryin interfaceBroadPhaseStrategyaabb- The axis-aligned bounding box.
-
raycast
Description copied from interface:BroadPhaseStrategyRay-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 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.- Specified by:
raycastin interfaceBroadPhaseStrategy- Parameters:
callback- A callback class that is called for each proxy that is hit by the ray.input- The ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1).
-
computeHeight
public final int computeHeight()Description copied from interface:BroadPhaseStrategyCompute the height of the tree.- Specified by:
computeHeightin interfaceBroadPhaseStrategy
-
validate
public void validate()Validate this tree. For testing. -
getHeight
public int getHeight()Description copied from interface:BroadPhaseStrategyCompute the height of the binary tree in O(N) time. Should not be called often.- Specified by:
getHeightin interfaceBroadPhaseStrategy
-
getMaxBalance
public int getMaxBalance()Description copied from interface:BroadPhaseStrategyGet the maximum balance of a node in the tree. The balance is the difference in height of the two children of a node.- Specified by:
getMaxBalancein interfaceBroadPhaseStrategy
-
getAreaRatio
public float getAreaRatio()Description copied from interface:BroadPhaseStrategyGet the ratio of the sum of the node areas to the root area.- Specified by:
getAreaRatioin interfaceBroadPhaseStrategy
-
drawTree
- Specified by:
drawTreein interfaceBroadPhaseStrategy
-
drawTree
-