@codexo/exojs-physics 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -73
- package/{dist/esm/debug/index.d.ts → debug.d.ts} +1 -2
- package/debug.js +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +17 -23
- package/dist/esm/Aabb.d.ts +0 -10
- package/dist/esm/Aabb.d.ts.map +0 -1
- package/dist/esm/Aabb.js +0 -16
- package/dist/esm/Aabb.js.map +0 -1
- package/dist/esm/Collider.d.ts +0 -107
- package/dist/esm/Collider.d.ts.map +0 -1
- package/dist/esm/Collider.js +0 -284
- package/dist/esm/Collider.js.map +0 -1
- package/dist/esm/ContactGraph.d.ts +0 -154
- package/dist/esm/ContactGraph.d.ts.map +0 -1
- package/dist/esm/ContactGraph.js +0 -383
- package/dist/esm/ContactGraph.js.map +0 -1
- package/dist/esm/ContactModifier.d.ts +0 -62
- package/dist/esm/ContactModifier.d.ts.map +0 -1
- package/dist/esm/ContactModifier.js +0 -49
- package/dist/esm/ContactModifier.js.map +0 -1
- package/dist/esm/PhysicsBody.d.ts +0 -186
- package/dist/esm/PhysicsBody.d.ts.map +0 -1
- package/dist/esm/PhysicsBody.js +0 -526
- package/dist/esm/PhysicsBody.js.map +0 -1
- package/dist/esm/PhysicsBodyComponent.d.ts +0 -45
- package/dist/esm/PhysicsBodyComponent.d.ts.map +0 -1
- package/dist/esm/PhysicsBodyComponent.js +0 -77
- package/dist/esm/PhysicsBodyComponent.js.map +0 -1
- package/dist/esm/PhysicsWorld.d.ts +0 -567
- package/dist/esm/PhysicsWorld.d.ts.map +0 -1
- package/dist/esm/PhysicsWorld.js +0 -1096
- package/dist/esm/PhysicsWorld.js.map +0 -1
- package/dist/esm/TimeStepper.d.ts +0 -40
- package/dist/esm/TimeStepper.d.ts.map +0 -1
- package/dist/esm/TimeStepper.js +0 -59
- package/dist/esm/TimeStepper.js.map +0 -1
- package/dist/esm/backend/NativePhysicsBackend.d.ts +0 -28
- package/dist/esm/backend/NativePhysicsBackend.d.ts.map +0 -1
- package/dist/esm/backend/NativePhysicsBackend.js +0 -52
- package/dist/esm/backend/NativePhysicsBackend.js.map +0 -1
- package/dist/esm/backend/PhysicsBackend.d.ts +0 -38
- package/dist/esm/backend/PhysicsBackend.d.ts.map +0 -1
- package/dist/esm/binding/BindingRegistry.d.ts +0 -48
- package/dist/esm/binding/BindingRegistry.d.ts.map +0 -1
- package/dist/esm/binding/BindingRegistry.js +0 -81
- package/dist/esm/binding/BindingRegistry.js.map +0 -1
- package/dist/esm/binding/PhysicsBinding.d.ts +0 -37
- package/dist/esm/binding/PhysicsBinding.d.ts.map +0 -1
- package/dist/esm/binding/PhysicsBinding.js +0 -54
- package/dist/esm/binding/PhysicsBinding.js.map +0 -1
- package/dist/esm/binding/nodeWorldTransform.d.ts +0 -18
- package/dist/esm/binding/nodeWorldTransform.d.ts.map +0 -1
- package/dist/esm/binding/nodeWorldTransform.js +0 -41
- package/dist/esm/binding/nodeWorldTransform.js.map +0 -1
- package/dist/esm/broadphase/AabbTreeBroadPhase.d.ts +0 -84
- package/dist/esm/broadphase/AabbTreeBroadPhase.d.ts.map +0 -1
- package/dist/esm/broadphase/AabbTreeBroadPhase.js +0 -183
- package/dist/esm/broadphase/AabbTreeBroadPhase.js.map +0 -1
- package/dist/esm/broadphase/BroadPhase.d.ts +0 -25
- package/dist/esm/broadphase/BroadPhase.d.ts.map +0 -1
- package/dist/esm/broadphase/index.d.ts +0 -3
- package/dist/esm/broadphase/index.d.ts.map +0 -1
- package/dist/esm/collision/CollisionProxy.d.ts +0 -15
- package/dist/esm/collision/CollisionProxy.d.ts.map +0 -1
- package/dist/esm/collision/Manifold.d.ts +0 -34
- package/dist/esm/collision/Manifold.d.ts.map +0 -1
- package/dist/esm/collision/Manifold.js +0 -37
- package/dist/esm/collision/Manifold.js.map +0 -1
- package/dist/esm/collision/chainAdjacency.d.ts +0 -2
- package/dist/esm/collision/chainAdjacency.d.ts.map +0 -1
- package/dist/esm/collision/chainAdjacency.js +0 -44
- package/dist/esm/collision/chainAdjacency.js.map +0 -1
- package/dist/esm/collision/dispatch.d.ts +0 -35
- package/dist/esm/collision/dispatch.d.ts.map +0 -1
- package/dist/esm/collision/dispatch.js +0 -58
- package/dist/esm/collision/dispatch.js.map +0 -1
- package/dist/esm/collision/index.d.ts +0 -5
- package/dist/esm/collision/index.d.ts.map +0 -1
- package/dist/esm/collision/narrowphase.d.ts +0 -17
- package/dist/esm/collision/narrowphase.d.ts.map +0 -1
- package/dist/esm/collision/narrowphase.js +0 -555
- package/dist/esm/collision/narrowphase.js.map +0 -1
- package/dist/esm/collision/segments.d.ts +0 -19
- package/dist/esm/collision/segments.d.ts.map +0 -1
- package/dist/esm/collision/segments.js +0 -36
- package/dist/esm/collision/segments.js.map +0 -1
- package/dist/esm/collision/sweep.d.ts +0 -35
- package/dist/esm/collision/sweep.d.ts.map +0 -1
- package/dist/esm/collision/sweep.js +0 -437
- package/dist/esm/collision/sweep.js.map +0 -1
- package/dist/esm/debug/PhysicsDebugDraw.d.ts +0 -72
- package/dist/esm/debug/PhysicsDebugDraw.d.ts.map +0 -1
- package/dist/esm/debug/PhysicsDebugDraw.js +0 -239
- package/dist/esm/debug/PhysicsDebugDraw.js.map +0 -1
- package/dist/esm/debug/index.d.ts.map +0 -1
- package/dist/esm/debug/index.js +0 -3
- package/dist/esm/events.d.ts +0 -36
- package/dist/esm/events.d.ts.map +0 -1
- package/dist/esm/index.d.ts +0 -2
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/index.js +0 -25
- package/dist/esm/joints/DistanceJoint.d.ts +0 -70
- package/dist/esm/joints/DistanceJoint.d.ts.map +0 -1
- package/dist/esm/joints/DistanceJoint.js +0 -167
- package/dist/esm/joints/DistanceJoint.js.map +0 -1
- package/dist/esm/joints/Joint.d.ts +0 -76
- package/dist/esm/joints/Joint.d.ts.map +0 -1
- package/dist/esm/joints/Joint.js +0 -62
- package/dist/esm/joints/Joint.js.map +0 -1
- package/dist/esm/joints/MouseJoint.d.ts +0 -55
- package/dist/esm/joints/MouseJoint.d.ts.map +0 -1
- package/dist/esm/joints/MouseJoint.js +0 -139
- package/dist/esm/joints/MouseJoint.js.map +0 -1
- package/dist/esm/joints/PrismaticJoint.d.ts +0 -84
- package/dist/esm/joints/PrismaticJoint.d.ts.map +0 -1
- package/dist/esm/joints/PrismaticJoint.js +0 -218
- package/dist/esm/joints/PrismaticJoint.js.map +0 -1
- package/dist/esm/joints/RevoluteJoint.d.ts +0 -77
- package/dist/esm/joints/RevoluteJoint.d.ts.map +0 -1
- package/dist/esm/joints/RevoluteJoint.js +0 -204
- package/dist/esm/joints/RevoluteJoint.js.map +0 -1
- package/dist/esm/joints/WeldJoint.d.ts +0 -60
- package/dist/esm/joints/WeldJoint.d.ts.map +0 -1
- package/dist/esm/joints/WeldJoint.js +0 -166
- package/dist/esm/joints/WeldJoint.js.map +0 -1
- package/dist/esm/joints/WheelJoint.d.ts +0 -91
- package/dist/esm/joints/WheelJoint.d.ts.map +0 -1
- package/dist/esm/joints/WheelJoint.js +0 -235
- package/dist/esm/joints/WheelJoint.js.map +0 -1
- package/dist/esm/math.d.ts +0 -29
- package/dist/esm/math.d.ts.map +0 -1
- package/dist/esm/math.js +0 -60
- package/dist/esm/math.js.map +0 -1
- package/dist/esm/physicsBuildInfo.d.ts +0 -16
- package/dist/esm/physicsBuildInfo.d.ts.map +0 -1
- package/dist/esm/physicsBuildInfo.js +0 -10
- package/dist/esm/physicsBuildInfo.js.map +0 -1
- package/dist/esm/public.d.ts +0 -34
- package/dist/esm/public.d.ts.map +0 -1
- package/dist/esm/query/QueryEngine.d.ts +0 -95
- package/dist/esm/query/QueryEngine.d.ts.map +0 -1
- package/dist/esm/query/QueryEngine.js +0 -512
- package/dist/esm/query/QueryEngine.js.map +0 -1
- package/dist/esm/query/SpatialIndex.d.ts +0 -34
- package/dist/esm/query/SpatialIndex.d.ts.map +0 -1
- package/dist/esm/shapes/AnyShape.d.ts +0 -14
- package/dist/esm/shapes/AnyShape.d.ts.map +0 -1
- package/dist/esm/shapes/BoxShape.d.ts +0 -12
- package/dist/esm/shapes/BoxShape.d.ts.map +0 -1
- package/dist/esm/shapes/BoxShape.js +0 -41
- package/dist/esm/shapes/BoxShape.js.map +0 -1
- package/dist/esm/shapes/CapsuleShape.d.ts +0 -30
- package/dist/esm/shapes/CapsuleShape.d.ts.map +0 -1
- package/dist/esm/shapes/CapsuleShape.js +0 -88
- package/dist/esm/shapes/CapsuleShape.js.map +0 -1
- package/dist/esm/shapes/ChainEdgeShape.d.ts +0 -2
- package/dist/esm/shapes/ChainEdgeShape.d.ts.map +0 -1
- package/dist/esm/shapes/ChainEdgeShape.js +0 -66
- package/dist/esm/shapes/ChainEdgeShape.js.map +0 -1
- package/dist/esm/shapes/ChainShape.d.ts +0 -46
- package/dist/esm/shapes/ChainShape.d.ts.map +0 -1
- package/dist/esm/shapes/ChainShape.js +0 -85
- package/dist/esm/shapes/ChainShape.js.map +0 -1
- package/dist/esm/shapes/CircleShape.d.ts +0 -14
- package/dist/esm/shapes/CircleShape.d.ts.map +0 -1
- package/dist/esm/shapes/CircleShape.js +0 -31
- package/dist/esm/shapes/CircleShape.js.map +0 -1
- package/dist/esm/shapes/PolygonShape.d.ts +0 -24
- package/dist/esm/shapes/PolygonShape.d.ts.map +0 -1
- package/dist/esm/shapes/PolygonShape.js +0 -153
- package/dist/esm/shapes/PolygonShape.js.map +0 -1
- package/dist/esm/shapes/SegmentShape.d.ts +0 -31
- package/dist/esm/shapes/SegmentShape.d.ts.map +0 -1
- package/dist/esm/shapes/SegmentShape.js +0 -62
- package/dist/esm/shapes/SegmentShape.js.map +0 -1
- package/dist/esm/shapes/Shape.d.ts +0 -37
- package/dist/esm/shapes/Shape.d.ts.map +0 -1
- package/dist/esm/shapes/Shape.js +0 -15
- package/dist/esm/shapes/Shape.js.map +0 -1
- package/dist/esm/shapes/convexParts.d.ts +0 -21
- package/dist/esm/shapes/convexParts.d.ts.map +0 -1
- package/dist/esm/shapes/convexParts.js +0 -26
- package/dist/esm/shapes/convexParts.js.map +0 -1
- package/dist/esm/shapes/decompose.d.ts +0 -2
- package/dist/esm/shapes/decompose.d.ts.map +0 -1
- package/dist/esm/shapes/decompose.js +0 -272
- package/dist/esm/shapes/decompose.js.map +0 -1
- package/dist/esm/shapes/index.d.ts +0 -9
- package/dist/esm/shapes/index.d.ts.map +0 -1
- package/dist/esm/solver/ContactSolver.d.ts +0 -94
- package/dist/esm/solver/ContactSolver.d.ts.map +0 -1
- package/dist/esm/solver/ContactSolver.js +0 -457
- package/dist/esm/solver/ContactSolver.js.map +0 -1
- package/dist/esm/solver/tolerances.d.ts +0 -2
- package/dist/esm/solver/tolerances.d.ts.map +0 -1
- package/dist/esm/solver/tolerances.js +0 -36
- package/dist/esm/solver/tolerances.js.map +0 -1
- package/dist/esm/sort.d.ts +0 -2
- package/dist/esm/sort.d.ts.map +0 -1
- package/dist/esm/sort.js +0 -44
- package/dist/esm/sort.js.map +0 -1
- package/dist/esm/types.d.ts +0 -35
- package/dist/esm/types.d.ts.map +0 -1
- package/dist/esm/types.js +0 -26
- package/dist/esm/types.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"segments.js","names":[],"sources":["../../../src/collision/segments.ts"],"sourcesContent":["import type { PointLike } from '@codexo/exojs';\n\n// Closest-feature primitives shared by every rounded shape. A capsule is a\n// segment with a radius and a chain edge is a segment without one, so all of\n// them reduce to these two questions - point-to-segment and segment-to-segment.\n// Kept as free functions taking output sinks, like the transform helpers, so the\n// narrow phase, the queries and the sweep can all use them allocation-free.\n\n/** Below this squared length a segment is treated as a single point. */\nconst degenerateLengthSquared = 1e-12;\n\n/**\n * Closest point on the segment `a → b` to `(px, py)`, written into `out`.\n * Returns the parameter along the segment, clamped to `[0, 1]`.\n */\nexport const closestPointOnSegment = (px: number, py: number, ax: number, ay: number, bx: number, by: number, out: PointLike): number => {\n const ex = bx - ax;\n const ey = by - ay;\n const lengthSquared = ex * ex + ey * ey;\n\n if (lengthSquared <= degenerateLengthSquared) {\n out.x = ax;\n out.y = ay;\n\n return 0;\n }\n\n const t = clamp01(((px - ax) * ex + (py - ay) * ey) / lengthSquared);\n\n out.x = ax + ex * t;\n out.y = ay + ey * t;\n\n return t;\n};\n\n/** Squared distance from `(px, py)` to the segment `a → b`. */\nexport const pointSegmentDistanceSquared = (px: number, py: number, ax: number, ay: number, bx: number, by: number, scratch: PointLike): number => {\n closestPointOnSegment(px, py, ax, ay, bx, by, scratch);\n\n const dx = px - scratch.x;\n const dy = py - scratch.y;\n\n return dx * dx + dy * dy;\n};\n\n/**\n * Closest points between the segments `a0 → a1` and `b0 → b1`, written into\n * `outA` and `outB`. Returns the squared distance between them.\n *\n * Parallel and overlapping segments have a whole interval of closest pairs; this\n * returns one of them, chosen deterministically. Callers that need a stable\n * two-point manifold for such a case must derive it from the face geometry, not\n * from this single pair.\n */\nexport const segmentSegmentDistanceSquared = (\n a0x: number,\n a0y: number,\n a1x: number,\n a1y: number,\n b0x: number,\n b0y: number,\n b1x: number,\n b1y: number,\n outA: PointLike,\n outB: PointLike,\n): number => {\n const dax = a1x - a0x;\n const day = a1y - a0y;\n const dbx = b1x - b0x;\n const dby = b1y - b0y;\n const rx = a0x - b0x;\n const ry = a0y - b0y;\n const aa = dax * dax + day * day;\n const bb = dbx * dbx + dby * dby;\n const f = dbx * rx + dby * ry;\n\n let s: number;\n let t: number;\n\n if (aa <= degenerateLengthSquared && bb <= degenerateLengthSquared) {\n outA.x = a0x;\n outA.y = a0y;\n outB.x = b0x;\n outB.y = b0y;\n\n return rx * rx + ry * ry;\n }\n\n if (aa <= degenerateLengthSquared) {\n s = 0;\n t = clamp01(f / bb);\n } else {\n const c = dax * rx + day * ry;\n\n if (bb <= degenerateLengthSquared) {\n t = 0;\n s = clamp01(-c / aa);\n } else {\n const b = dax * dbx + day * dby;\n const denom = aa * bb - b * b;\n\n // Parallel segments leave `denom` at zero; pinning s = 0 picks the pair at\n // a0, which is deterministic and as good as any other on the interval.\n s = denom > 0 ? clamp01((b * f - c * bb) / denom) : 0;\n t = (b * s + f) / bb;\n\n if (t < 0) {\n t = 0;\n s = clamp01(-c / aa);\n } else if (t > 1) {\n t = 1;\n s = clamp01((b - c) / aa);\n }\n }\n }\n\n outA.x = a0x + dax * s;\n outA.y = a0y + day * s;\n outB.x = b0x + dbx * t;\n outB.y = b0y + dby * t;\n\n const dx = outA.x - outB.x;\n const dy = outA.y - outB.y;\n\n return dx * dx + dy * dy;\n};\n\nconst clamp01 = (value: number): number => {\n if (value < 0) {\n return 0;\n }\n\n return value > 1 ? 1 : value;\n};\n"],"mappings":";;AASA,MAAM,0BAA0B;;;;;AAMhC,MAAa,yBAAyB,IAAY,IAAY,IAAY,IAAY,IAAY,IAAY,QAA2B;CACvI,MAAM,KAAK,KAAK;CAChB,MAAM,KAAK,KAAK;CAChB,MAAM,gBAAgB,KAAK,KAAK,KAAK;CAErC,IAAI,iBAAiB,yBAAyB;EAC5C,IAAI,IAAI;EACR,IAAI,IAAI;EAER,OAAO;CACT;CAEA,MAAM,IAAI,UAAU,KAAK,MAAM,MAAM,KAAK,MAAM,MAAM,aAAa;CAEnE,IAAI,IAAI,KAAK,KAAK;CAClB,IAAI,IAAI,KAAK,KAAK;CAElB,OAAO;AACT;;AAGA,MAAa,+BAA+B,IAAY,IAAY,IAAY,IAAY,IAAY,IAAY,YAA+B;CACjJ,sBAAsB,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,OAAO;CAErD,MAAM,KAAK,KAAK,QAAQ;CACxB,MAAM,KAAK,KAAK,QAAQ;CAExB,OAAO,KAAK,KAAK,KAAK;AACxB;AAoFA,MAAM,WAAW,UAA0B;CACzC,IAAI,QAAQ,GACV,OAAO;CAGT,OAAO,QAAQ,IAAI,IAAI;AACzB"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { ShapeType } from '../shapes/Shape';
|
|
2
|
-
import type { CollisionProxy } from './CollisionProxy';
|
|
3
|
-
/**
|
|
4
|
-
* First time of impact of a translation-only shape cast, written by
|
|
5
|
-
* {@link sweepProxies} (allocation-free: the caller owns the struct).
|
|
6
|
-
*/
|
|
7
|
-
export interface SweepHit {
|
|
8
|
-
/** Fraction of the motion at first contact, in `(0, 1]`. */
|
|
9
|
-
t: number;
|
|
10
|
-
/** Unit surface normal on the target at the hit, pointing back toward the moving shape (opposing the motion). */
|
|
11
|
-
normalX: number;
|
|
12
|
-
/** See {@link SweepHit.normalX}. */
|
|
13
|
-
normalY: number;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Translation-only shape cast of `moving` against a static `target`: `moving`
|
|
17
|
-
* is given at its **end-of-motion** pose (its cached world geometry) and is
|
|
18
|
-
* swept from `pose − (dx, dy)` to `pose`. Rotation over the motion is not swept
|
|
19
|
-
* - the moving shape keeps its end orientation for the whole cast, matching the
|
|
20
|
-
* bullet CCD model (the step's rotation is applied before the sweep).
|
|
21
|
-
*
|
|
22
|
-
* Returns `true` with the first time of impact and the target-surface normal
|
|
23
|
-
* written into `out`. Pairs already overlapping (or exactly touching) at the
|
|
24
|
-
* start of the motion return `false` - they cannot tunnel within this motion
|
|
25
|
-
* and the discrete solver owns them. Allocation-free.
|
|
26
|
-
*
|
|
27
|
-
* Boundary geometry (a segment, a chain edge) is a target, never the moving
|
|
28
|
-
* operand: a chain edge blocks a bullet under the same one-sided adjacency rule
|
|
29
|
-
* the discrete narrow phase applies, while a fast segment or chain is not swept
|
|
30
|
-
* at all.
|
|
31
|
-
*/
|
|
32
|
-
export declare const sweepProxies: (moving: CollisionProxy, dx: number, dy: number, target: CollisionProxy, out: SweepHit) => boolean;
|
|
33
|
-
/** `true` when {@link sweepProxies} has an implementation for this ordered pair. */
|
|
34
|
-
export declare const canSweep: (moving: ShapeType, target: ShapeType) => boolean;
|
|
35
|
-
//# sourceMappingURL=sweep.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sweep.d.ts","sourceRoot":"","sources":["../../../src/collision/sweep.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKvD;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,4DAA4D;IAC5D,CAAC,EAAE,MAAM,CAAC;IACV,iHAAiH;IACjH,OAAO,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;CACjB;AASD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,YAAY,WAAY,cAAc,MAAM,MAAM,MAAM,MAAM,UAAU,cAAc,OAAO,QAAQ,KAAG,OAiBpH,CAAC;AAEF,oFAAoF;AACpF,eAAO,MAAM,QAAQ,WAAY,SAAS,UAAU,SAAS,KAAG,OAAiE,CAAC"}
|
|
@@ -1,437 +0,0 @@
|
|
|
1
|
-
import { chainEdgeAdmits } from "./chainAdjacency.js";
|
|
2
|
-
import { orderedEntry, orderedTable } from "./dispatch.js";
|
|
3
|
-
import { pointSegmentDistanceSquared } from "./segments.js";
|
|
4
|
-
|
|
5
|
-
//#region src/collision/sweep.ts
|
|
6
|
-
const eps = 1e-9;
|
|
7
|
-
const _pointScratch = {
|
|
8
|
-
x: 0,
|
|
9
|
-
y: 0
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Translation-only shape cast of `moving` against a static `target`: `moving`
|
|
13
|
-
* is given at its **end-of-motion** pose (its cached world geometry) and is
|
|
14
|
-
* swept from `pose − (dx, dy)` to `pose`. Rotation over the motion is not swept
|
|
15
|
-
* - the moving shape keeps its end orientation for the whole cast, matching the
|
|
16
|
-
* bullet CCD model (the step's rotation is applied before the sweep).
|
|
17
|
-
*
|
|
18
|
-
* Returns `true` with the first time of impact and the target-surface normal
|
|
19
|
-
* written into `out`. Pairs already overlapping (or exactly touching) at the
|
|
20
|
-
* start of the motion return `false` - they cannot tunnel within this motion
|
|
21
|
-
* and the discrete solver owns them. Allocation-free.
|
|
22
|
-
*
|
|
23
|
-
* Boundary geometry (a segment, a chain edge) is a target, never the moving
|
|
24
|
-
* operand: a chain edge blocks a bullet under the same one-sided adjacency rule
|
|
25
|
-
* the discrete narrow phase applies, while a fast segment or chain is not swept
|
|
26
|
-
* at all.
|
|
27
|
-
*/
|
|
28
|
-
const sweepProxies = (moving, dx, dy, target, out) => {
|
|
29
|
-
const cast = orderedEntry(sweepTable, moving.shape.type, target.shape.type);
|
|
30
|
-
if (cast === void 0) return false;
|
|
31
|
-
if (!cast(moving, dx, dy, target, out)) return false;
|
|
32
|
-
return chainEdgeAdmits(target, out.normalX, out.normalY);
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Vertex count of a proxy's **core**: the geometry left once its radius is taken
|
|
36
|
-
* off. A circle is a point (no core ring), a capsule and a segment are both a
|
|
37
|
-
* two-vertex ring - with and without a radius - and a polygon is its own ring.
|
|
38
|
-
*/
|
|
39
|
-
const coreCount = (proxy) => {
|
|
40
|
-
switch (proxy.shape.type) {
|
|
41
|
-
case "polygon": return proxy.shape.count;
|
|
42
|
-
case "capsule":
|
|
43
|
-
case "segment": return 2;
|
|
44
|
-
case "circle":
|
|
45
|
-
case "chain": return 0;
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
const radiusOf = (proxy) => proxy.shape.type === "circle" || proxy.shape.type === "capsule" ? proxy.shape.radius : 0;
|
|
49
|
-
/** Moving circle vs static circle: a ray against the Minkowski-summed circle. */
|
|
50
|
-
const sweepCircleCircle = (moving, dx, dy, target, out) => {
|
|
51
|
-
const rsum = radiusOf(moving) + radiusOf(target);
|
|
52
|
-
const cx = target.worldCenter.x;
|
|
53
|
-
const cy = target.worldCenter.y;
|
|
54
|
-
const ox = moving.worldCenter.x - dx;
|
|
55
|
-
const oy = moving.worldCenter.y - dy;
|
|
56
|
-
const mx = ox - cx;
|
|
57
|
-
const my = oy - cy;
|
|
58
|
-
if (mx * mx + my * my <= rsum * rsum) return false;
|
|
59
|
-
const a = dx * dx + dy * dy;
|
|
60
|
-
const b = mx * dx + my * dy;
|
|
61
|
-
const c = mx * mx + my * my - rsum * rsum;
|
|
62
|
-
if (b >= 0) return false;
|
|
63
|
-
const disc = b * b - a * c;
|
|
64
|
-
if (disc < 0) return false;
|
|
65
|
-
const t = (-b - Math.sqrt(disc)) / a;
|
|
66
|
-
if (t < 0 || t > 1) return false;
|
|
67
|
-
out.t = t;
|
|
68
|
-
out.normalX = (ox + dx * t - cx) / rsum;
|
|
69
|
-
out.normalY = (oy + dy * t - cy) / rsum;
|
|
70
|
-
return true;
|
|
71
|
-
};
|
|
72
|
-
/**
|
|
73
|
-
* Moving circle vs a static core ring (polygon, capsule or segment): a ray
|
|
74
|
-
* against that ring inflated by both radii - offset faces plus vertex arcs, the
|
|
75
|
-
* exact swept geometry.
|
|
76
|
-
*/
|
|
77
|
-
const sweepCircleRing = (moving, dx, dy, target, out) => {
|
|
78
|
-
const rsum = radiusOf(moving) + radiusOf(target);
|
|
79
|
-
const ox = moving.worldCenter.x - dx;
|
|
80
|
-
const oy = moving.worldCenter.y - dy;
|
|
81
|
-
const verts = target.worldVertices;
|
|
82
|
-
const normals = target.worldNormals;
|
|
83
|
-
const count = coreCount(target);
|
|
84
|
-
if (pointRingDistanceSquared(ox, oy, verts, normals, count) <= rsum * rsum) return false;
|
|
85
|
-
return castPointAtRing(ox, oy, dx, dy, rsum, verts, normals, count, out);
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* Moving core ring (polygon or capsule) vs static circle, solved in the moving
|
|
89
|
-
* shape's frame: the circle sweeps backward (`−d`) from a start displaced by
|
|
90
|
-
* `+d`, against the ring's end-pose geometry - the same relative motion, so the
|
|
91
|
-
* same time of impact.
|
|
92
|
-
*/
|
|
93
|
-
const sweepRingCircle = (moving, dx, dy, target, out) => {
|
|
94
|
-
const rsum = radiusOf(moving) + radiusOf(target);
|
|
95
|
-
const ox = target.worldCenter.x + dx;
|
|
96
|
-
const oy = target.worldCenter.y + dy;
|
|
97
|
-
const verts = moving.worldVertices;
|
|
98
|
-
const normals = moving.worldNormals;
|
|
99
|
-
const count = coreCount(moving);
|
|
100
|
-
if (pointRingDistanceSquared(ox, oy, verts, normals, count) <= rsum * rsum) return false;
|
|
101
|
-
if (!castPointAtRing(ox, oy, -dx, -dy, rsum, verts, normals, count, out)) return false;
|
|
102
|
-
out.normalX = -out.normalX;
|
|
103
|
-
out.normalY = -out.normalY;
|
|
104
|
-
return true;
|
|
105
|
-
};
|
|
106
|
-
/**
|
|
107
|
-
* Two core rings of which at least one carries a radius (any pair involving a
|
|
108
|
-
* capsule): built as one configuration-space ring and cast as a point, which is
|
|
109
|
-
* exact where a radius-inflated SAT would square off the rounded corners.
|
|
110
|
-
*/
|
|
111
|
-
const sweepRoundedRings = (moving, dx, dy, target, out) => {
|
|
112
|
-
const rsum = radiusOf(moving) + radiusOf(target);
|
|
113
|
-
if (!buildConfigurationRing(moving, dx, dy, target)) return false;
|
|
114
|
-
const verts = _configurationRing.vertices;
|
|
115
|
-
const normals = _configurationRing.normals;
|
|
116
|
-
const count = _configurationRing.count;
|
|
117
|
-
if (pointRingDistanceSquared(0, 0, verts, normals, count) <= rsum * rsum) return false;
|
|
118
|
-
return castPointAtRing(0, 0, dx, dy, rsum, verts, normals, count, out);
|
|
119
|
-
};
|
|
120
|
-
/**
|
|
121
|
-
* Cast the point `(ox, oy)` along `(dx, dy)` (t ∈ [0, 1]) against `count`-vertex
|
|
122
|
-
* convex ring inflated by `r`: offset faces plus vertex arcs - the exact swept
|
|
123
|
-
* geometry. Writes the earliest hit into `out`; the normal points from the ring
|
|
124
|
-
* surface toward the point.
|
|
125
|
-
*/
|
|
126
|
-
const castPointAtRing = (ox, oy, dx, dy, r, verts, normals, count, out) => {
|
|
127
|
-
out.t = Infinity;
|
|
128
|
-
castAtOffsetFaces(ox, oy, dx, dy, r, verts, normals, count, out);
|
|
129
|
-
castAtVertexArcs(ox, oy, dx, dy, r, verts, count, out);
|
|
130
|
-
return out.t !== Infinity;
|
|
131
|
-
};
|
|
132
|
-
/** Offset-face pass of {@link castPointAtRing}: the face plane pushed out by `r`, hits valid within the edge span. */
|
|
133
|
-
const castAtOffsetFaces = (ox, oy, dx, dy, r, verts, normals, count, out) => {
|
|
134
|
-
for (let i = 0; i < count; i++) {
|
|
135
|
-
const nx = normals[i * 2];
|
|
136
|
-
const ny = normals[i * 2 + 1];
|
|
137
|
-
const denom = nx * dx + ny * dy;
|
|
138
|
-
if (denom >= 0) continue;
|
|
139
|
-
const v1x = verts[i * 2];
|
|
140
|
-
const v1y = verts[i * 2 + 1];
|
|
141
|
-
const t = (nx * (v1x - ox) + ny * (v1y - oy) + r) / denom;
|
|
142
|
-
if (t < 0 || t > 1 || t >= out.t) continue;
|
|
143
|
-
const j = (i + 1) % count;
|
|
144
|
-
const v2x = verts[j * 2];
|
|
145
|
-
const v2y = verts[j * 2 + 1];
|
|
146
|
-
const ex = v2x - v1x;
|
|
147
|
-
const ey = v2y - v1y;
|
|
148
|
-
const px = ox + dx * t;
|
|
149
|
-
const py = oy + dy * t;
|
|
150
|
-
const u = (px - v1x) * ex + (py - v1y) * ey;
|
|
151
|
-
if (u < 0 || u > ex * ex + ey * ey) continue;
|
|
152
|
-
out.t = t;
|
|
153
|
-
out.normalX = nx;
|
|
154
|
-
out.normalY = ny;
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
/** Vertex-arc pass of {@link castPointAtRing}: a ray against the circle of radius `r` around each vertex. */
|
|
158
|
-
const castAtVertexArcs = (ox, oy, dx, dy, r, verts, count, out) => {
|
|
159
|
-
if (r <= 0) return;
|
|
160
|
-
const a = dx * dx + dy * dy;
|
|
161
|
-
for (let i = 0; i < count; i++) {
|
|
162
|
-
const vx = verts[i * 2];
|
|
163
|
-
const vy = verts[i * 2 + 1];
|
|
164
|
-
const mx = ox - vx;
|
|
165
|
-
const my = oy - vy;
|
|
166
|
-
const b = mx * dx + my * dy;
|
|
167
|
-
if (b >= 0) continue;
|
|
168
|
-
const c = mx * mx + my * my - r * r;
|
|
169
|
-
if (c < 0) continue;
|
|
170
|
-
const disc = b * b - a * c;
|
|
171
|
-
if (disc < 0) continue;
|
|
172
|
-
const t = (-b - Math.sqrt(disc)) / a;
|
|
173
|
-
if (t < 0 || t > 1 || t >= out.t) continue;
|
|
174
|
-
out.t = t;
|
|
175
|
-
out.normalX = (ox + dx * t - vx) / r;
|
|
176
|
-
out.normalY = (oy + dy * t - vy) / r;
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
/**
|
|
180
|
-
* Squared distance from `(px, py)` to a convex core ring, `0` inside it. A
|
|
181
|
-
* two-vertex ring has no interior, so it is always the distance to the segment.
|
|
182
|
-
*/
|
|
183
|
-
const pointRingDistanceSquared = (px, py, verts, normals, count) => {
|
|
184
|
-
if (count >= 3) {
|
|
185
|
-
let inside = true;
|
|
186
|
-
for (let i = 0; i < count && inside; i++) inside = normals[i * 2] * (px - verts[i * 2]) + normals[i * 2 + 1] * (py - verts[i * 2 + 1]) <= 0;
|
|
187
|
-
if (inside) return 0;
|
|
188
|
-
}
|
|
189
|
-
let best = Infinity;
|
|
190
|
-
for (let i = 0; i < count; i++) {
|
|
191
|
-
const j = (i + 1) % count;
|
|
192
|
-
const distance = pointSegmentDistanceSquared(px, py, verts[i * 2], verts[i * 2 + 1], verts[j * 2], verts[j * 2 + 1], _pointScratch);
|
|
193
|
-
best = distance < best ? distance : best;
|
|
194
|
-
}
|
|
195
|
-
return best;
|
|
196
|
-
};
|
|
197
|
-
const _configurationRing = {
|
|
198
|
-
vertices: [],
|
|
199
|
-
normals: [],
|
|
200
|
-
count: 0
|
|
201
|
-
};
|
|
202
|
-
const _sumPoints = [];
|
|
203
|
-
const _sumOrder = [];
|
|
204
|
-
const _hull = [];
|
|
205
|
-
/**
|
|
206
|
-
* Build the pair's configuration-space obstacle into {@link _configurationRing}:
|
|
207
|
-
* the Minkowski sum of the target's core and the negated start-pose core of the
|
|
208
|
-
* moving shape. A translational cast of the pair is then a cast of the origin
|
|
209
|
-
* point against that single ring, inflated by the two radii - which is why every
|
|
210
|
-
* rounded pair reduces to {@link castPointAtRing} instead of its own algorithm.
|
|
211
|
-
*/
|
|
212
|
-
const buildConfigurationRing = (moving, dx, dy, target) => {
|
|
213
|
-
const movingCount = coreCount(moving);
|
|
214
|
-
const targetCount = coreCount(target);
|
|
215
|
-
if (movingCount < 2 || targetCount < 2) return false;
|
|
216
|
-
const movingVerts = moving.worldVertices;
|
|
217
|
-
const targetVerts = target.worldVertices;
|
|
218
|
-
const total = movingCount * targetCount;
|
|
219
|
-
grow(_sumPoints, total * 2);
|
|
220
|
-
grow(_sumOrder, total);
|
|
221
|
-
for (let j = 0, k = 0; j < targetCount; j++) for (let i = 0; i < movingCount; i++, k++) {
|
|
222
|
-
_sumPoints[k * 2] = targetVerts[j * 2] - (movingVerts[i * 2] - dx);
|
|
223
|
-
_sumPoints[k * 2 + 1] = targetVerts[j * 2 + 1] - (movingVerts[i * 2 + 1] - dy);
|
|
224
|
-
_sumOrder[k] = k;
|
|
225
|
-
}
|
|
226
|
-
const count = convexHull(total);
|
|
227
|
-
if (count < 2) return false;
|
|
228
|
-
grow(_configurationRing.vertices, count * 2);
|
|
229
|
-
grow(_configurationRing.normals, count * 2);
|
|
230
|
-
_configurationRing.count = count;
|
|
231
|
-
const verts = _configurationRing.vertices;
|
|
232
|
-
const normals = _configurationRing.normals;
|
|
233
|
-
for (let i = 0; i < count; i++) {
|
|
234
|
-
const point = _hull[i];
|
|
235
|
-
verts[i * 2] = _sumPoints[point * 2];
|
|
236
|
-
verts[i * 2 + 1] = _sumPoints[point * 2 + 1];
|
|
237
|
-
}
|
|
238
|
-
for (let i = 0; i < count; i++) {
|
|
239
|
-
const j = (i + 1) % count;
|
|
240
|
-
const ex = verts[j * 2] - verts[i * 2];
|
|
241
|
-
const ey = verts[j * 2 + 1] - verts[i * 2 + 1];
|
|
242
|
-
const length = Math.sqrt(ex * ex + ey * ey) || 1;
|
|
243
|
-
normals[i * 2] = ey / length;
|
|
244
|
-
normals[i * 2 + 1] = -ex / length;
|
|
245
|
-
}
|
|
246
|
-
return true;
|
|
247
|
-
};
|
|
248
|
-
/**
|
|
249
|
-
* Counter-clockwise convex hull of the first `total` points in
|
|
250
|
-
* {@link _sumPoints} (Andrew's monotone chain), written as point indices into
|
|
251
|
-
* {@link _hull}; returns the hull size. Collinear points are dropped, so a
|
|
252
|
-
* degenerate sum - two parallel spines - comes out as a two-vertex ring rather
|
|
253
|
-
* than a zero-area polygon.
|
|
254
|
-
*/
|
|
255
|
-
const convexHull = (total) => {
|
|
256
|
-
for (let i = 1; i < total; i++) {
|
|
257
|
-
const value = _sumOrder[i];
|
|
258
|
-
let j = i - 1;
|
|
259
|
-
while (j >= 0 && comparePoints(_sumOrder[j], value) > 0) {
|
|
260
|
-
_sumOrder[j + 1] = _sumOrder[j];
|
|
261
|
-
j--;
|
|
262
|
-
}
|
|
263
|
-
_sumOrder[j + 1] = value;
|
|
264
|
-
}
|
|
265
|
-
grow(_hull, total * 2 + 1);
|
|
266
|
-
let size = 0;
|
|
267
|
-
for (let i = 0; i < total; i++) size = pushHullPoint(_sumOrder[i], size, 2);
|
|
268
|
-
const upperFloor = size + 1;
|
|
269
|
-
for (let i = total - 2; i >= 0; i--) size = pushHullPoint(_sumOrder[i], size, upperFloor);
|
|
270
|
-
return size > 1 ? size - 1 : size;
|
|
271
|
-
};
|
|
272
|
-
/** One monotone-chain step: drop hull points that a left turn onto `point` makes interior. */
|
|
273
|
-
const pushHullPoint = (point, size, floor) => {
|
|
274
|
-
while (size >= floor && cross(_hull[size - 2], _hull[size - 1], point) <= 0) size--;
|
|
275
|
-
_hull[size] = point;
|
|
276
|
-
return size + 1;
|
|
277
|
-
};
|
|
278
|
-
const comparePoints = (a, b) => {
|
|
279
|
-
const ax = _sumPoints[a * 2];
|
|
280
|
-
const bx = _sumPoints[b * 2];
|
|
281
|
-
if (ax !== bx) return ax < bx ? -1 : 1;
|
|
282
|
-
const ay = _sumPoints[a * 2 + 1];
|
|
283
|
-
const by = _sumPoints[b * 2 + 1];
|
|
284
|
-
if (ay === by) return 0;
|
|
285
|
-
return ay < by ? -1 : 1;
|
|
286
|
-
};
|
|
287
|
-
/** Cross product of `o → a` and `o → b`; positive for a counter-clockwise turn. */
|
|
288
|
-
const cross = (o, a, b) => {
|
|
289
|
-
const ox = _sumPoints[o * 2];
|
|
290
|
-
const oy = _sumPoints[o * 2 + 1];
|
|
291
|
-
return (_sumPoints[a * 2] - ox) * (_sumPoints[b * 2 + 1] - oy) - (_sumPoints[a * 2 + 1] - oy) * (_sumPoints[b * 2] - ox);
|
|
292
|
-
};
|
|
293
|
-
/** Extend a scratch array to `length`, keeping it a plain packed number array. */
|
|
294
|
-
const grow = (array, length) => {
|
|
295
|
-
while (array.length < length) array.push(0);
|
|
296
|
-
};
|
|
297
|
-
const _satState = {
|
|
298
|
-
tEnter: 0,
|
|
299
|
-
tLeave: 0,
|
|
300
|
-
normalX: 0,
|
|
301
|
-
normalY: 0
|
|
302
|
-
};
|
|
303
|
-
/**
|
|
304
|
-
* Two radius-free core rings (polygon or segment) via swept SAT: for every
|
|
305
|
-
* candidate axis (both rings' face normals) intersect the moving projection
|
|
306
|
-
* interval with the static one over t ∈ [0, 1]; the latest entry over all axes
|
|
307
|
-
* is the time of impact, and its axis (oriented against the motion) the normal.
|
|
308
|
-
* Exact for linear motion of convex shapes.
|
|
309
|
-
*/
|
|
310
|
-
const sweepRings = (moving, dx, dy, target, out) => {
|
|
311
|
-
const state = _satState;
|
|
312
|
-
state.tEnter = -Infinity;
|
|
313
|
-
state.tLeave = Infinity;
|
|
314
|
-
if (!sweptSatAxes(target, moving, dx, dy, target, state) || !sweptSatAxes(moving, moving, dx, dy, target, state)) return false;
|
|
315
|
-
if (state.tEnter <= 0 || state.tEnter > 1) return false;
|
|
316
|
-
out.t = state.tEnter;
|
|
317
|
-
out.normalX = state.normalX;
|
|
318
|
-
out.normalY = state.normalY;
|
|
319
|
-
return true;
|
|
320
|
-
};
|
|
321
|
-
/**
|
|
322
|
-
* One swept-SAT axis pass over `axisOwner`'s face normals, tightening the
|
|
323
|
-
* `state` entry/exit window of `moving` (translated by `(dx, dy)`, given at its
|
|
324
|
-
* end pose) against the static `target`. Returns `false` as soon as an axis
|
|
325
|
-
* proves the shapes never meet within the motion.
|
|
326
|
-
*/
|
|
327
|
-
const sweptSatAxes = (axisOwner, moving, dx, dy, target, state) => {
|
|
328
|
-
const axes = axisOwner.worldNormals;
|
|
329
|
-
const axisCount = coreCount(axisOwner);
|
|
330
|
-
const mv = moving.worldVertices;
|
|
331
|
-
const mc = coreCount(moving);
|
|
332
|
-
const tv = target.worldVertices;
|
|
333
|
-
const tc = coreCount(target);
|
|
334
|
-
for (let i = 0; i < axisCount; i++) {
|
|
335
|
-
const nx = axes[i * 2];
|
|
336
|
-
const ny = axes[i * 2 + 1];
|
|
337
|
-
const dn = nx * dx + ny * dy;
|
|
338
|
-
let minA = Infinity;
|
|
339
|
-
let maxA = -Infinity;
|
|
340
|
-
for (let k = 0; k < mc; k++) {
|
|
341
|
-
const p = nx * mv[k * 2] + ny * mv[k * 2 + 1];
|
|
342
|
-
minA = p < minA ? p : minA;
|
|
343
|
-
maxA = p > maxA ? p : maxA;
|
|
344
|
-
}
|
|
345
|
-
minA -= dn;
|
|
346
|
-
maxA -= dn;
|
|
347
|
-
let minB = Infinity;
|
|
348
|
-
let maxB = -Infinity;
|
|
349
|
-
for (let k = 0; k < tc; k++) {
|
|
350
|
-
const p = nx * tv[k * 2] + ny * tv[k * 2 + 1];
|
|
351
|
-
minB = p < minB ? p : minB;
|
|
352
|
-
maxB = p > maxB ? p : maxB;
|
|
353
|
-
}
|
|
354
|
-
if (dn > -1e-9 && dn < eps) {
|
|
355
|
-
if (maxA <= minB || maxB <= minA) return false;
|
|
356
|
-
continue;
|
|
357
|
-
}
|
|
358
|
-
const t0 = (minB - maxA) / dn;
|
|
359
|
-
const t1 = (maxB - minA) / dn;
|
|
360
|
-
const entry = t0 < t1 ? t0 : t1;
|
|
361
|
-
const exit = t0 < t1 ? t1 : t0;
|
|
362
|
-
if (entry > state.tEnter) {
|
|
363
|
-
state.tEnter = entry;
|
|
364
|
-
state.normalX = dn < 0 ? nx : -nx;
|
|
365
|
-
state.normalY = dn < 0 ? ny : -ny;
|
|
366
|
-
}
|
|
367
|
-
if (exit < state.tLeave) state.tLeave = exit;
|
|
368
|
-
if (state.tEnter >= state.tLeave) return false;
|
|
369
|
-
}
|
|
370
|
-
return true;
|
|
371
|
-
};
|
|
372
|
-
const sweepTable = orderedTable([
|
|
373
|
-
[
|
|
374
|
-
"circle",
|
|
375
|
-
"circle",
|
|
376
|
-
sweepCircleCircle
|
|
377
|
-
],
|
|
378
|
-
[
|
|
379
|
-
"circle",
|
|
380
|
-
"capsule",
|
|
381
|
-
sweepCircleRing
|
|
382
|
-
],
|
|
383
|
-
[
|
|
384
|
-
"circle",
|
|
385
|
-
"segment",
|
|
386
|
-
sweepCircleRing
|
|
387
|
-
],
|
|
388
|
-
[
|
|
389
|
-
"circle",
|
|
390
|
-
"polygon",
|
|
391
|
-
sweepCircleRing
|
|
392
|
-
],
|
|
393
|
-
[
|
|
394
|
-
"capsule",
|
|
395
|
-
"circle",
|
|
396
|
-
sweepRingCircle
|
|
397
|
-
],
|
|
398
|
-
[
|
|
399
|
-
"capsule",
|
|
400
|
-
"capsule",
|
|
401
|
-
sweepRoundedRings
|
|
402
|
-
],
|
|
403
|
-
[
|
|
404
|
-
"capsule",
|
|
405
|
-
"segment",
|
|
406
|
-
sweepRoundedRings
|
|
407
|
-
],
|
|
408
|
-
[
|
|
409
|
-
"capsule",
|
|
410
|
-
"polygon",
|
|
411
|
-
sweepRoundedRings
|
|
412
|
-
],
|
|
413
|
-
[
|
|
414
|
-
"polygon",
|
|
415
|
-
"circle",
|
|
416
|
-
sweepRingCircle
|
|
417
|
-
],
|
|
418
|
-
[
|
|
419
|
-
"polygon",
|
|
420
|
-
"capsule",
|
|
421
|
-
sweepRoundedRings
|
|
422
|
-
],
|
|
423
|
-
[
|
|
424
|
-
"polygon",
|
|
425
|
-
"segment",
|
|
426
|
-
sweepRings
|
|
427
|
-
],
|
|
428
|
-
[
|
|
429
|
-
"polygon",
|
|
430
|
-
"polygon",
|
|
431
|
-
sweepRings
|
|
432
|
-
]
|
|
433
|
-
]);
|
|
434
|
-
|
|
435
|
-
//#endregion
|
|
436
|
-
export { sweepProxies };
|
|
437
|
-
//# sourceMappingURL=sweep.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sweep.js","names":[],"sources":["../../../src/collision/sweep.ts"],"sourcesContent":["import type { PointLike } from '@codexo/exojs';\n\nimport type { ShapeType } from '../shapes/Shape';\nimport { chainEdgeAdmits } from './chainAdjacency';\nimport type { CollisionProxy } from './CollisionProxy';\nimport type { PairTable } from './dispatch';\nimport { orderedEntry, orderedTable } from './dispatch';\nimport { pointSegmentDistanceSquared } from './segments';\n\n/**\n * First time of impact of a translation-only shape cast, written by\n * {@link sweepProxies} (allocation-free: the caller owns the struct).\n */\nexport interface SweepHit {\n /** Fraction of the motion at first contact, in `(0, 1]`. */\n t: number;\n /** Unit surface normal on the target at the hit, pointing back toward the moving shape (opposing the motion). */\n normalX: number;\n /** See {@link SweepHit.normalX}. */\n normalY: number;\n}\n\nconst eps = 1e-9;\n\n// Module-local scratch shared by the casts below. Like the narrow-phase clip\n// scratch, the sweep is single-threaded and non-reentrant - the world's CCD pass\n// calls `sweepProxies` strictly sequentially - so module-global scratch is safe.\nconst _pointScratch: PointLike = { x: 0, y: 0 };\n\n/**\n * Translation-only shape cast of `moving` against a static `target`: `moving`\n * is given at its **end-of-motion** pose (its cached world geometry) and is\n * swept from `pose − (dx, dy)` to `pose`. Rotation over the motion is not swept\n * - the moving shape keeps its end orientation for the whole cast, matching the\n * bullet CCD model (the step's rotation is applied before the sweep).\n *\n * Returns `true` with the first time of impact and the target-surface normal\n * written into `out`. Pairs already overlapping (or exactly touching) at the\n * start of the motion return `false` - they cannot tunnel within this motion\n * and the discrete solver owns them. Allocation-free.\n *\n * Boundary geometry (a segment, a chain edge) is a target, never the moving\n * operand: a chain edge blocks a bullet under the same one-sided adjacency rule\n * the discrete narrow phase applies, while a fast segment or chain is not swept\n * at all.\n */\nexport const sweepProxies = (moving: CollisionProxy, dx: number, dy: number, target: CollisionProxy, out: SweepHit): boolean => {\n const cast = orderedEntry(sweepTable, moving.shape.type, target.shape.type);\n\n // Unlike the narrow phase, the sweep distinguishes its operands, so this table\n // is filled for both orders. A missing entry reports no impact - the pair is\n // not swept at all rather than swept approximately.\n if (cast === undefined) {\n return false;\n }\n\n if (!cast(moving, dx, dy, target, out)) {\n return false;\n }\n\n // `out` holds the outward normal on the target, which is the direction a chain\n // edge has to admit for the hit to be its own.\n return chainEdgeAdmits(target, out.normalX, out.normalY);\n};\n\n/** `true` when {@link sweepProxies} has an implementation for this ordered pair. */\nexport const canSweep = (moving: ShapeType, target: ShapeType): boolean => orderedEntry(sweepTable, moving, target) !== undefined;\n\n/**\n * Vertex count of a proxy's **core**: the geometry left once its radius is taken\n * off. A circle is a point (no core ring), a capsule and a segment are both a\n * two-vertex ring - with and without a radius - and a polygon is its own ring.\n */\nconst coreCount = (proxy: CollisionProxy): number => {\n switch (proxy.shape.type) {\n case 'polygon':\n return proxy.shape.count;\n case 'capsule':\n case 'segment':\n return 2;\n case 'circle':\n case 'chain':\n // A chain is never an operand here - it is swept through its edge proxies.\n return 0;\n }\n};\n\nconst radiusOf = (proxy: CollisionProxy): number => (proxy.shape.type === 'circle' || proxy.shape.type === 'capsule' ? proxy.shape.radius : 0);\n\n/** Moving circle vs static circle: a ray against the Minkowski-summed circle. */\nconst sweepCircleCircle = (moving: CollisionProxy, dx: number, dy: number, target: CollisionProxy, out: SweepHit): boolean => {\n const rsum = radiusOf(moving) + radiusOf(target);\n const cx = target.worldCenter.x;\n const cy = target.worldCenter.y;\n // Start-of-motion centre.\n const ox = moving.worldCenter.x - dx;\n const oy = moving.worldCenter.y - dy;\n const mx = ox - cx;\n const my = oy - cy;\n\n // Already overlapping/touching at the start: the discrete solver owns it.\n if (mx * mx + my * my <= rsum * rsum) {\n return false;\n }\n\n const a = dx * dx + dy * dy;\n const b = mx * dx + my * dy;\n const c = mx * mx + my * my - rsum * rsum;\n\n if (b >= 0) {\n // Moving away (or tangential) - no entry within the motion.\n return false;\n }\n\n const disc = b * b - a * c;\n\n if (disc < 0) {\n return false;\n }\n\n const t = (-b - Math.sqrt(disc)) / a;\n\n if (t < 0 || t > 1) {\n return false;\n }\n\n out.t = t;\n out.normalX = (ox + dx * t - cx) / rsum;\n out.normalY = (oy + dy * t - cy) / rsum;\n\n return true;\n};\n\n/**\n * Moving circle vs a static core ring (polygon, capsule or segment): a ray\n * against that ring inflated by both radii - offset faces plus vertex arcs, the\n * exact swept geometry.\n */\nconst sweepCircleRing = (moving: CollisionProxy, dx: number, dy: number, target: CollisionProxy, out: SweepHit): boolean => {\n const rsum = radiusOf(moving) + radiusOf(target);\n const ox = moving.worldCenter.x - dx;\n const oy = moving.worldCenter.y - dy;\n const verts = target.worldVertices;\n const normals = target.worldNormals;\n const count = coreCount(target);\n\n // Already overlapping/touching at the start: the discrete solver owns it.\n if (pointRingDistanceSquared(ox, oy, verts, normals, count) <= rsum * rsum) {\n return false;\n }\n\n return castPointAtRing(ox, oy, dx, dy, rsum, verts, normals, count, out);\n};\n\n/**\n * Moving core ring (polygon or capsule) vs static circle, solved in the moving\n * shape's frame: the circle sweeps backward (`−d`) from a start displaced by\n * `+d`, against the ring's end-pose geometry - the same relative motion, so the\n * same time of impact.\n */\nconst sweepRingCircle = (moving: CollisionProxy, dx: number, dy: number, target: CollisionProxy, out: SweepHit): boolean => {\n const rsum = radiusOf(moving) + radiusOf(target);\n const ox = target.worldCenter.x + dx;\n const oy = target.worldCenter.y + dy;\n const verts = moving.worldVertices;\n const normals = moving.worldNormals;\n const count = coreCount(moving);\n\n // Already overlapping/touching at the start: the discrete solver owns it.\n if (pointRingDistanceSquared(ox, oy, verts, normals, count) <= rsum * rsum) {\n return false;\n }\n\n if (!castPointAtRing(ox, oy, -dx, -dy, rsum, verts, normals, count, out)) {\n return false;\n }\n\n // The cast reports the normal on the moving shape toward the circle; the\n // caller wants the obstacle-surface normal, so flip it.\n out.normalX = -out.normalX;\n out.normalY = -out.normalY;\n\n return true;\n};\n\n/**\n * Two core rings of which at least one carries a radius (any pair involving a\n * capsule): built as one configuration-space ring and cast as a point, which is\n * exact where a radius-inflated SAT would square off the rounded corners.\n */\nconst sweepRoundedRings = (moving: CollisionProxy, dx: number, dy: number, target: CollisionProxy, out: SweepHit): boolean => {\n const rsum = radiusOf(moving) + radiusOf(target);\n\n if (!buildConfigurationRing(moving, dx, dy, target)) {\n return false;\n }\n\n const verts = _configurationRing.vertices;\n const normals = _configurationRing.normals;\n const count = _configurationRing.count;\n\n // Already overlapping/touching at the start: the discrete solver owns it.\n if (pointRingDistanceSquared(0, 0, verts, normals, count) <= rsum * rsum) {\n return false;\n }\n\n return castPointAtRing(0, 0, dx, dy, rsum, verts, normals, count, out);\n};\n\n/**\n * Cast the point `(ox, oy)` along `(dx, dy)` (t ∈ [0, 1]) against `count`-vertex\n * convex ring inflated by `r`: offset faces plus vertex arcs - the exact swept\n * geometry. Writes the earliest hit into `out`; the normal points from the ring\n * surface toward the point.\n */\nconst castPointAtRing = (\n ox: number,\n oy: number,\n dx: number,\n dy: number,\n r: number,\n verts: readonly number[],\n normals: readonly number[],\n count: number,\n out: SweepHit,\n): boolean => {\n // Both passes only improve `out` when they beat the current `out.t`.\n out.t = Infinity;\n castAtOffsetFaces(ox, oy, dx, dy, r, verts, normals, count, out);\n castAtVertexArcs(ox, oy, dx, dy, r, verts, count, out);\n\n return out.t !== Infinity;\n};\n\n/** Offset-face pass of {@link castPointAtRing}: the face plane pushed out by `r`, hits valid within the edge span. */\nconst castAtOffsetFaces = (\n ox: number,\n oy: number,\n dx: number,\n dy: number,\n r: number,\n verts: readonly number[],\n normals: readonly number[],\n count: number,\n out: SweepHit,\n): void => {\n for (let i = 0; i < count; i++) {\n // Loop indices are provably in-bounds (0..count-1); the `!` is zero-cost.\n const nx = normals[i * 2]!;\n const ny = normals[i * 2 + 1]!;\n const denom = nx * dx + ny * dy;\n\n if (denom >= 0) {\n continue; // Not entering through this face.\n }\n\n const v1x = verts[i * 2]!;\n const v1y = verts[i * 2 + 1]!;\n const t = (nx * (v1x - ox) + ny * (v1y - oy) + r) / denom;\n\n if (t < 0 || t > 1 || t >= out.t) {\n continue;\n }\n\n const j = (i + 1) % count;\n const v2x = verts[j * 2]!;\n const v2y = verts[j * 2 + 1]!;\n const ex = v2x - v1x;\n const ey = v2y - v1y;\n const px = ox + dx * t;\n const py = oy + dy * t;\n const u = (px - v1x) * ex + (py - v1y) * ey;\n\n if (u < 0 || u > ex * ex + ey * ey) {\n continue; // Outside the edge span — the vertex arcs own the corners.\n }\n\n out.t = t;\n out.normalX = nx;\n out.normalY = ny;\n }\n};\n\n/** Vertex-arc pass of {@link castPointAtRing}: a ray against the circle of radius `r` around each vertex. */\nconst castAtVertexArcs = (ox: number, oy: number, dx: number, dy: number, r: number, verts: readonly number[], count: number, out: SweepHit): void => {\n if (r <= 0) {\n return; // A radius-free ring has no arcs; its faces meet at the vertices.\n }\n\n const a = dx * dx + dy * dy;\n\n for (let i = 0; i < count; i++) {\n const vx = verts[i * 2]!;\n const vy = verts[i * 2 + 1]!;\n const mx = ox - vx;\n const my = oy - vy;\n const b = mx * dx + my * dy;\n\n if (b >= 0) {\n continue; // Moving away from this vertex.\n }\n\n const c = mx * mx + my * my - r * r;\n\n if (c < 0) {\n continue; // Start inside the arc — covered by the start-overlap pre-check.\n }\n\n const disc = b * b - a * c;\n\n if (disc < 0) {\n continue;\n }\n\n const t = (-b - Math.sqrt(disc)) / a;\n\n if (t < 0 || t > 1 || t >= out.t) {\n continue;\n }\n\n out.t = t;\n out.normalX = (ox + dx * t - vx) / r;\n out.normalY = (oy + dy * t - vy) / r;\n }\n};\n\n/**\n * Squared distance from `(px, py)` to a convex core ring, `0` inside it. A\n * two-vertex ring has no interior, so it is always the distance to the segment.\n */\nconst pointRingDistanceSquared = (px: number, py: number, verts: readonly number[], normals: readonly number[], count: number): number => {\n if (count >= 3) {\n let inside = true;\n\n for (let i = 0; i < count && inside; i++) {\n inside = normals[i * 2]! * (px - verts[i * 2]!) + normals[i * 2 + 1]! * (py - verts[i * 2 + 1]!) <= 0;\n }\n\n if (inside) {\n return 0;\n }\n }\n\n let best = Infinity;\n\n for (let i = 0; i < count; i++) {\n const j = (i + 1) % count;\n const distance = pointSegmentDistanceSquared(px, py, verts[i * 2]!, verts[i * 2 + 1]!, verts[j * 2]!, verts[j * 2 + 1]!, _pointScratch);\n\n best = distance < best ? distance : best;\n }\n\n return best;\n};\n\n/** A convex ring in world space: the only geometry the casts above work on. */\ninterface Ring {\n vertices: number[];\n normals: number[];\n count: number;\n}\n\n// Scratch for the configuration-space ring and its hull pass. The arrays grow\n// to the largest pair seen and are then written in place, so a steady-state\n// bullet against known geometry allocates nothing.\nconst _configurationRing: Ring = { vertices: [], normals: [], count: 0 };\nconst _sumPoints: number[] = [];\nconst _sumOrder: number[] = [];\nconst _hull: number[] = [];\n\n/**\n * Build the pair's configuration-space obstacle into {@link _configurationRing}:\n * the Minkowski sum of the target's core and the negated start-pose core of the\n * moving shape. A translational cast of the pair is then a cast of the origin\n * point against that single ring, inflated by the two radii - which is why every\n * rounded pair reduces to {@link castPointAtRing} instead of its own algorithm.\n */\nconst buildConfigurationRing = (moving: CollisionProxy, dx: number, dy: number, target: CollisionProxy): boolean => {\n const movingCount = coreCount(moving);\n const targetCount = coreCount(target);\n\n if (movingCount < 2 || targetCount < 2) {\n return false;\n }\n\n const movingVerts = moving.worldVertices;\n const targetVerts = target.worldVertices;\n const total = movingCount * targetCount;\n\n grow(_sumPoints, total * 2);\n grow(_sumOrder, total);\n\n for (let j = 0, k = 0; j < targetCount; j++) {\n for (let i = 0; i < movingCount; i++, k++) {\n // The moving core at the start of the motion is its end pose minus (dx, dy).\n _sumPoints[k * 2] = targetVerts[j * 2]! - (movingVerts[i * 2]! - dx);\n _sumPoints[k * 2 + 1] = targetVerts[j * 2 + 1]! - (movingVerts[i * 2 + 1]! - dy);\n _sumOrder[k] = k;\n }\n }\n\n const count = convexHull(total);\n\n if (count < 2) {\n return false;\n }\n\n grow(_configurationRing.vertices, count * 2);\n grow(_configurationRing.normals, count * 2);\n _configurationRing.count = count;\n\n const verts = _configurationRing.vertices;\n const normals = _configurationRing.normals;\n\n for (let i = 0; i < count; i++) {\n const point = _hull[i]!;\n\n verts[i * 2] = _sumPoints[point * 2]!;\n verts[i * 2 + 1] = _sumPoints[point * 2 + 1]!;\n }\n\n // Same convention as every authored ring: the outward normal of the\n // counter-clockwise edge i → i+1 is (eY, -eX). A two-vertex ring gets the two\n // opposite normals out of the same loop.\n for (let i = 0; i < count; i++) {\n const j = (i + 1) % count;\n const ex = verts[j * 2]! - verts[i * 2]!;\n const ey = verts[j * 2 + 1]! - verts[i * 2 + 1]!;\n const length = Math.sqrt(ex * ex + ey * ey) || 1;\n\n normals[i * 2] = ey / length;\n normals[i * 2 + 1] = -ex / length;\n }\n\n return true;\n};\n\n/**\n * Counter-clockwise convex hull of the first `total` points in\n * {@link _sumPoints} (Andrew's monotone chain), written as point indices into\n * {@link _hull}; returns the hull size. Collinear points are dropped, so a\n * degenerate sum - two parallel spines - comes out as a two-vertex ring rather\n * than a zero-area polygon.\n */\nconst convexHull = (total: number): number => {\n // Insertion sort by (x, y): the point sets here are a handful of vertices, and\n // sorting in place over the index scratch keeps the pass allocation-free.\n for (let i = 1; i < total; i++) {\n const value = _sumOrder[i]!;\n let j = i - 1;\n\n while (j >= 0 && comparePoints(_sumOrder[j]!, value) > 0) {\n _sumOrder[j + 1] = _sumOrder[j]!;\n j--;\n }\n\n _sumOrder[j + 1] = value;\n }\n\n grow(_hull, total * 2 + 1);\n\n let size = 0;\n\n for (let i = 0; i < total; i++) {\n size = pushHullPoint(_sumOrder[i]!, size, 2);\n }\n\n // The upper chain may not eat into the lower one, so it keeps one more point\n // than the lower chain left behind.\n const upperFloor = size + 1;\n\n for (let i = total - 2; i >= 0; i--) {\n size = pushHullPoint(_sumOrder[i]!, size, upperFloor);\n }\n\n // The chain closes on its starting point, which is already the first entry.\n return size > 1 ? size - 1 : size;\n};\n\n/** One monotone-chain step: drop hull points that a left turn onto `point` makes interior. */\nconst pushHullPoint = (point: number, size: number, floor: number): number => {\n while (size >= floor && cross(_hull[size - 2]!, _hull[size - 1]!, point) <= 0) {\n size--;\n }\n\n _hull[size] = point;\n\n return size + 1;\n};\n\nconst comparePoints = (a: number, b: number): number => {\n const ax = _sumPoints[a * 2]!;\n const bx = _sumPoints[b * 2]!;\n\n if (ax !== bx) {\n return ax < bx ? -1 : 1;\n }\n\n const ay = _sumPoints[a * 2 + 1]!;\n const by = _sumPoints[b * 2 + 1]!;\n\n if (ay === by) {\n return 0;\n }\n\n return ay < by ? -1 : 1;\n};\n\n/** Cross product of `o → a` and `o → b`; positive for a counter-clockwise turn. */\nconst cross = (o: number, a: number, b: number): number => {\n const ox = _sumPoints[o * 2]!;\n const oy = _sumPoints[o * 2 + 1]!;\n\n return (_sumPoints[a * 2]! - ox) * (_sumPoints[b * 2 + 1]! - oy) - (_sumPoints[a * 2 + 1]! - oy) * (_sumPoints[b * 2]! - ox);\n};\n\n/** Extend a scratch array to `length`, keeping it a plain packed number array. */\nconst grow = (array: number[], length: number): void => {\n while (array.length < length) {\n array.push(0);\n }\n};\n\n// Swept-SAT accumulator shared by sweepRings's two axis passes.\n// Module-local scratch under the same single-threaded/non-reentrant contract\n// as the rest of this file.\ninterface SweptSatState {\n tEnter: number;\n tLeave: number;\n normalX: number;\n normalY: number;\n}\n\nconst _satState: SweptSatState = { tEnter: 0, tLeave: 0, normalX: 0, normalY: 0 };\n\n/**\n * Two radius-free core rings (polygon or segment) via swept SAT: for every\n * candidate axis (both rings' face normals) intersect the moving projection\n * interval with the static one over t ∈ [0, 1]; the latest entry over all axes\n * is the time of impact, and its axis (oriented against the motion) the normal.\n * Exact for linear motion of convex shapes.\n */\nconst sweepRings = (moving: CollisionProxy, dx: number, dy: number, target: CollisionProxy, out: SweepHit): boolean => {\n const state = _satState;\n\n state.tEnter = -Infinity;\n state.tLeave = Infinity;\n\n // Two passes: axes from the target, then from the moving ring. Either pass may\n // prove the pair never meets within the motion.\n if (!sweptSatAxes(target, moving, dx, dy, target, state) || !sweptSatAxes(moving, moving, dx, dy, target, state)) {\n return false;\n }\n\n // tEnter ≤ 0 means every axis already overlapped at the start of the motion\n // (i.e. the shapes were overlapping/touching): the discrete solver owns it.\n if (state.tEnter <= 0 || state.tEnter > 1) {\n return false;\n }\n\n out.t = state.tEnter;\n out.normalX = state.normalX;\n out.normalY = state.normalY;\n\n return true;\n};\n\n/**\n * One swept-SAT axis pass over `axisOwner`'s face normals, tightening the\n * `state` entry/exit window of `moving` (translated by `(dx, dy)`, given at its\n * end pose) against the static `target`. Returns `false` as soon as an axis\n * proves the shapes never meet within the motion.\n */\nconst sweptSatAxes = (axisOwner: CollisionProxy, moving: CollisionProxy, dx: number, dy: number, target: CollisionProxy, state: SweptSatState): boolean => {\n const axes = axisOwner.worldNormals;\n const axisCount = coreCount(axisOwner);\n const mv = moving.worldVertices;\n const mc = coreCount(moving);\n const tv = target.worldVertices;\n const tc = coreCount(target);\n\n for (let i = 0; i < axisCount; i++) {\n // Loop indices are provably in-bounds; the `!` is zero-cost.\n const nx = axes[i * 2]!;\n const ny = axes[i * 2 + 1]!;\n const dn = nx * dx + ny * dy;\n\n // Project the moving ring (end pose), then shift to its start pose.\n let minA = Infinity;\n let maxA = -Infinity;\n\n for (let k = 0; k < mc; k++) {\n const p = nx * mv[k * 2]! + ny * mv[k * 2 + 1]!;\n\n minA = p < minA ? p : minA;\n maxA = p > maxA ? p : maxA;\n }\n\n minA -= dn;\n maxA -= dn;\n\n let minB = Infinity;\n let maxB = -Infinity;\n\n for (let k = 0; k < tc; k++) {\n const p = nx * tv[k * 2]! + ny * tv[k * 2 + 1]!;\n\n minB = p < minB ? p : minB;\n maxB = p > maxB ? p : maxB;\n }\n\n if (dn > -eps && dn < eps) {\n // No relative motion along this axis: separated - or exactly touching,\n // which the discrete narrow phase already treats as no contact - here\n // means never in contact.\n if (maxA <= minB || maxB <= minA) {\n return false;\n }\n\n continue;\n }\n\n // Entry/exit times of the moving interval against the static one.\n const t0 = (minB - maxA) / dn;\n const t1 = (maxB - minA) / dn;\n const entry = t0 < t1 ? t0 : t1;\n const exit = t0 < t1 ? t1 : t0;\n\n if (entry > state.tEnter) {\n state.tEnter = entry;\n // Orient the axis against the motion (from the target toward the mover).\n state.normalX = dn < 0 ? nx : -nx;\n state.normalY = dn < 0 ? ny : -ny;\n }\n\n if (exit < state.tLeave) {\n state.tLeave = exit;\n }\n\n if (state.tEnter >= state.tLeave) {\n // Separated on one axis before overlapping on another. Equality is an\n // exact graze (separation touches 0 but never goes negative), which the\n // discrete narrow phase classifies as no contact.\n return false;\n }\n }\n\n return true;\n};\n\n/** One ordered `(moving, target)` shape cast. */\ntype SweepPair = (moving: CollisionProxy, dx: number, dy: number, target: CollisionProxy, out: SweepHit) => boolean;\n\n// Every ordered pair a mass-bearing shape can move as. Boundary geometry\n// (segment, chain) appears only as a target: level structure is not swept, and\n// a fast body that needs protection carries a solid shape.\nconst sweepTable: PairTable<SweepPair> = orderedTable<SweepPair>([\n ['circle', 'circle', sweepCircleCircle],\n ['circle', 'capsule', sweepCircleRing],\n ['circle', 'segment', sweepCircleRing],\n ['circle', 'polygon', sweepCircleRing],\n ['capsule', 'circle', sweepRingCircle],\n ['capsule', 'capsule', sweepRoundedRings],\n ['capsule', 'segment', sweepRoundedRings],\n ['capsule', 'polygon', sweepRoundedRings],\n ['polygon', 'circle', sweepRingCircle],\n ['polygon', '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tC;EAAC;EAAU;EAAW;CAAe;CACrC;EAAC;EAAU;EAAW;CAAe;CACrC;EAAC;EAAU;EAAW;CAAe;CACrC;EAAC;EAAW;EAAU;CAAe;CACrC;EAAC;EAAW;EAAW;CAAiB;CACxC;EAAC;EAAW;EAAW;CAAiB;CACxC;EAAC;EAAW;EAAW;CAAiB;CACxC;EAAC;EAAW;EAAU;CAAe;CACrC;EAAC;EAAW;EAAW;CAAiB;CACxC;EAAC;EAAW;EAAW;CAAU;CACjC;EAAC;EAAW;EAAW;CAAU;AACnC,CAAC"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import type { Application } from '@codexo/exojs';
|
|
2
|
-
import type { DebugLayerViewMode } from '@codexo/exojs/debug';
|
|
3
|
-
import { DebugLayer } from '@codexo/exojs/debug';
|
|
4
|
-
import type { RenderBackend } from '@codexo/exojs/renderer-sdk';
|
|
5
|
-
import type { PhysicsWorld } from '../PhysicsWorld';
|
|
6
|
-
/** Toggles for the physics debug overlay. */
|
|
7
|
-
export interface PhysicsDebugDrawOptions {
|
|
8
|
-
/** Collider shape outlines, coloured by body type. Default `true`. */
|
|
9
|
-
drawShapes?: boolean;
|
|
10
|
-
/** World AABBs of the geometry the broad phase holds - a chain as its per-edge leaves. Default `false`. */
|
|
11
|
-
drawAabb?: boolean;
|
|
12
|
-
/** Contact points. Default `false`. */
|
|
13
|
-
drawContacts?: boolean;
|
|
14
|
-
/** Contact normals. Default `false`. */
|
|
15
|
-
drawNormals?: boolean;
|
|
16
|
-
/** Body origins (centre markers). Default `false`. */
|
|
17
|
-
drawCenters?: boolean;
|
|
18
|
-
/** Broad-phase candidate links between AABB-overlapping leaves - a chain links per edge. Default `false`. */
|
|
19
|
-
drawBroadphase?: boolean;
|
|
20
|
-
/** Tint sleeping bodies distinctly (applies to the shape outline). Default `false`. */
|
|
21
|
-
drawSleeping?: boolean;
|
|
22
|
-
/** Lines connecting the bodies of each joint. Default `false`. */
|
|
23
|
-
drawJoints?: boolean;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* `DebugLayer` that visualises a {@link PhysicsWorld} - shapes, AABBs, contacts,
|
|
27
|
-
* normals, centres and broad-phase links. It reads the world's public state and
|
|
28
|
-
* recomputes contacts/broad-phase locally only while visible, so it never
|
|
29
|
-
* perturbs the simulation and works over any backend. Lives in the `./debug`
|
|
30
|
-
* subpath so it tree-shakes out of production bundles.
|
|
31
|
-
*/
|
|
32
|
-
export declare class PhysicsDebugDraw extends DebugLayer {
|
|
33
|
-
/** Mutable option flags (read each frame). */
|
|
34
|
-
readonly options: Required<PhysicsDebugDrawOptions>;
|
|
35
|
-
private readonly _world;
|
|
36
|
-
private _graphics;
|
|
37
|
-
private readonly _manifold;
|
|
38
|
-
private readonly _pairs;
|
|
39
|
-
constructor(app: Application, world: PhysicsWorld, options?: PhysicsDebugDrawOptions);
|
|
40
|
-
get viewMode(): DebugLayerViewMode;
|
|
41
|
-
update(): void;
|
|
42
|
-
render(backend: RenderBackend): void;
|
|
43
|
-
private _renderJoints;
|
|
44
|
-
destroy(): void;
|
|
45
|
-
private _outlineColor;
|
|
46
|
-
private _strokeShape;
|
|
47
|
-
/**
|
|
48
|
-
* Capsule outline: the two straight sides offset from the spine, joined by a
|
|
49
|
-
* half-circle at each end. The arcs are approximated - a visualisation may
|
|
50
|
-
* tessellate, the solver never does.
|
|
51
|
-
*/
|
|
52
|
-
private _strokeCapsule;
|
|
53
|
-
private _strokeAabb;
|
|
54
|
-
private _strokeCircle;
|
|
55
|
-
private _strokeCross;
|
|
56
|
-
/**
|
|
57
|
-
* Recomputes candidate pairs from scratch for the current frame via a plain
|
|
58
|
-
* brute-force AABB-overlap scan - deliberately NOT `AabbTreeBroadPhase`.
|
|
59
|
-
* That class relies on `Collider._treeProxy`, a field shared on the
|
|
60
|
-
* Collider object and valid only for whichever ONE broad phase currently
|
|
61
|
-
* owns it (the world's own `NativePhysicsBackend`); a second instance here
|
|
62
|
-
* would silently corrupt that ownership every time debug draw and a
|
|
63
|
-
* physics step interleave. Debug-only/opt-in (tree-shaken from production
|
|
64
|
-
* bundles), recomputed from scratch every visible frame regardless, so an
|
|
65
|
-
* O(n^2) scan is an appropriate, fully self-contained trade for
|
|
66
|
-
* correctness - it touches no state outside this method.
|
|
67
|
-
*/
|
|
68
|
-
private _collectPairs;
|
|
69
|
-
private _renderBroadphase;
|
|
70
|
-
private _renderContacts;
|
|
71
|
-
}
|
|
72
|
-
//# sourceMappingURL=PhysicsDebugDraw.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PhysicsDebugDraw.d.ts","sourceRoot":"","sources":["../../../src/debug/PhysicsDebugDraw.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAQhE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGpD,6CAA6C;AAC7C,MAAM,WAAW,uBAAuB;IACtC,sEAAsE;IACtE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,2GAA2G;IAC3G,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uCAAuC;IACvC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,wCAAwC;IACxC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,sDAAsD;IACtD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,6GAA6G;IAC7G,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,uFAAuF;IACvF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,kEAAkE;IAClE,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAmBD;;;;;;GAMG;AACH,qBAAa,gBAAiB,SAAQ,UAAU;IAC9C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