UNPKG

@box2d/debug-draw

Version:

Debug drawing helper for @box2d

85 lines 3.37 kB
import { b2Vec2, XY } from "../common/b2_math"; import { b2Readonly } from "../common/b2_readonly"; import { b2AABB, b2RayCastInput } from "./b2_collision"; import { b2TreeNode } from "./b2_dynamic_tree"; /** * 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. */ export declare class b2BroadPhase<T> { private readonly m_tree; private m_proxyCount; private m_moveCount; private readonly m_moveBuffer; private m_pairCount; private readonly m_pairBuffer; private m_queryProxy; /** * Create a proxy with an initial AABB. Pairs are not reported until * UpdatePairs is called. */ CreateProxy(aabb: b2AABB, userData: T): b2TreeNode<T>; /** * Destroy a proxy. It is up to the client to remove any pairs. */ DestroyProxy(proxy: b2TreeNode<T>): void; /** * Call MoveProxy as many times as you like, then when you are done * call UpdatePairs to finalized the proxy pairs (for your time step). */ MoveProxy(proxy: b2TreeNode<T>, aabb: b2AABB, displacement: b2Readonly<b2Vec2>): void; /** * Call to trigger a re-processing of it's pairs on the next call to UpdatePairs. */ TouchProxy(proxy: b2TreeNode<T>): void; /** * Get the number of proxies. */ GetProxyCount(): number; /** * Update the pairs. This results in pair callbacks. This can only add pairs. */ UpdatePairs(callback: (a: T, b: T) => void): void; /** * Query an AABB for overlapping proxies. The callback class * is called for each proxy that overlaps the supplied AABB. */ Query(aabb: b2AABB, callback: (node: b2TreeNode<T>) => boolean): void; QueryPoint(point: XY, callback: (node: b2TreeNode<T>) => boolean): void; /** This is called from b2DynamicTree::Query when we are gathering pairs. */ private QueryCallback; /** * 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. * * @param input The ray-cast input data. The ray extends from p1 to p1 + maxFraction * (p2 - p1). * @param callback A callback class that is called for each proxy that is hit by the ray. */ RayCast(input: b2RayCastInput, callback: (input: b2RayCastInput, node: b2TreeNode<T>) => number): void; /** * Get the height of the embedded tree. */ GetTreeHeight(): number; /** * Get the balance of the embedded tree. */ GetTreeBalance(): number; /** * Get the quality metric of the embedded tree. */ GetTreeQuality(): number; /** * Shift the world origin. Useful for large worlds. * The shift formula is: position -= newOrigin * * @param newOrigin The new origin with respect to the old origin */ ShiftOrigin(newOrigin: XY): void; private BufferMove; private UnBufferMove; } //# sourceMappingURL=b2_broad_phase.d.ts.map