UNPKG

@box2d/debug-draw

Version:

Debug drawing helper for @box2d

113 lines 3.76 kB
import { b2Vec2, b2Transform } from "../common/b2_math"; import { b2Readonly } from "../common/b2_readonly"; import type { b2Shape } from "./b2_shape"; /** * A distance proxy is used by the GJK algorithm. * It encapsulates any shape. */ export declare class b2DistanceProxy { readonly m_buffer: b2Vec2[]; m_vertices: b2Vec2[]; m_count: number; m_radius: number; Copy(other: Readonly<b2DistanceProxy>): this; Reset(): b2DistanceProxy; SetShape(shape: b2Shape, index: number): void; /** * Initialize the proxy using the given shape. The shape * must remain in scope while the proxy is in use. * Initialize the proxy using a vertex cloud and radius. The vertices * must remain in scope while the proxy is in use. */ SetVerticesRadius(vertices: b2Vec2[], count: number, radius: number): void; /** Get the supporting vertex index in the given direction. */ GetSupport(d: b2Readonly<b2Vec2>): number; /** Get the supporting vertex in the given direction. */ GetSupportVertex(d: b2Readonly<b2Vec2>): b2Readonly<b2Vec2>; /** Get the vertex count. */ GetVertexCount(): number; /** Get a vertex by index. Used by b2Distance. */ GetVertex(index: number): b2Readonly<b2Vec2>; } /** * Used to warm start b2Distance. * Set count to zero on first call. */ export declare class b2SimplexCache { /** Length or area */ metric: number; count: number; /** Vertices on shape A */ readonly indexA: [number, number, number]; /** Vertices on shape B */ readonly indexB: [number, number, number]; Reset(): b2SimplexCache; } /** * Input for b2Distance. * You have to option to use the shape radii * in the computation. Even */ export declare class b2DistanceInput { readonly proxyA: b2DistanceProxy; readonly proxyB: b2DistanceProxy; readonly transformA: b2Transform; readonly transformB: b2Transform; useRadii: boolean; Reset(): b2DistanceInput; } /** * Output for b2Distance. */ export declare class b2DistanceOutput { /** Closest point on shapeA */ readonly pointA: b2Vec2; /** Closest point on shapeB */ readonly pointB: b2Vec2; distance: number; /** Number of GJK iterations used */ iterations: number; Reset(): b2DistanceOutput; } /** * Input parameters for b2ShapeCast */ export declare class b2ShapeCastInput { readonly proxyA: b2DistanceProxy; readonly proxyB: b2DistanceProxy; readonly transformA: b2Transform; readonly transformB: b2Transform; readonly translationB: b2Vec2; } /** * Output results for b2ShapeCast */ export declare class b2ShapeCastOutput { readonly point: b2Vec2; readonly normal: b2Vec2; lambda: number; iterations: number; } /** GJK using Voronoi regions (Christer Ericson) and Barycentric coordinates. */ export declare const b2Gjk: { calls: number; iters: number; maxIters: number; reset(): void; }; /** * Compute the closest points between two shapes. Supports any combination of: * b2CircleShape, b2PolygonShape, b2EdgeShape. The simplex cache is input/output. * On the first call set b2SimplexCache.count to zero. */ export declare function b2Distance(output: b2DistanceOutput, cache: b2SimplexCache, input: b2DistanceInput): void; /** * Perform a linear shape cast of shape B moving and shape A fixed. Determines the hit point, normal, and translation fraction. * GJK-raycast * Algorithm by Gino van den Bergen. * "Smooth Mesh Contacts with GJK" in Game Physics Pearls. 2010 * * @returns true if hit, false if there is no hit or an initial overlap */ export declare function b2ShapeCast(output: b2ShapeCastOutput, input: b2ShapeCastInput): boolean; //# sourceMappingURL=b2_distance.d.ts.map