@codexo/exojs-physics 0.16.2 → 0.18.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.
Files changed (72) hide show
  1. package/README.md +13 -45
  2. package/dist/esm/Collider.d.ts +0 -33
  3. package/dist/esm/Collider.d.ts.map +1 -1
  4. package/dist/esm/Collider.js +10 -1
  5. package/dist/esm/Collider.js.map +1 -1
  6. package/dist/esm/ContactGraph.d.ts +22 -14
  7. package/dist/esm/ContactGraph.d.ts.map +1 -1
  8. package/dist/esm/ContactGraph.js +43 -5
  9. package/dist/esm/ContactGraph.js.map +1 -1
  10. package/dist/esm/ContactModifier.d.ts +0 -23
  11. package/dist/esm/ContactModifier.d.ts.map +1 -1
  12. package/dist/esm/PhysicsBody.d.ts +0 -81
  13. package/dist/esm/PhysicsBody.d.ts.map +1 -1
  14. package/dist/esm/PhysicsBody.js +37 -8
  15. package/dist/esm/PhysicsBody.js.map +1 -1
  16. package/dist/esm/PhysicsWorld.d.ts +63 -41
  17. package/dist/esm/PhysicsWorld.d.ts.map +1 -1
  18. package/dist/esm/PhysicsWorld.js +162 -36
  19. package/dist/esm/PhysicsWorld.js.map +1 -1
  20. package/dist/esm/broadphase/AabbTreeBroadPhase.d.ts +22 -6
  21. package/dist/esm/broadphase/AabbTreeBroadPhase.d.ts.map +1 -1
  22. package/dist/esm/broadphase/AabbTreeBroadPhase.js +45 -11
  23. package/dist/esm/broadphase/AabbTreeBroadPhase.js.map +1 -1
  24. package/dist/esm/collision/chainAdjacency.d.ts +1 -28
  25. package/dist/esm/collision/chainAdjacency.d.ts.map +1 -1
  26. package/dist/esm/joints/DistanceJoint.d.ts +2 -4
  27. package/dist/esm/joints/DistanceJoint.d.ts.map +1 -1
  28. package/dist/esm/joints/DistanceJoint.js +8 -5
  29. package/dist/esm/joints/DistanceJoint.js.map +1 -1
  30. package/dist/esm/joints/Joint.d.ts +59 -9
  31. package/dist/esm/joints/Joint.d.ts.map +1 -1
  32. package/dist/esm/joints/Joint.js +39 -3
  33. package/dist/esm/joints/Joint.js.map +1 -1
  34. package/dist/esm/joints/MouseJoint.d.ts +0 -3
  35. package/dist/esm/joints/MouseJoint.d.ts.map +1 -1
  36. package/dist/esm/joints/MouseJoint.js +4 -1
  37. package/dist/esm/joints/MouseJoint.js.map +1 -1
  38. package/dist/esm/joints/PrismaticJoint.d.ts +2 -4
  39. package/dist/esm/joints/PrismaticJoint.d.ts.map +1 -1
  40. package/dist/esm/joints/PrismaticJoint.js +5 -2
  41. package/dist/esm/joints/PrismaticJoint.js.map +1 -1
  42. package/dist/esm/joints/RevoluteJoint.d.ts +4 -9
  43. package/dist/esm/joints/RevoluteJoint.d.ts.map +1 -1
  44. package/dist/esm/joints/RevoluteJoint.js +42 -33
  45. package/dist/esm/joints/RevoluteJoint.js.map +1 -1
  46. package/dist/esm/joints/WeldJoint.d.ts +2 -4
  47. package/dist/esm/joints/WeldJoint.d.ts.map +1 -1
  48. package/dist/esm/joints/WeldJoint.js +12 -9
  49. package/dist/esm/joints/WeldJoint.js.map +1 -1
  50. package/dist/esm/joints/WheelJoint.d.ts +2 -4
  51. package/dist/esm/joints/WheelJoint.d.ts.map +1 -1
  52. package/dist/esm/joints/WheelJoint.js +8 -5
  53. package/dist/esm/joints/WheelJoint.js.map +1 -1
  54. package/dist/esm/physicsBuildInfo.js +2 -2
  55. package/dist/esm/public.d.ts +1 -1
  56. package/dist/esm/public.d.ts.map +1 -1
  57. package/dist/esm/shapes/ChainEdgeShape.d.ts +1 -29
  58. package/dist/esm/shapes/ChainEdgeShape.d.ts.map +1 -1
  59. package/dist/esm/shapes/ChainShape.d.ts +0 -6
  60. package/dist/esm/shapes/ChainShape.d.ts.map +1 -1
  61. package/dist/esm/shapes/decompose.d.ts +1 -23
  62. package/dist/esm/shapes/decompose.d.ts.map +1 -1
  63. package/dist/esm/solver/ContactSolver.d.ts.map +1 -1
  64. package/dist/esm/solver/ContactSolver.js +16 -3
  65. package/dist/esm/solver/ContactSolver.js.map +1 -1
  66. package/dist/esm/solver/tolerances.d.ts +1 -33
  67. package/dist/esm/solver/tolerances.d.ts.map +1 -1
  68. package/dist/esm/solver/tolerances.js +14 -16
  69. package/dist/esm/solver/tolerances.js.map +1 -1
  70. package/dist/esm/sort.d.ts +1 -17
  71. package/dist/esm/sort.d.ts.map +1 -1
  72. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"WheelJoint.js","names":[],"sources":["../../../src/joints/WheelJoint.ts"],"sourcesContent":["import type { PointLike } from '@codexo/exojs';\n\nimport { applyInverseRotation, applyInverseTransform, applyRotation, applyTransform } from '../math';\nimport type { PhysicsBody } from '../PhysicsBody';\nimport { Joint } from './Joint';\n\n/** Construction options for a {@link WheelJoint}. */\nexport interface WheelJointOptions {\n /** First body (the chassis). */\n bodyA: PhysicsBody;\n /** Second body (the wheel). */\n bodyB: PhysicsBody;\n /** Shared world-space anchor at creation (the wheel hub). */\n anchor: Readonly<PointLike>;\n /** Suspension axis in world space at creation (normalised internally). */\n axis: Readonly<PointLike>;\n /** Suspension spring frequency in Hz (`0` makes the axis rigid). Default `0`. */\n hertz?: number;\n /** Suspension spring damping ratio. Default `1`. */\n dampingRatio?: number;\n /** Enable the rotation motor (drives the wheel's spin). Default `false`. */\n enableMotor?: boolean;\n /** Target relative angular velocity (rad/s) for the motor. Default `0`. */\n motorSpeed?: number;\n /** Maximum motor torque. Default `0`. */\n maxMotorTorque?: number;\n /** Enable the suspension-travel limit (keeps the axis translation in `[lowerTranslation, upperTranslation]`). Default `false`. */\n enableLimit?: boolean;\n /** Lower suspension-travel limit along the axis (relative to the creation position). Default `0`. */\n lowerTranslation?: number;\n /** Upper suspension-travel limit along the axis. Default `0`. */\n upperTranslation?: number;\n}\n\n/** Reused output sink - physics steps single-threaded, so a shared scratch is safe. */\nconst scratch: PointLike = { x: 0, y: 0 };\n\n/**\n * A wheel attached to a chassis: free to **spin** (no rotation lock) and sprung\n * along a **suspension axis** (a soft spring), but locked **laterally** (it\n * cannot slide perpendicular to the axis). Optionally driven by a rotation\n * motor and/or bounded by a suspension-travel limit. Used for vehicles. Solved\n * in the sub-step loop, warm-started.\n */\nexport class WheelJoint extends Joint {\n /** Suspension spring frequency in Hz (`0` = rigid axis). */\n public hertz: number;\n /** Suspension spring damping ratio. */\n public dampingRatio: number;\n /** When `true`, the motor drives the wheel's spin toward {@link motorSpeed}. */\n public enableMotor: boolean;\n /** Target relative angular velocity (rad/s) for the motor. */\n public motorSpeed: number;\n /** Maximum motor torque. */\n public maxMotorTorque: number;\n /** When `true`, the axis translation is constrained to `[lowerTranslation, upperTranslation]`. */\n public enableLimit: boolean;\n /** Lower suspension-travel limit along the axis. */\n public lowerTranslation: number;\n /** Upper suspension-travel limit along the axis. */\n public upperTranslation: number;\n\n private readonly _localAnchorAx: number;\n private readonly _localAnchorAy: number;\n private readonly _localAnchorBx: number;\n private readonly _localAnchorBy: number;\n private readonly _localAxisAx: number;\n private readonly _localAxisAy: number;\n\n private _axisX = 1;\n private _axisY = 0;\n private _perpX = 0;\n private _perpY = 1;\n private _a1 = 0;\n private _a2 = 0;\n private _s1 = 0;\n private _s2 = 0;\n private _perpMass = 0;\n private _axialMass = 0;\n private _angularMass = 0;\n private _springBiasRate = 0;\n private _springMassScale = 1;\n private _springImpulseScale = 0;\n private _cPerp = 0;\n private _translation = 0;\n private _h = 0;\n private _invH = 0;\n private _perpImpulse = 0;\n private _springImpulse = 0;\n private _motorImpulse = 0;\n private _lowerImpulse = 0;\n private _upperImpulse = 0;\n\n public constructor(options: WheelJointOptions) {\n super(options.bodyA, options.bodyB);\n\n applyInverseTransform(options.bodyA.transform, options.anchor.x, options.anchor.y, scratch);\n this._localAnchorAx = scratch.x;\n this._localAnchorAy = scratch.y;\n applyInverseTransform(options.bodyB.transform, options.anchor.x, options.anchor.y, scratch);\n this._localAnchorBx = scratch.x;\n this._localAnchorBy = scratch.y;\n\n const axisLength = Math.hypot(options.axis.x, options.axis.y);\n\n if (!Number.isFinite(axisLength) || axisLength === 0) {\n throw new RangeError(`WheelJoint: axis must be a non-zero finite vector, received (${options.axis.x}, ${options.axis.y}).`);\n }\n\n applyInverseRotation(options.bodyA.transform, options.axis.x / axisLength, options.axis.y / axisLength, scratch);\n this._localAxisAx = scratch.x;\n this._localAxisAy = scratch.y;\n\n this.hertz = options.hertz ?? 0;\n this.dampingRatio = options.dampingRatio ?? 1;\n this.enableMotor = options.enableMotor ?? false;\n this.motorSpeed = options.motorSpeed ?? 0;\n this.maxMotorTorque = options.maxMotorTorque ?? 0;\n this.enableLimit = options.enableLimit ?? false;\n this.lowerTranslation = options.lowerTranslation ?? 0;\n this.upperTranslation = options.upperTranslation ?? 0;\n }\n\n public override _prepare(h: number): void {\n const bodyA = this.bodyA;\n const bodyB = this.bodyB;\n\n this._active = this.enabled && !bodyA.isSleeping && !bodyB.isSleeping && (bodyA.invMass > 0 || bodyB.invMass > 0);\n\n if (!this._active) {\n return;\n }\n\n applyRotation(bodyA.transform, this._localAxisAx, this._localAxisAy, scratch);\n const axisX = scratch.x;\n const axisY = scratch.y;\n const perpX = -axisY;\n const perpY = axisX;\n\n this._axisX = axisX;\n this._axisY = axisY;\n this._perpX = perpX;\n this._perpY = perpY;\n\n applyTransform(bodyA.transform, this._localAnchorAx, this._localAnchorAy, scratch);\n const pAx = scratch.x;\n const pAy = scratch.y;\n applyTransform(bodyB.transform, this._localAnchorBx, this._localAnchorBy, scratch);\n const pBx = scratch.x;\n const pBy = scratch.y;\n\n const rAx = pAx - bodyA.worldCenterOfMassX;\n const rAy = pAy - bodyA.worldCenterOfMassY;\n const rBx = pBx - bodyB.worldCenterOfMassX;\n const rBy = pBy - bodyB.worldCenterOfMassY;\n const dx = pBx - pAx;\n const dy = pBy - pAy;\n\n this._a1 = (dx + rAx) * axisY - (dy + rAy) * axisX;\n this._a2 = rBx * axisY - rBy * axisX;\n this._s1 = (dx + rAx) * perpY - (dy + rAy) * perpX;\n this._s2 = rBx * perpY - rBy * perpX;\n\n const mA = bodyA.invMass;\n const mB = bodyB.invMass;\n const iA = bodyA.invInertia;\n const iB = bodyB.invInertia;\n\n const kPerp = mA + mB + iA * this._s1 * this._s1 + iB * this._s2 * this._s2;\n this._perpMass = kPerp > 0 ? 1 / kPerp : 0;\n const kAxial = mA + mB + iA * this._a1 * this._a1 + iB * this._a2 * this._a2;\n this._axialMass = kAxial > 0 ? 1 / kAxial : 0;\n this._angularMass = iA + iB > 0 ? 1 / (iA + iB) : 0;\n\n this._cPerp = dx * perpX + dy * perpY;\n this._translation = dx * axisX + dy * axisY;\n this._h = h;\n this._invH = 1 / h;\n\n if (this.hertz > 0) {\n const omega = 2 * Math.PI * this.hertz;\n const a1 = 2 * this.dampingRatio + h * omega;\n const a2 = h * omega * a1;\n const a3 = 1 / (1 + a2);\n\n this._springBiasRate = omega / a1;\n this._springMassScale = a2 * a3;\n this._springImpulseScale = a3;\n } else {\n this._springBiasRate = 0.2 / h;\n this._springMassScale = 1;\n this._springImpulseScale = 0;\n }\n\n if (!this.enableMotor) {\n this._motorImpulse = 0;\n }\n\n if (!this.enableLimit) {\n this._lowerImpulse = 0;\n this._upperImpulse = 0;\n }\n }\n\n public override _warmStart(): void {\n if (!this._active) {\n return;\n }\n\n const bodyA = this.bodyA;\n const bodyB = this.bodyB;\n\n // Rotation motor (angular).\n bodyA.angularVelocity -= bodyA.invInertia * this._motorImpulse;\n bodyB.angularVelocity += bodyB.invInertia * this._motorImpulse;\n\n this._applyAxial(this._springImpulse + this._lowerImpulse - this._upperImpulse);\n this._applyPerp(this._perpImpulse);\n }\n\n public override _solve(useBias: boolean): void {\n if (!this._active) {\n return;\n }\n\n const bodyA = this.bodyA;\n const bodyB = this.bodyB;\n\n // Rotation motor - drives the wheel's spin; rotation is otherwise free.\n if (this.enableMotor) {\n const cdot = bodyB.angularVelocity - bodyA.angularVelocity - this.motorSpeed;\n const max = this.maxMotorTorque * this._h;\n const old = this._motorImpulse;\n\n this._motorImpulse = Math.min(max, Math.max(-max, old - this._angularMass * cdot));\n\n const applied = this._motorImpulse - old;\n bodyA.angularVelocity -= bodyA.invInertia * applied;\n bodyB.angularVelocity += bodyB.invInertia * applied;\n }\n\n // Suspension spring along the axis (soft).\n const cdotAxis = this._axisVelocity();\n const springImpulse =\n -this._axialMass * this._springMassScale * (cdotAxis + this._springBiasRate * this._translation) - this._springImpulseScale * this._springImpulse;\n\n this._springImpulse += springImpulse;\n this._applyAxial(springImpulse);\n\n // Suspension-travel limits along the axis.\n if (this.enableLimit) {\n // Lower limit (translation ≥ lowerTranslation): positive impulse pushes along +axis.\n const cLower = this._translation - this.lowerTranslation;\n let biasLower = 0;\n\n if (cLower > 0) {\n biasLower = cLower * this._invH;\n } else if (useBias) {\n biasLower = 0.2 * this._invH * cLower;\n }\n\n const oldLower = this._lowerImpulse;\n this._lowerImpulse = Math.max(0, oldLower - this._axialMass * (this._axisVelocity() + biasLower));\n this._applyAxial(this._lowerImpulse - oldLower);\n\n // Upper limit (translation ≤ upperTranslation): impulse pushes along −axis.\n const cUpper = this.upperTranslation - this._translation;\n let biasUpper = 0;\n\n if (cUpper > 0) {\n biasUpper = cUpper * this._invH;\n } else if (useBias) {\n biasUpper = 0.2 * this._invH * cUpper;\n }\n\n const oldUpper = this._upperImpulse;\n this._upperImpulse = Math.max(0, oldUpper - this._axialMass * (-this._axisVelocity() + biasUpper));\n this._applyAxial(-(this._upperImpulse - oldUpper));\n }\n\n // Lateral lock (perpendicular, rigid).\n const cdotPerp = this._perpVelocity();\n const perpImpulse = -this._perpMass * (cdotPerp + (useBias ? 0.2 * this._invH * this._cPerp : 0));\n\n this._perpImpulse += perpImpulse;\n this._applyPerp(perpImpulse);\n }\n\n private _axisVelocity(): number {\n const bodyA = this.bodyA;\n const bodyB = this.bodyB;\n\n return (\n this._axisX * (bodyB.linearVelocityX - bodyA.linearVelocityX) +\n this._axisY * (bodyB.linearVelocityY - bodyA.linearVelocityY) +\n this._a2 * bodyB.angularVelocity -\n this._a1 * bodyA.angularVelocity\n );\n }\n\n private _perpVelocity(): number {\n const bodyA = this.bodyA;\n const bodyB = this.bodyB;\n\n return (\n this._perpX * (bodyB.linearVelocityX - bodyA.linearVelocityX) +\n this._perpY * (bodyB.linearVelocityY - bodyA.linearVelocityY) +\n this._s2 * bodyB.angularVelocity -\n this._s1 * bodyA.angularVelocity\n );\n }\n\n private _applyAxial(impulse: number): void {\n const bodyA = this.bodyA;\n const bodyB = this.bodyB;\n const px = impulse * this._axisX;\n const py = impulse * this._axisY;\n\n bodyA.linearVelocityX -= bodyA.invMass * px;\n bodyA.linearVelocityY -= bodyA.invMass * py;\n bodyA.angularVelocity -= bodyA.invInertia * impulse * this._a1;\n bodyB.linearVelocityX += bodyB.invMass * px;\n bodyB.linearVelocityY += bodyB.invMass * py;\n bodyB.angularVelocity += bodyB.invInertia * impulse * this._a2;\n }\n\n private _applyPerp(impulse: number): void {\n const bodyA = this.bodyA;\n const bodyB = this.bodyB;\n const px = impulse * this._perpX;\n const py = impulse * this._perpY;\n\n bodyA.linearVelocityX -= bodyA.invMass * px;\n bodyA.linearVelocityY -= bodyA.invMass * py;\n bodyA.angularVelocity -= bodyA.invInertia * impulse * this._s1;\n bodyB.linearVelocityX += bodyB.invMass * px;\n bodyB.linearVelocityY += bodyB.invMass * py;\n bodyB.angularVelocity += bodyB.invInertia * impulse * this._s2;\n }\n}\n"],"mappings":";;;;;AAmCA,MAAM,UAAqB;CAAE,GAAG;CAAG,GAAG;AAAE;;;;;;;;AASxC,IAAa,aAAb,cAAgC,MAAM;;CAEpC,AAAO;;CAEP,AAAO;;CAEP,AAAO;;CAEP,AAAO;;CAEP,AAAO;;CAEP,AAAO;;CAEP,AAAO;;CAEP,AAAO;CAEP,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CAEjB,AAAQ,SAAS;CACjB,AAAQ,SAAS;CACjB,AAAQ,SAAS;CACjB,AAAQ,SAAS;CACjB,AAAQ,MAAM;CACd,AAAQ,M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1
+ {"version":3,"file":"WheelJoint.js","names":[],"sources":["../../../src/joints/WheelJoint.ts"],"sourcesContent":["import type { PointLike } from '@codexo/exojs';\n\nimport { applyInverseRotation, applyInverseTransform, applyRotation, applyTransform } from '../math';\nimport type { PhysicsBody } from '../PhysicsBody';\nimport type { JointOptions, JointSoftness } from './Joint';\nimport { Joint } from './Joint';\n\n/** Construction options for a {@link WheelJoint}. */\nexport interface WheelJointOptions extends JointOptions {\n /** First body (the chassis). */\n bodyA: PhysicsBody;\n /** Second body (the wheel). */\n bodyB: PhysicsBody;\n /** Shared world-space anchor at creation (the wheel hub). */\n anchor: Readonly<PointLike>;\n /** Suspension axis in world space at creation (normalised internally). */\n axis: Readonly<PointLike>;\n /** Suspension spring frequency in Hz (`0` makes the axis rigid). Default `0`. */\n hertz?: number;\n /** Suspension spring damping ratio. Default `1`. */\n dampingRatio?: number;\n /** Enable the rotation motor (drives the wheel's spin). Default `false`. */\n enableMotor?: boolean;\n /** Target relative angular velocity (rad/s) for the motor. Default `0`. */\n motorSpeed?: number;\n /** Maximum motor torque. Default `0`. */\n maxMotorTorque?: number;\n /** Enable the suspension-travel limit (keeps the axis translation in `[lowerTranslation, upperTranslation]`). Default `false`. */\n enableLimit?: boolean;\n /** Lower suspension-travel limit along the axis (relative to the creation position). Default `0`. */\n lowerTranslation?: number;\n /** Upper suspension-travel limit along the axis. Default `0`. */\n upperTranslation?: number;\n}\n\n/** Reused output sink - physics steps single-threaded, so a shared scratch is safe. */\nconst scratch: PointLike = { x: 0, y: 0 };\n\n/**\n * A wheel attached to a chassis: free to **spin** (no rotation lock) and sprung\n * along a **suspension axis** (a soft spring), but locked **laterally** (it\n * cannot slide perpendicular to the axis). Optionally driven by a rotation\n * motor and/or bounded by a suspension-travel limit. Used for vehicles. Solved\n * in the sub-step loop, warm-started.\n */\nexport class WheelJoint extends Joint {\n /** Suspension spring frequency in Hz (`0` = rigid axis). */\n public hertz: number;\n /** Suspension spring damping ratio. */\n public dampingRatio: number;\n /** When `true`, the motor drives the wheel's spin toward {@link motorSpeed}. */\n public enableMotor: boolean;\n /** Target relative angular velocity (rad/s) for the motor. */\n public motorSpeed: number;\n /** Maximum motor torque. */\n public maxMotorTorque: number;\n /** When `true`, the axis translation is constrained to `[lowerTranslation, upperTranslation]`. */\n public enableLimit: boolean;\n /** Lower suspension-travel limit along the axis. */\n public lowerTranslation: number;\n /** Upper suspension-travel limit along the axis. */\n public upperTranslation: number;\n\n private readonly _localAnchorAx: number;\n private readonly _localAnchorAy: number;\n private readonly _localAnchorBx: number;\n private readonly _localAnchorBy: number;\n private readonly _localAxisAx: number;\n private readonly _localAxisAy: number;\n\n private _axisX = 1;\n private _axisY = 0;\n private _perpX = 0;\n private _perpY = 1;\n private _a1 = 0;\n private _a2 = 0;\n private _s1 = 0;\n private _s2 = 0;\n private _perpMass = 0;\n private _axialMass = 0;\n private _angularMass = 0;\n private _springBiasRate = 0;\n private _springMassScale = 1;\n private _springImpulseScale = 0;\n private _cPerp = 0;\n private _translation = 0;\n private _h = 0;\n private _invH = 0;\n private _perpImpulse = 0;\n private _springImpulse = 0;\n private _motorImpulse = 0;\n private _lowerImpulse = 0;\n private _upperImpulse = 0;\n\n public constructor(options: WheelJointOptions) {\n super(options.bodyA, options.bodyB, options.collideConnected);\n\n applyInverseTransform(options.bodyA.transform, options.anchor.x, options.anchor.y, scratch);\n this._localAnchorAx = scratch.x;\n this._localAnchorAy = scratch.y;\n applyInverseTransform(options.bodyB.transform, options.anchor.x, options.anchor.y, scratch);\n this._localAnchorBx = scratch.x;\n this._localAnchorBy = scratch.y;\n\n const axisLength = Math.hypot(options.axis.x, options.axis.y);\n\n if (!Number.isFinite(axisLength) || axisLength === 0) {\n throw new RangeError(`WheelJoint: axis must be a non-zero finite vector, received (${options.axis.x}, ${options.axis.y}).`);\n }\n\n applyInverseRotation(options.bodyA.transform, options.axis.x / axisLength, options.axis.y / axisLength, scratch);\n this._localAxisAx = scratch.x;\n this._localAxisAy = scratch.y;\n\n this.hertz = options.hertz ?? 0;\n this.dampingRatio = options.dampingRatio ?? 1;\n this.enableMotor = options.enableMotor ?? false;\n this.motorSpeed = options.motorSpeed ?? 0;\n this.maxMotorTorque = options.maxMotorTorque ?? 0;\n this.enableLimit = options.enableLimit ?? false;\n this.lowerTranslation = options.lowerTranslation ?? 0;\n this.upperTranslation = options.upperTranslation ?? 0;\n }\n\n /** @internal */\n public override _prepare(h: number, rigid: JointSoftness): void {\n const bodyA = this.bodyA;\n const bodyB = this.bodyB;\n\n this._active = this.enabled && !bodyA.isSleeping && !bodyB.isSleeping && (bodyA.invMass > 0 || bodyB.invMass > 0);\n\n if (!this._active) {\n return;\n }\n\n applyRotation(bodyA.transform, this._localAxisAx, this._localAxisAy, scratch);\n const axisX = scratch.x;\n const axisY = scratch.y;\n const perpX = -axisY;\n const perpY = axisX;\n\n this._axisX = axisX;\n this._axisY = axisY;\n this._perpX = perpX;\n this._perpY = perpY;\n\n applyTransform(bodyA.transform, this._localAnchorAx, this._localAnchorAy, scratch);\n const pAx = scratch.x;\n const pAy = scratch.y;\n applyTransform(bodyB.transform, this._localAnchorBx, this._localAnchorBy, scratch);\n const pBx = scratch.x;\n const pBy = scratch.y;\n\n const rAx = pAx - bodyA.worldCenterOfMassX;\n const rAy = pAy - bodyA.worldCenterOfMassY;\n const rBx = pBx - bodyB.worldCenterOfMassX;\n const rBy = pBy - bodyB.worldCenterOfMassY;\n const dx = pBx - pAx;\n const dy = pBy - pAy;\n\n this._a1 = (dx + rAx) * axisY - (dy + rAy) * axisX;\n this._a2 = rBx * axisY - rBy * axisX;\n this._s1 = (dx + rAx) * perpY - (dy + rAy) * perpX;\n this._s2 = rBx * perpY - rBy * perpX;\n\n const mA = bodyA.invMass;\n const mB = bodyB.invMass;\n const iA = bodyA.invInertia;\n const iB = bodyB.invInertia;\n\n const kPerp = mA + mB + iA * this._s1 * this._s1 + iB * this._s2 * this._s2;\n this._perpMass = kPerp > 0 ? 1 / kPerp : 0;\n const kAxial = mA + mB + iA * this._a1 * this._a1 + iB * this._a2 * this._a2;\n this._axialMass = kAxial > 0 ? 1 / kAxial : 0;\n this._angularMass = iA + iB > 0 ? 1 / (iA + iB) : 0;\n\n this._cPerp = dx * perpX + dy * perpY;\n this._translation = dx * axisX + dy * axisY;\n this._h = h;\n this._invH = 1 / h;\n\n if (this.hertz > 0) {\n const omega = 2 * Math.PI * this.hertz;\n const a1 = 2 * this.dampingRatio + h * omega;\n const a2 = h * omega * a1;\n const a3 = 1 / (1 + a2);\n\n this._springBiasRate = omega / a1;\n this._springMassScale = a2 * a3;\n this._springImpulseScale = a3;\n } else {\n // The solver's own softness rather than a raw Baumgarte term; see\n // `softConstraint`. An unscaled bias relaxes no impulse, which a chain of\n // these constraints turns into energy.\n this._springBiasRate = rigid.biasRate;\n this._springMassScale = rigid.massScale;\n this._springImpulseScale = rigid.impulseScale;\n }\n\n if (!this.enableMotor) {\n this._motorImpulse = 0;\n }\n\n if (!this.enableLimit) {\n this._lowerImpulse = 0;\n this._upperImpulse = 0;\n }\n }\n\n /** @internal */\n public override _warmStart(): void {\n if (!this._active) {\n return;\n }\n\n const bodyA = this.bodyA;\n const bodyB = this.bodyB;\n\n // Rotation motor (angular).\n bodyA.angularVelocity -= bodyA.invInertia * this._motorImpulse;\n bodyB.angularVelocity += bodyB.invInertia * this._motorImpulse;\n\n this._applyAxial(this._springImpulse + this._lowerImpulse - this._upperImpulse);\n this._applyPerp(this._perpImpulse);\n }\n\n /** @internal */\n public override _solve(useBias: boolean): void {\n if (!this._active) {\n return;\n }\n\n const bodyA = this.bodyA;\n const bodyB = this.bodyB;\n\n // Rotation motor - drives the wheel's spin; rotation is otherwise free.\n if (this.enableMotor) {\n const cdot = bodyB.angularVelocity - bodyA.angularVelocity - this.motorSpeed;\n const max = this.maxMotorTorque * this._h;\n const old = this._motorImpulse;\n\n this._motorImpulse = Math.min(max, Math.max(-max, old - this._angularMass * cdot));\n\n const applied = this._motorImpulse - old;\n bodyA.angularVelocity -= bodyA.invInertia * applied;\n bodyB.angularVelocity += bodyB.invInertia * applied;\n }\n\n // Suspension spring along the axis (soft).\n const cdotAxis = this._axisVelocity();\n const springImpulse =\n -this._axialMass * this._springMassScale * (cdotAxis + this._springBiasRate * this._translation) - this._springImpulseScale * this._springImpulse;\n\n this._springImpulse += springImpulse;\n this._applyAxial(springImpulse);\n\n // Suspension-travel limits along the axis.\n if (this.enableLimit) {\n // Lower limit (translation ≥ lowerTranslation): positive impulse pushes along +axis.\n const cLower = this._translation - this.lowerTranslation;\n let biasLower = 0;\n\n if (cLower > 0) {\n biasLower = cLower * this._invH;\n } else if (useBias) {\n biasLower = 0.2 * this._invH * cLower;\n }\n\n const oldLower = this._lowerImpulse;\n this._lowerImpulse = Math.max(0, oldLower - this._axialMass * (this._axisVelocity() + biasLower));\n this._applyAxial(this._lowerImpulse - oldLower);\n\n // Upper limit (translation ≤ upperTranslation): impulse pushes along −axis.\n const cUpper = this.upperTranslation - this._translation;\n let biasUpper = 0;\n\n if (cUpper > 0) {\n biasUpper = cUpper * this._invH;\n } else if (useBias) {\n biasUpper = 0.2 * this._invH * cUpper;\n }\n\n const oldUpper = this._upperImpulse;\n this._upperImpulse = Math.max(0, oldUpper - this._axialMass * (-this._axisVelocity() + biasUpper));\n this._applyAxial(-(this._upperImpulse - oldUpper));\n }\n\n // Lateral lock (perpendicular, rigid).\n const cdotPerp = this._perpVelocity();\n const perpImpulse = -this._perpMass * (cdotPerp + (useBias ? 0.2 * this._invH * this._cPerp : 0));\n\n this._perpImpulse += perpImpulse;\n this._applyPerp(perpImpulse);\n }\n\n private _axisVelocity(): number {\n const bodyA = this.bodyA;\n const bodyB = this.bodyB;\n\n return (\n this._axisX * (bodyB.linearVelocityX - bodyA.linearVelocityX) +\n this._axisY * (bodyB.linearVelocityY - bodyA.linearVelocityY) +\n this._a2 * bodyB.angularVelocity -\n this._a1 * bodyA.angularVelocity\n );\n }\n\n private _perpVelocity(): number {\n const bodyA = this.bodyA;\n const bodyB = this.bodyB;\n\n return (\n this._perpX * (bodyB.linearVelocityX - bodyA.linearVelocityX) +\n this._perpY * (bodyB.linearVelocityY - bodyA.linearVelocityY) +\n this._s2 * bodyB.angularVelocity -\n this._s1 * bodyA.angularVelocity\n );\n }\n\n private _applyAxial(impulse: number): void {\n const bodyA = this.bodyA;\n const bodyB = this.bodyB;\n const px = impulse * this._axisX;\n const py = impulse * this._axisY;\n\n bodyA.linearVelocityX -= bodyA.invMass * px;\n bodyA.linearVelocityY -= bodyA.invMass * py;\n bodyA.angularVelocity -= bodyA.invInertia * impulse * this._a1;\n bodyB.linearVelocityX += bodyB.invMass * px;\n bodyB.linearVelocityY += bodyB.invMass * py;\n bodyB.angularVelocity += bodyB.invInertia * impulse * this._a2;\n }\n\n private _applyPerp(impulse: number): void {\n const bodyA = this.bodyA;\n const bodyB = this.bodyB;\n const px = impulse * this._perpX;\n const py = impulse * this._perpY;\n\n bodyA.linearVelocityX -= bodyA.invMass * px;\n bodyA.linearVelocityY -= bodyA.invMass * py;\n bodyA.angularVelocity -= bodyA.invInertia * impulse * this._s1;\n bodyB.linearVelocityX += bodyB.invMass * px;\n bodyB.linearVelocityY += bodyB.invMass * py;\n bodyB.angularVelocity += bodyB.invInertia * impulse * this._s2;\n }\n}\n"],"mappings":";;;;;AAoCA,MAAM,UAAqB;CAAE,GAAG;CAAG,GAAG;AAAE;;;;;;;;AASxC,IAAa,aAAb,cAAgC,MAAM;;CAEpC,AAAO;;CAEP,AAAO;;CAEP,AAAO;;CAEP,AAAO;;CAEP,AAAO;;CAEP,AAAO;;CAEP,AAAO;;CAEP,AAAO;CAEP,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CAEjB,AAAQ,SAAS;CACjB,AAAQ,SAAS;CACjB,AAAQ,SAAS;CACjB,AAAQ,SAAS;CACjB,AAAQ,MAAM;CACd,AAAQ,MAAM;CACd,AAAQ,MAAM;CACd,AAAQ,MAAM;CACd,AAAQ,YA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 @@
1
1
  //#region src/physicsBuildInfo.ts
2
2
  const physicsBuildInfo = Object.freeze({
3
- version: "0.16.2",
4
- revision: "59afd58",
3
+ version: "0.18.0",
4
+ revision: "5681ab4",
5
5
  development: false
6
6
  });
7
7
 
@@ -4,7 +4,7 @@ export { Collider } from './Collider';
4
4
  export type { ContactModifier, ContactModifierContext } from './ContactModifier';
5
5
  export type { CollisionEvent, ContactPoint, SensorEvent } from './events';
6
6
  export { DistanceJoint, type DistanceJointOptions } from './joints/DistanceJoint';
7
- export { Joint } from './joints/Joint';
7
+ export { Joint, type JointOptions } from './joints/Joint';
8
8
  export { MouseJoint, type MouseJointOptions } from './joints/MouseJoint';
9
9
  export { PrismaticJoint, type PrismaticJointOptions } from './joints/PrismaticJoint';
10
10
  export { RevoluteJoint, type RevoluteJointOptions } from './joints/RevoluteJoint';
@@ -1 +1 @@
1
- {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/public.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AACjF,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAClF,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAClF,O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D,YAAY,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,YAAY,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}
@@ -1,30 +1,2 @@
1
- import type { ChainShape } from './ChainShape';
2
- import { SegmentShape } from './SegmentShape';
3
- /**
4
- * One edge of a {@link ChainShape}, the geometry the solver actually sees. Built
5
- * and owned by the engine when a chain collider is created; never authored, and
6
- * never part of the public collider set.
7
- *
8
- * It is a segment plus the adjacency of the chain it came from. The adjacency is
9
- * stored as the rotation from this edge's outward normal to a neighbour's, which
10
- * is invariant under the collider's world transform - so the narrow phase can
11
- * compare a world-space contact normal against the neighbouring edges without
12
- * knowing the transform and without caching a second set of world normals.
13
- *
14
- * @internal
15
- */
16
- export declare class ChainEdgeShape extends SegmentShape {
17
- /** Index of this edge within the owning chain. */
18
- readonly index: number;
19
- /** `false` at the free end of an open chain, where a body may pass around the edge. */
20
- readonly hasPrevious: boolean;
21
- readonly hasNext: boolean;
22
- /** Rotation (cos, sin) taking this edge's outward normal onto the previous edge's. */
23
- readonly previousCos: number;
24
- readonly previousSin: number;
25
- /** Rotation (cos, sin) taking this edge's outward normal onto the next edge's. */
26
- readonly nextCos: number;
27
- readonly nextSin: number;
28
- constructor(chain: ChainShape, index: number);
29
- }
1
+ export {};
30
2
  //# sourceMappingURL=ChainEdgeShape.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ChainEdgeShape.d.ts","sourceRoot":"","sources":["../../../src/shapes/ChainEdgeShape.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;;;;;;;;;;GAYG;AACH,qBAAa,cAAe,SAAQ,YAAY;IAC9C,kDAAkD;IAClD,SAAgB,KAAK,EAAE,MAAM,CAAC;IAE9B,uFAAuF;IACvF,SAAgB,WAAW,EAAE,OAAO,CAAC;IACrC,SAAgB,OAAO,EAAE,OAAO,CAAC;IAEjC,sFAAsF;IACtF,SAAgB,WAAW,EAAE,MAAM,CAAC;IACpC,SAAgB,WAAW,EAAE,MAAM,CAAC;IAEpC,kFAAkF;IAClF,SAAgB,OAAO,EAAE,MAAM,CAAC;IAChC,SAAgB,OAAO,EAAE,MAAM,CAAC;gBAEb,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM;CA2BpD"}
1
+ {"version":3,"file":"ChainEdgeShape.d.ts","sourceRoot":"","sources":["../../../src/shapes/ChainEdgeShape.ts"],"names":[],"mappings":""}
@@ -1,5 +1,4 @@
1
1
  import type { PointLike } from '@codexo/exojs';
2
- import { ChainEdgeShape } from './ChainEdgeShape';
3
2
  import { Shape } from './Shape';
4
3
  /** Construction options for a {@link ChainShape}. */
5
4
  export interface ChainShapeOptions {
@@ -42,11 +41,6 @@ export declare class ChainShape extends Shape {
42
41
  readonly boundingRadius: number;
43
42
  /** Always `null`: a boundary has no interior and therefore no mass. */
44
43
  readonly massProperties: null;
45
- /**
46
- * @internal - the per-edge geometry the solver works on, built once with the
47
- * chain. Immutable and shared by every collider carrying this shape.
48
- */
49
- readonly edges: readonly ChainEdgeShape[];
50
44
  constructor(vertices: ReadonlyArray<Readonly<PointLike>>, options?: ChainShapeOptions);
51
45
  }
52
46
  //# sourceMappingURL=ChainShape.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ChainShape.d.ts","sourceRoot":"","sources":["../../../src/shapes/ChainShape.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAKhC,qDAAqD;AACrD,MAAM,WAAW,iBAAiB;IAChC,gFAAgF;IAChF,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACnC,SAAgB,IAAI,EAAG,OAAO,CAAU;IAExC,uEAAuE;IACvE,SAAgB,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IAE5C,8CAA8C;IAC9C,SAAgB,KAAK,EAAE,MAAM,CAAC;IAE9B,2EAA2E;IAC3E,SAAgB,SAAS,EAAE,MAAM,CAAC;IAElC,SAAgB,MAAM,EAAE,OAAO,CAAC;IAChC,SAAgB,cAAc,EAAE,MAAM,CAAC;IAEvC,uEAAuE;IACvE,SAAgB,cAAc,OAAQ;IAEtC;;;OAGG;IACH,SAAgB,KAAK,EAAE,SAAS,cAAc,EAAE,CAAC;gBAE9B,QAAQ,EAAE,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,OAAO,GAAE,iBAAsB;CA+DjG"}
1
+ {"version":3,"file":"ChainShape.d.ts","sourceRoot":"","sources":["../../../src/shapes/ChainShape.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG/C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAKhC,qDAAqD;AACrD,MAAM,WAAW,iBAAiB;IAChC,gFAAgF;IAChF,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACnC,SAAgB,IAAI,EAAG,OAAO,CAAU;IAExC,uEAAuE;IACvE,SAAgB,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IAE5C,8CAA8C;IAC9C,SAAgB,KAAK,EAAE,MAAM,CAAC;IAE9B,2EAA2E;IAC3E,SAAgB,SAAS,EAAE,MAAM,CAAC;IAElC,SAAgB,MAAM,EAAE,OAAO,CAAC;IAChC,SAAgB,cAAc,EAAE,MAAM,CAAC;IAEvC,uEAAuE;IACvE,SAAgB,cAAc,OAAQ;gBAQnB,QAAQ,EAAE,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,OAAO,GAAE,iBAAsB;CA+DjG"}
@@ -1,24 +1,2 @@
1
- import type { PointLike } from '@codexo/exojs';
2
- /**
3
- * Split a simple polygon into convex parts.
4
- *
5
- * The input may be concave, wound either way, and may carry duplicate or
6
- * collinear vertices; it must not intersect itself. The result is a list of
7
- * strictly convex, counter-clockwise parts whose union is the input and whose
8
- * interiors do not overlap. An already-convex input yields exactly one part.
9
- *
10
- * Deterministic: the same cleaned input always produces the same parts. The
11
- * number of parts and their order are an artefact of the current algorithm and
12
- * must not be relied on - assert convexity, preserved area and preserved mass
13
- * properties instead.
14
- *
15
- * Cost is O(n²) in the vertex count (self-intersection check and ear clipping),
16
- * which suits import-time geometry rather than a per-step path.
17
- *
18
- * @throws RangeError if a coordinate is not finite, if fewer than three
19
- * distinct non-collinear vertices remain after cleanup, or if the outline
20
- * intersects itself.
21
- * @internal
22
- */
23
- export declare const decomposeToConvexParts: (vertices: ReadonlyArray<Readonly<PointLike>>) => PointLike[][];
1
+ export {};
24
2
  //# sourceMappingURL=decompose.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"decompose.d.ts","sourceRoot":"","sources":["../../../src/shapes/decompose.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAmB/C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,sBAAsB,GAAI,UAAU,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,KAAG,SAAS,EAAE,EAqChG,CAAC"}
1
+ {"version":3,"file":"decompose.d.ts","sourceRoot":"","sources":["../../../src/shapes/decompose.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"ContactSolver.d.ts","sourceRoot":"","sources":["../../../src/solver/ContactSolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAgFrD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA2B;IACxD,OAAO,CAAC,MAAM,CAAK;IAEnB;;;;;OAKG;IACI,OAAO,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI;IAkI/G,gGAAgG;IACzF,SAAS,IAAI,IAAI;IAmBxB;;;;;;OAMG;IACI,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAM9C;;;;;;OAMG;IACI,gBAAgB,IAAI,IAAI;IAuC/B,8FAA8F;IAC9F,OAAO,CAAC,WAAW;IAmBnB,OAAO,CAAC,qBAAqB;IA4B7B,wGAAwG;IACxG,OAAO,CAAC,cAAc;IAsBtB;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,sBAAsB;IA8B9B;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB;IAiEzB,OAAO,CAAC,QAAQ;IAQhB;;;;;OAKG;IACH,OAAO,CAAC,GAAG;CASZ"}
1
+ {"version":3,"file":"ContactSolver.d.ts","sourceRoot":"","sources":["../../../src/solver/ContactSolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AA6FrD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA2B;IACxD,OAAO,CAAC,MAAM,CAAK;IAEnB;;;;;OAKG;IACI,OAAO,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI;IAkI/G,gGAAgG;IACzF,SAAS,IAAI,IAAI;IAmBxB;;;;;;OAMG;IACI,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAM9C;;;;;;OAMG;IACI,gBAAgB,IAAI,IAAI;IAuC/B,8FAA8F;IAC9F,OAAO,CAAC,WAAW;IAmBnB,OAAO,CAAC,qBAAqB;IA4B7B,wGAAwG;IACxG,OAAO,CAAC,cAAc;IAsBtB;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,sBAAsB;IA8B9B;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB;IAiEzB,OAAO,CAAC,QAAQ;IAQhB;;;;;OAKG;IACH,OAAO,CAAC,GAAG;CASZ"}
@@ -3,10 +3,23 @@ import { contactSlop } from "./tolerances.js";
3
3
  //#region src/solver/ContactSolver.ts
4
4
  /**
5
5
  * Cap on the soft-constraint push-out velocity (px/s). Bounds how fast the bias
6
- * resolves deep penetration so a large overlap cannot fling bodies apart; the
7
- * Box2D-v3 analogue is `contactSpeed = 3·lengthUnit`, retuned for ExoJS pixels.
6
+ * resolves deep penetration so a large overlap cannot fling bodies apart.
7
+ *
8
+ * The Box2D-v3 analogue is `contactSpeed = 3·lengthUnit`, i.e. 3 m/s in SI. The
9
+ * conversion to pixels is the whole content of this constant: 2D games in this
10
+ * engine's envelope put a metre at roughly 20-100 px (equivalently, the gravity
11
+ * range the solver is tuned for, a few hundred to a few thousand px/s²), so the
12
+ * same physical speed is 60-300 px/s. The low end of that band is taken - it is
13
+ * already past the point where a settling scene stops fighting the cap, and
14
+ * anything higher only widens the speed at which a deep overlap may be undone.
15
+ *
16
+ * A single-digit cap is enough for one body resting on a floor and badly short
17
+ * everywhere else: a gravity-driven pile rearranges faster than such a push-out
18
+ * can work, so overlap accumulates instead of resolving, the pile settles
19
+ * several px deep with far more touching pairs than its geometry has, and the
20
+ * permanently unresolved contacts keep every island awake.
8
21
  */
9
- const maxBiasVelocity = 4;
22
+ const maxBiasVelocity = 60;
10
23
  /** Reject the 2-point block solve when the contact matrix is worse-conditioned than this (fall back to sequential). */
11
24
  const maxConditionNumber = 1e3;
12
25
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ContactSolver.js","names":[],"sources":["../../../src/solver/ContactSolver.ts"],"sourcesContent":["import type { ContactRecord } from '../ContactGraph';\nimport type { PhysicsBody } from '../PhysicsBody';\nimport { contactSlop } from './tolerances';\n\n/** Relative normal speed (px/s) below which a contact is treated as resting (no restitution). */\nconst restitutionThreshold = 1;\n/**\n * Cap on the soft-constraint push-out velocity (px/s). Bounds how fast the bias\n * resolves deep penetration so a large overlap cannot fling bodies apart; the\n * Box2D-v3 analogue is `contactSpeed = 3·lengthUnit`, retuned for ExoJS pixels.\n */\nconst maxBiasVelocity = 4;\n/** Reject the 2-point block solve when the contact matrix is worse-conditioned than this (fall back to sequential). */\nconst maxConditionNumber = 1000;\n\n/**\n * Per-contact velocity constraint (1-2 points), computed once per **frame** in\n * {@link ContactSolver.prepare} and reused across all sub-steps and passes.\n * Pooled and reused across frames, so a steady-state step constructs no\n * constraint of its own. It is not allocation-free in the wider sense: a double\n * handed to a function the optimiser declines to inline is boxed on the heap for\n * the duration of that call, which is why the hot paths below apply their\n * results in place instead of through helpers.\n */\nclass ContactConstraint {\n public record!: ContactRecord;\n public bodyA!: PhysicsBody;\n public bodyB!: PhysicsBody;\n public nx = 0;\n public ny = 0;\n public tx = 0;\n public ty = 0;\n public friction = 0;\n public restitution = 0;\n public pointCount = 0;\n\n // Soft-constraint factors (Box2D-v3 \"soft step\"), derived once per frame from\n // contactHertz/dampingRatio and the sub-step `h`. Shared by both points.\n public biasRate = 0;\n public massScale = 1;\n public impulseScale = 0;\n\n // Per-point contact arms at frame start (relative to each body's centre of mass).\n public readonly rAx = [0, 0];\n public readonly rAy = [0, 0];\n public readonly rBx = [0, 0];\n public readonly rBy = [0, 0];\n // Per-point arms rotated by the live sub-step rotation (refreshed each pass by\n // {@link ContactSolver._updateArms}); the solve reads these so a rotating body's\n // contact torque tracks its current orientation.\n public readonly rotAx = [0, 0];\n public readonly rotAy = [0, 0];\n public readonly rotBx = [0, 0];\n public readonly rotBy = [0, 0];\n public readonly normalMass = [0, 0];\n public readonly tangentMass = [0, 0];\n /** Contact separation at frame start (= −penetration; negative when overlapping). */\n public readonly baseSeparation = [0, 0];\n /** Relative normal velocity at frame start (the impact speed the restitution pass keys off). */\n public readonly relativeVelocity = [0, 0];\n /** Push-out target normal velocity for the current pass (set per pass from the live separation). */\n public readonly velocityBias = [0, 0];\n /**\n * Whether the point's push-out target was clamped to `maxBiasVelocity` this\n * pass. A clamped target is no longer the spring response the soft scaling\n * models, so the single-point solve drops that scaling while it holds.\n */\n public readonly biasClamped = [false, false];\n\n // 2-point block: the contact matrix `K` and its inverse (set only when the\n // manifold has two points and `K` is well-conditioned; else sequential).\n public block = false;\n public k11 = 0;\n public k12 = 0;\n public k22 = 0;\n public invK11 = 0;\n public invK12 = 0;\n public invK22 = 0;\n}\n\n/**\n * Native warm-started **TGS-Soft** contact solver (Box2D-v3 \"soft step\"). Driven\n * by {@link PhysicsWorld} as a sub-stepping loop: detection runs once per frame,\n * then {@link prepare} builds the per-contact constraints (effective masses,\n * frame-start separation + impact velocity, soft factors, and a 2×2 block matrix\n * for two-point manifolds) **once**, and each sub-step runs\n * {@link warmStart} → {@link solveVelocities}(useBias=true) → integrate positions\n * → {@link solveVelocities}(useBias=false) relax. A final {@link applyRestitution}\n * pass adds bounce above the threshold.\n *\n * The position constraint is folded into the velocity solve as a **soft bias**\n * (a damped-spring push-out whose stiffness is decoupled from the iteration\n * count), recomputed each pass from the live per-body delta position/rotation -\n * so there is no separate NGS geometric pass. The contact anchors are rotated by\n * the live sub-step rotation each pass, so a tilting stack's restoring torque is\n * computed against its current orientation (without this the tilt grows instead\n * of being corrected). Two-point manifolds still solve the normal impulses **as a\n * 2×2 block LCP** (Box2D-style), which propagates stack loads far better than\n * solving the points sequentially; the block path carries the soft push-out as\n * its velocity target (hard mass scale), while single-point contacts use the full\n * soft mass/impulse scaling for as long as their push-out target stays inside\n * the cap, and the hard scale once it is clamped. Accumulated impulses are\n * written back to each {@link ContactRecord} for warm-starting the next frame.\n *\n * Internal to {@link NativePhysicsBackend}; not part of the public surface.\n */\nexport class ContactSolver {\n private readonly _constraints: ContactConstraint[] = [];\n private _count = 0;\n\n /**\n * Build the per-contact constraints for this frame from the touching solid\n * contacts. `h` is the sub-step duration (`fixedDelta / subStepCount`); the\n * soft factors are derived from it together with `contactHertz`/`dampingRatio`.\n * Runs once per frame (detection is not repeated per sub-step).\n */\n public prepare(contacts: readonly ContactRecord[], h: number, contactHertz: number, dampingRatio: number): void {\n this._count = 0;\n\n // Box2D-v3 soft-constraint factors from a damped spring (hertz, zeta) at the\n // sub-step `h`: omega = 2πf; a1 = 2ζ + hω; a2 = hω·a1; a3 = 1/(1+a2).\n const omega = 2 * Math.PI * contactHertz;\n const a1 = 2 * dampingRatio + h * omega;\n const a2 = h * omega * a1;\n const a3 = 1 / (1 + a2);\n const biasRate = contactHertz > 0 ? omega / a1 : 0;\n const massScale = contactHertz > 0 ? a2 * a3 : 1;\n const impulseScale = contactHertz > 0 ? a3 : 0;\n\n for (const contact of contacts) {\n const manifold = contact.manifold;\n const pointCount = manifold.pointCount;\n\n // A contact the world's `ContactModifier` disabled for this step stays\n // touching geometrically but applies no impulse.\n if (pointCount === 0 || !contact.enabled) {\n continue;\n }\n\n const bodyA = contact.a.body;\n const bodyB = contact.b.body;\n\n // Skip contacts where either body is asleep: a sleeping island's solid\n // contacts are all sleeping↔sleeping or sleeping↔static (both at rest), so\n // there is nothing to solve. A sleeping body touched by an awake one is\n // woken (island merge) before this runs, so it is never skipped wrongly.\n if (bodyA.isSleeping || bodyB.isSleeping) {\n continue;\n }\n\n const constraint = this._acquire();\n const nx = manifold.normalX;\n const ny = manifold.normalY;\n const tx = -ny;\n const ty = nx;\n\n constraint.record = contact;\n constraint.bodyA = bodyA;\n constraint.bodyB = bodyB;\n constraint.nx = nx;\n constraint.ny = ny;\n constraint.tx = tx;\n constraint.ty = ty;\n // Per-step values: derived from the two colliders each pass, then possibly\n // overridden by the world's `ContactModifier`.\n constraint.friction = contact.friction;\n constraint.restitution = contact.restitution;\n constraint.pointCount = pointCount;\n constraint.block = false;\n constraint.biasRate = biasRate;\n constraint.massScale = massScale;\n constraint.impulseScale = impulseScale;\n\n const mA = bodyA.invMass;\n const mB = bodyB.invMass;\n const iA = bodyA.invInertia;\n const iB = bodyB.invInertia;\n const comAx = bodyA.worldCenterOfMassX;\n const comAy = bodyA.worldCenterOfMassY;\n const comBx = bodyB.worldCenterOfMassX;\n const comBy = bodyB.worldCenterOfMassY;\n\n for (let i = 0; i < pointCount; i++) {\n // i in 0..pointCount-1 and pointCount ≤ 2, so the manifold point exists.\n const point = i === 0 ? manifold.points[0] : manifold.points[1];\n const rAx = point.x - comAx;\n const rAy = point.y - comAy;\n const rBx = point.x - comBx;\n const rBy = point.y - comBy;\n\n constraint.rAx[i] = rAx;\n constraint.rAy[i] = rAy;\n constraint.rBx[i] = rBx;\n constraint.rBy[i] = rBy;\n // Frame start: no accumulated rotation yet, so the live arms equal the base arms.\n constraint.rotAx[i] = rAx;\n constraint.rotAy[i] = rAy;\n constraint.rotBx[i] = rBx;\n constraint.rotBy[i] = rBy;\n\n const rnA = rAx * ny - rAy * nx;\n const rnB = rBx * ny - rBy * nx;\n const kn = mA + mB + iA * rnA * rnA + iB * rnB * rnB;\n const rtA = rAx * ty - rAy * tx;\n const rtB = rBx * ty - rBy * tx;\n const kt = mA + mB + iA * rtA * rtA + iB * rtB * rtB;\n\n constraint.normalMass[i] = kn > 0 ? 1 / kn : 0;\n constraint.tangentMass[i] = kt > 0 ? 1 / kt : 0;\n constraint.baseSeparation[i] = -point.penetration;\n constraint.velocityBias[i] = 0;\n\n // Frame-start relative normal velocity (the true impact speed, captured\n // before this frame's gravity since prepare runs ahead of the sub-step\n // loop) - keys the restitution pass so a resting contact does not\n // perpetually micro-bounce off the per-step gravity increment.\n constraint.relativeVelocity[i] = normalVelocity(bodyA, bodyB, rAx, rAy, rBx, rBy, nx, ny);\n }\n\n if (pointCount === 2) {\n const rn1A = n(constraint.rAx, 0) * ny - n(constraint.rAy, 0) * nx;\n const rn1B = n(constraint.rBx, 0) * ny - n(constraint.rBy, 0) * nx;\n const rn2A = n(constraint.rAx, 1) * ny - n(constraint.rAy, 1) * nx;\n const rn2B = n(constraint.rBx, 1) * ny - n(constraint.rBy, 1) * nx;\n const k11 = mA + mB + iA * rn1A * rn1A + iB * rn1B * rn1B;\n const k22 = mA + mB + iA * rn2A * rn2A + iB * rn2B * rn2B;\n const k12 = mA + mB + iA * rn1A * rn2A + iB * rn1B * rn2B;\n const det = k11 * k22 - k12 * k12;\n\n // Only block-solve when `K` is well-conditioned (parallel-ish contacts\n // produce a near-singular matrix → fall back to sequential).\n if (det > 0 && k11 * k11 < maxConditionNumber * det) {\n const invDet = 1 / det;\n\n constraint.k11 = k11;\n constraint.k12 = k12;\n constraint.k22 = k22;\n constraint.invK11 = invDet * k22;\n constraint.invK12 = -invDet * k12;\n constraint.invK22 = invDet * k11;\n constraint.block = true;\n }\n }\n }\n }\n\n /** Re-apply the cached impulses from the previous frame (warm-starting); runs each sub-step. */\n public warmStart(): void {\n for (let ci = 0; ci < this._count; ci++) {\n const constraint = this._at(ci);\n const bodyA = constraint.bodyA;\n const bodyB = constraint.bodyB;\n\n this._updateArms(constraint);\n\n for (let i = 0; i < constraint.pointCount; i++) {\n const normalImpulse = n(constraint.record.normalImpulse, i);\n const tangentImpulse = n(constraint.record.tangentImpulse, i);\n const jx = normalImpulse * constraint.nx + tangentImpulse * constraint.tx;\n const jy = normalImpulse * constraint.ny + tangentImpulse * constraint.ty;\n\n applyImpulse(bodyA, bodyB, n(constraint.rotAx, i), n(constraint.rotAy, i), n(constraint.rotBx, i), n(constraint.rotBy, i), jx, jy);\n }\n }\n }\n\n /**\n * One velocity pass over every contact: the normal constraint (block when\n * possible) then friction (Coulomb cone). With `useBias` the normal solve\n * carries the soft push-out bias (the main pass, recomputed from the live\n * separation); without it the relax pass drives the normal velocity to zero so\n * the bias velocity does not remain in the bodies as injected energy.\n */\n public solveVelocities(useBias: boolean): void {\n for (let ci = 0; ci < this._count; ci++) {\n this._solveVelocityContact(this._at(ci), useBias);\n }\n }\n\n /**\n * Restitution pass, run once after the sub-step loop. For each loaded point\n * whose frame-start impact speed exceeded the threshold, add the impulse that\n * brings the post-solve normal velocity to `−restitution·impactSpeed`. Kept\n * separate from the main solve so resting contacts (impact below threshold) do\n * not micro-bounce.\n */\n public applyRestitution(): void {\n for (let ci = 0; ci < this._count; ci++) {\n const constraint = this._at(ci);\n\n if (constraint.restitution === 0) {\n continue;\n }\n\n const bodyA = constraint.bodyA;\n const bodyB = constraint.bodyB;\n const nx = constraint.nx;\n const ny = constraint.ny;\n\n this._updateArms(constraint);\n\n for (let i = 0; i < constraint.pointCount; i++) {\n const relativeVelocity = n(constraint.relativeVelocity, i);\n\n // Only points that carried load (normalImpulse > 0) and were struck\n // above the resting threshold bounce.\n if (relativeVelocity > -restitutionThreshold || n(constraint.record.normalImpulse, i) <= 0) {\n continue;\n }\n\n const rAx = n(constraint.rotAx, i);\n const rAy = n(constraint.rotAy, i);\n const rBx = n(constraint.rotBx, i);\n const rBy = n(constraint.rotBy, i);\n const vn = normalVelocity(bodyA, bodyB, rAx, rAy, rBx, rBy, nx, ny);\n const oldNormal = n(constraint.record.normalImpulse, i);\n const newNormal = Math.max(0, oldNormal - n(constraint.normalMass, i) * (vn + constraint.restitution * relativeVelocity));\n const deltaNormal = newNormal - oldNormal;\n\n constraint.record.normalImpulse[i] = newNormal;\n applyImpulse(bodyA, bodyB, rAx, rAy, rBx, rBy, deltaNormal * nx, deltaNormal * ny);\n }\n }\n }\n\n /** Refresh the live (rotated) contact arms from each body's accumulated sub-step rotation. */\n private _updateArms(constraint: ContactConstraint): void {\n const cosA = constraint.bodyA._deltaCos;\n const sinA = constraint.bodyA._deltaSin;\n const cosB = constraint.bodyB._deltaCos;\n const sinB = constraint.bodyB._deltaSin;\n\n for (let i = 0; i < constraint.pointCount; i++) {\n const rAx = n(constraint.rAx, i);\n const rAy = n(constraint.rAy, i);\n const rBx = n(constraint.rBx, i);\n const rBy = n(constraint.rBy, i);\n\n constraint.rotAx[i] = rAx * cosA - rAy * sinA;\n constraint.rotAy[i] = rAx * sinA + rAy * cosA;\n constraint.rotBx[i] = rBx * cosB - rBy * sinB;\n constraint.rotBy[i] = rBx * sinB + rBy * cosB;\n }\n }\n\n private _solveVelocityContact(constraint: ContactConstraint, useBias: boolean): void {\n this._updateArms(constraint);\n\n // Recompute the per-point push-out target from the live separation (folds the\n // position constraint into the velocity solve as a soft bias). With useBias\n // off (relax pass) the target is zero - the plain hard normal solve.\n for (let i = 0; i < constraint.pointCount; i++) {\n // Push out only the penetration beyond the slop, capped - leaving the slop\n // keeps the contact overlapping so the narrow phase does not drop it.\n const excess = -currentSeparation(constraint, i) - contactSlop;\n const target = useBias && excess > 0 ? constraint.biasRate * excess : 0;\n\n constraint.velocityBias[i] = Math.min(target, maxBiasVelocity);\n constraint.biasClamped[i] = target > maxBiasVelocity;\n }\n\n // Normal before friction (Box2D-v3 order): friction's Coulomb cone clamps to\n // `μ·normalImpulse`, so it must see this pass's freshly-solved normal impulse -\n // solving friction first uses last pass's cone and lets stacks creep laterally.\n if (constraint.block) {\n this._solveNormalBlock(constraint);\n } else {\n this._solveNormalSequential(constraint, useBias);\n }\n\n this._solveFriction(constraint);\n }\n\n /** Per-point friction: clamp the accumulated tangent impulse to the Coulomb cone `±μ·normalImpulse`. */\n private _solveFriction(constraint: ContactConstraint): void {\n const bodyA = constraint.bodyA;\n const bodyB = constraint.bodyB;\n\n for (let i = 0; i < constraint.pointCount; i++) {\n const rAx = n(constraint.rotAx, i);\n const rAy = n(constraint.rotAy, i);\n const rBx = n(constraint.rotBx, i);\n const rBy = n(constraint.rotBy, i);\n const vtX = bodyB.linearVelocityX - bodyB.angularVelocity * rBy - (bodyA.linearVelocityX - bodyA.angularVelocity * rAy);\n const vtY = bodyB.linearVelocityY + bodyB.angularVelocity * rBx - (bodyA.linearVelocityY + bodyA.angularVelocity * rAx);\n const vt = vtX * constraint.tx + vtY * constraint.ty;\n const maxFriction = constraint.friction * n(constraint.record.normalImpulse, i);\n const oldTangent = n(constraint.record.tangentImpulse, i);\n const newTangent = clamp(oldTangent - n(constraint.tangentMass, i) * vt, -maxFriction, maxFriction);\n const deltaTangent = newTangent - oldTangent;\n\n constraint.record.tangentImpulse[i] = newTangent;\n applyImpulse(bodyA, bodyB, rAx, rAy, rBx, rBy, deltaTangent * constraint.tx, deltaTangent * constraint.ty);\n }\n }\n\n /**\n * Single-point (or ill-conditioned) soft normal solve, accumulated and clamped\n * ≥ 0. The Box2D-v3 incremental form: with the soft bias active the impulse is\n * `−normalMass·massScale·(vn − bias) − impulseScale·accumulated`, which both\n * pushes out the penetration and bleeds a little stored impulse (the damped\n * spring). The relax pass passes `useBias=false`, collapsing it to the hard\n * `−normalMass·vn` (no bias, full mass, no impulse decay).\n *\n * A point whose push-out target was clamped to `maxBiasVelocity` is solved\n * with the hard scale as well: the soft scaling models a spring, and once the\n * target is capped the point would otherwise reach only a fraction of an\n * already limited push-out. That deficit grows with the load, so past the\n * acceleration at which the cap binds the contact would sink without bound\n * instead of settling into a slightly deeper limit cycle.\n */\n private _solveNormalSequential(constraint: ContactConstraint, useBias: boolean): void {\n const bodyA = constraint.bodyA;\n const bodyB = constraint.bodyB;\n const nx = constraint.nx;\n const ny = constraint.ny;\n\n for (let i = 0; i < constraint.pointCount; i++) {\n const rAx = n(constraint.rotAx, i);\n const rAy = n(constraint.rotAy, i);\n const rBx = n(constraint.rotBx, i);\n const rBy = n(constraint.rotBy, i);\n const vn = normalVelocity(bodyA, bodyB, rAx, rAy, rBx, rBy, nx, ny);\n const oldNormal = n(constraint.record.normalImpulse, i);\n // A clamped push-out target is a fixed velocity goal, not a spring\n // response: scaling it down by `massScale` would leave the point short of\n // a target that is already capped, and the deficit is what removes the\n // fixpoint once the cap binds. Solve those points hard, as the two-point\n // block path always does.\n const clamped = constraint.biasClamped[i] ?? false;\n const massScale = useBias && !clamped ? constraint.massScale : 1;\n const impulseScale = useBias && !clamped ? constraint.impulseScale : 0;\n const impulse = -n(constraint.normalMass, i) * massScale * (vn - n(constraint.velocityBias, i)) - impulseScale * oldNormal;\n const newNormal = Math.max(0, oldNormal + impulse);\n const deltaNormal = newNormal - oldNormal;\n\n constraint.record.normalImpulse[i] = newNormal;\n applyImpulse(bodyA, bodyB, rAx, rAy, rBx, rBy, deltaNormal * nx, deltaNormal * ny);\n }\n }\n\n /**\n * Two-point block normal solve (Box2D LCP): find both new normal impulses\n * `x ≥ 0` so the post-solve normal velocities equal the push-out targets\n * (`velocityBias`, zero in the relax pass) and are complementary, trying the\n * four corners (both active, one active, none). The block path carries the\n * soft push-out as its target but solves with a hard mass scale.\n */\n private _solveNormalBlock(constraint: ContactConstraint): void {\n const bodyA = constraint.bodyA;\n const bodyB = constraint.bodyB;\n const nx = constraint.nx;\n const ny = constraint.ny;\n const a1 = n(constraint.record.normalImpulse, 0);\n const a2 = n(constraint.record.normalImpulse, 1);\n const vn1 = normalVelocity(bodyA, bodyB, n(constraint.rotAx, 0), n(constraint.rotAy, 0), n(constraint.rotBx, 0), n(constraint.rotBy, 0), nx, ny);\n const vn2 = normalVelocity(bodyA, bodyB, n(constraint.rotAx, 1), n(constraint.rotAy, 1), n(constraint.rotBx, 1), n(constraint.rotBy, 1), nx, ny);\n\n // Residual at the current impulse: b = (vn − bias) − K·a.\n const bx = vn1 - n(constraint.velocityBias, 0) - (constraint.k11 * a1 + constraint.k12 * a2);\n const by = vn2 - n(constraint.velocityBias, 1) - (constraint.k12 * a1 + constraint.k22 * a2);\n\n // Case 1 - both points active: x = −K⁻¹·b.\n let x1 = -(constraint.invK11 * bx + constraint.invK12 * by);\n let x2 = -(constraint.invK12 * bx + constraint.invK22 * by);\n let solved = x1 >= 0 && x2 >= 0;\n\n if (!solved) {\n // Case 2 - only point 1 active (x2 = 0).\n x1 = -n(constraint.normalMass, 0) * bx;\n x2 = 0;\n solved = x1 >= 0 && constraint.k12 * x1 + by >= 0;\n }\n\n if (!solved) {\n // Case 3 - only point 2 active (x1 = 0).\n x1 = 0;\n x2 = -n(constraint.normalMass, 1) * by;\n solved = x2 >= 0 && constraint.k12 * x2 + bx >= 0;\n }\n\n if (!solved) {\n // Case 4 - neither active (separating). Only valid when both residuals are\n // non-negative; otherwise no corner applies and the impulses stay put.\n if (bx < 0 || by < 0) {\n return;\n }\n\n x1 = 0;\n x2 = 0;\n }\n\n // Applied here rather than through a helper: the deltas are freshly computed\n // doubles, and passing them across a call the optimiser declines to inline\n // boxes each one on the heap for the duration of the call.\n const d1 = x1 - a1;\n const d2 = x2 - a2;\n const jx = (d1 + d2) * nx;\n const jy = (d1 + d2) * ny;\n const torqueA = (n(constraint.rotAx, 0) * ny - n(constraint.rotAy, 0) * nx) * d1 + (n(constraint.rotAx, 1) * ny - n(constraint.rotAy, 1) * nx) * d2;\n const torqueB = (n(constraint.rotBx, 0) * ny - n(constraint.rotBy, 0) * nx) * d1 + (n(constraint.rotBx, 1) * ny - n(constraint.rotBy, 1) * nx) * d2;\n\n bodyA.linearVelocityX -= jx * bodyA.invMass;\n bodyA.linearVelocityY -= jy * bodyA.invMass;\n bodyA.angularVelocity -= torqueA * bodyA.invInertia;\n bodyB.linearVelocityX += jx * bodyB.invMass;\n bodyB.linearVelocityY += jy * bodyB.invMass;\n bodyB.angularVelocity += torqueB * bodyB.invInertia;\n\n constraint.record.normalImpulse[0] = x1;\n constraint.record.normalImpulse[1] = x2;\n }\n\n private _acquire(): ContactConstraint {\n if (this._count === this._constraints.length) {\n this._constraints.push(new ContactConstraint());\n }\n\n return this._at(this._count++);\n }\n\n /**\n * Pooled constraint at `ci`. Every caller indexes within `0..this._count-1`\n * and `_count` never exceeds the pool length, so the entry always exists; the\n * throw is unreachable and only discharges `noUncheckedIndexedAccess` without a\n * cast or non-null assertion.\n */\n private _at(ci: number): ContactConstraint {\n const constraint = this._constraints[ci];\n\n if (constraint === undefined) {\n throw new RangeError(`ContactSolver: constraint pool index ${ci} out of range.`);\n }\n\n return constraint;\n }\n}\n\n/**\n * Live contact separation at point `i`, recomputed from each body's accumulated\n * delta position plus the rotation-induced shift of the (rotated) anchor since\n * frame start, projected onto the normal. Negative when overlapping. This is what\n * folds the position constraint into the velocity solve without a separate\n * geometric pass or re-running detection per sub-step.\n */\nconst currentSeparation = (constraint: ContactConstraint, i: number): number => {\n const bodyA = constraint.bodyA;\n const bodyB = constraint.bodyB;\n // Anchor displacement since frame start = linear delta + (rotated arm − base arm).\n const dispAx = bodyA._deltaPosX + n(constraint.rotAx, i) - n(constraint.rAx, i);\n const dispAy = bodyA._deltaPosY + n(constraint.rotAy, i) - n(constraint.rAy, i);\n const dispBx = bodyB._deltaPosX + n(constraint.rotBx, i) - n(constraint.rBx, i);\n const dispBy = bodyB._deltaPosY + n(constraint.rotBy, i) - n(constraint.rBy, i);\n\n return n(constraint.baseSeparation, i) + (dispBx - dispAx) * constraint.nx + (dispBy - dispAy) * constraint.ny;\n};\n\n/** Relative normal velocity at a contact point: `dot(vB + ωB×rB − vA − ωA×rA, n)`. */\nconst normalVelocity = (bodyA: PhysicsBody, bodyB: PhysicsBody, rAx: number, rAy: number, rBx: number, rBy: number, nx: number, ny: number): number => {\n const dvx = bodyB.linearVelocityX - bodyB.angularVelocity * rBy - (bodyA.linearVelocityX - bodyA.angularVelocity * rAy);\n const dvy = bodyB.linearVelocityY + bodyB.angularVelocity * rBx - (bodyA.linearVelocityY + bodyA.angularVelocity * rAx);\n\n return dvx * nx + dvy * ny;\n};\n\n/** Apply impulse `(jx, jy)` to B and its negation to A about their contact arms. */\nconst applyImpulse = (bodyA: PhysicsBody, bodyB: PhysicsBody, rAx: number, rAy: number, rBx: number, rBy: number, jx: number, jy: number): void => {\n bodyA.linearVelocityX -= jx * bodyA.invMass;\n bodyA.linearVelocityY -= jy * bodyA.invMass;\n bodyA.angularVelocity -= (rAx * jy - rAy * jx) * bodyA.invInertia;\n\n bodyB.linearVelocityX += jx * bodyB.invMass;\n bodyB.linearVelocityY += jy * bodyB.invMass;\n bodyB.angularVelocity += (rBx * jy - rBy * jx) * bodyB.invInertia;\n};\n\nconst clamp = (value: number, low: number, high: number): number => Math.min(Math.max(value, low), high);\n\n/**\n * In-bounds read of a fixed-size (length-2) per-point scratch array. Every\n * caller indexes within `0..pointCount-1` (pointCount ≤ 2), so the element\n * always exists; the `0` fallback only discharges `noUncheckedIndexedAccess`\n * for the unreachable case and keeps the `??` out of caller complexity.\n */\nconst n = (arr: readonly number[], i: number): number => arr[i] ?? 0;\n"],"mappings":";;;;;;;;AAWA,MAAM,kBAAkB;;AAExB,MAAM,qBAAqB;;;;;;;;;;AAW3B,IAAM,oBAAN,MAAwB;CACtB,AAAO;CACP,AAAO;CACP,AAAO;CACP,AAAO,KAAK;CACZ,AAAO,KAAK;CACZ,AAAO,KAAK;CACZ,AAAO,KAAK;CACZ,AAAO,WAAW;CAClB,AAAO,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MAAM,SAAS,UAAU,WAAW;AAC9G;;AAGA,MAAM,kBAAkB,OAAoB,OAAoB,KAAa,KAAa,KAAa,KAAa,IAAY,OAAuB;CACrJ,MAAM,MAAM,MAAM,kBAAkB,MAAM,kBAAkB,OAAO,MAAM,kBAAkB,MAAM,kBAAkB;CACnH,MAAM,MAAM,MAAM,kBAAkB,MAAM,kBAAkB,OAAO,MAAM,kBAAkB,MAAM,kBAAkB;CAEnH,OAAO,MAAM,KAAK,MAAM;AAC1B;;AAGA,MAAM,gBAAgB,OAAoB,OAAoB,KAAa,KAAa,KAAa,KAAa,IAAY,OAAqB;CACjJ,MAAM,mBAAmB,KAAK,MAAM;CACpC,MAAM,mBAAmB,KAAK,MAAM;CACpC,MAAM,oBAAoB,MAAM,KAAK,MAAM,MAAM,MAAM;CAEvD,MAAM,mBAAmB,KAAK,MAAM;CACpC,MAAM,mBAAmB,KAAK,MAAM;CACpC,MAAM,oBAAoB,MAAM,KAAK,MAAM,MAAM,MAAM;AACzD;AAEA,MAAM,SAAS,OAAe,KAAa,SAAyB,KAAK,IAAI,KAAK,IAAI,OAAO,GAAG,GAAG,IAAI;;;;;;;AAQvG,MAAM,KAAK,KAAwB,MAAsB,IAAI,MAAM"}
1
+ {"version":3,"file":"ContactSolver.js","names":[],"sources":["../../../src/solver/ContactSolver.ts"],"sourcesContent":["import type { ContactRecord } from '../ContactGraph';\nimport type { PhysicsBody } from '../PhysicsBody';\nimport { contactSlop } from './tolerances';\n\n/** Relative normal speed (px/s) below which a contact is treated as resting (no restitution). */\nconst restitutionThreshold = 1;\n/**\n * Cap on the soft-constraint push-out velocity (px/s). Bounds how fast the bias\n * resolves deep penetration so a large overlap cannot fling bodies apart.\n *\n * The Box2D-v3 analogue is `contactSpeed = 3·lengthUnit`, i.e. 3 m/s in SI. The\n * conversion to pixels is the whole content of this constant: 2D games in this\n * engine's envelope put a metre at roughly 20-100 px (equivalently, the gravity\n * range the solver is tuned for, a few hundred to a few thousand px/s²), so the\n * same physical speed is 60-300 px/s. The low end of that band is taken - it is\n * already past the point where a settling scene stops fighting the cap, and\n * anything higher only widens the speed at which a deep overlap may be undone.\n *\n * A single-digit cap is enough for one body resting on a floor and badly short\n * everywhere else: a gravity-driven pile rearranges faster than such a push-out\n * can work, so overlap accumulates instead of resolving, the pile settles\n * several px deep with far more touching pairs than its geometry has, and the\n * permanently unresolved contacts keep every island awake.\n */\nconst maxBiasVelocity = 60;\n/** Reject the 2-point block solve when the contact matrix is worse-conditioned than this (fall back to sequential). */\nconst maxConditionNumber = 1000;\n\n/**\n * Per-contact velocity constraint (1-2 points), computed once per **frame** in\n * {@link ContactSolver.prepare} and reused across all sub-steps and passes.\n * Pooled and reused across frames, so a steady-state step constructs no\n * constraint of its own. It is not allocation-free in the wider sense: a double\n * handed to a function the optimiser declines to inline is boxed on the heap for\n * the duration of that call, which is why the hot paths below apply their\n * results in place instead of through helpers.\n */\nclass ContactConstraint {\n public record!: ContactRecord;\n public bodyA!: PhysicsBody;\n public bodyB!: PhysicsBody;\n public nx = 0;\n public ny = 0;\n public tx = 0;\n public ty = 0;\n public friction = 0;\n public restitution = 0;\n public pointCount = 0;\n\n // Soft-constraint factors (Box2D-v3 \"soft step\"), derived once per frame from\n // contactHertz/dampingRatio and the sub-step `h`. Shared by both points.\n public biasRate = 0;\n public massScale = 1;\n public impulseScale = 0;\n\n // Per-point contact arms at frame start (relative to each body's centre of mass).\n public readonly rAx = [0, 0];\n public readonly rAy = [0, 0];\n public readonly rBx = [0, 0];\n public readonly rBy = [0, 0];\n // Per-point arms rotated by the live sub-step rotation (refreshed each pass by\n // {@link ContactSolver._updateArms}); the solve reads these so a rotating body's\n // contact torque tracks its current orientation.\n public readonly rotAx = [0, 0];\n public readonly rotAy = [0, 0];\n public readonly rotBx = [0, 0];\n public readonly rotBy = [0, 0];\n public readonly normalMass = [0, 0];\n public readonly tangentMass = [0, 0];\n /** Contact separation at frame start (= −penetration; negative when overlapping). */\n public readonly baseSeparation = [0, 0];\n /** Relative normal velocity at frame start (the impact speed the restitution pass keys off). */\n public readonly relativeVelocity = [0, 0];\n /** Push-out target normal velocity for the current pass (set per pass from the live separation). */\n public readonly velocityBias = [0, 0];\n /**\n * Whether the point's push-out target was clamped to `maxBiasVelocity` this\n * pass. A clamped target is no longer the spring response the soft scaling\n * models, so the single-point solve drops that scaling while it holds.\n */\n public readonly biasClamped = [false, false];\n\n // 2-point block: the contact matrix `K` and its inverse (set only when the\n // manifold has two points and `K` is well-conditioned; else sequential).\n public block = false;\n public k11 = 0;\n public k12 = 0;\n public k22 = 0;\n public invK11 = 0;\n public invK12 = 0;\n public invK22 = 0;\n}\n\n/**\n * Native warm-started **TGS-Soft** contact solver (Box2D-v3 \"soft step\"). Driven\n * by {@link PhysicsWorld} as a sub-stepping loop: detection runs once per frame,\n * then {@link prepare} builds the per-contact constraints (effective masses,\n * frame-start separation + impact velocity, soft factors, and a 2×2 block matrix\n * for two-point manifolds) **once**, and each sub-step runs\n * {@link warmStart} → {@link solveVelocities}(useBias=true) → integrate positions\n * → {@link solveVelocities}(useBias=false) relax. A final {@link applyRestitution}\n * pass adds bounce above the threshold.\n *\n * The position constraint is folded into the velocity solve as a **soft bias**\n * (a damped-spring push-out whose stiffness is decoupled from the iteration\n * count), recomputed each pass from the live per-body delta position/rotation -\n * so there is no separate NGS geometric pass. The contact anchors are rotated by\n * the live sub-step rotation each pass, so a tilting stack's restoring torque is\n * computed against its current orientation (without this the tilt grows instead\n * of being corrected). Two-point manifolds still solve the normal impulses **as a\n * 2×2 block LCP** (Box2D-style), which propagates stack loads far better than\n * solving the points sequentially; the block path carries the soft push-out as\n * its velocity target (hard mass scale), while single-point contacts use the full\n * soft mass/impulse scaling for as long as their push-out target stays inside\n * the cap, and the hard scale once it is clamped. Accumulated impulses are\n * written back to each {@link ContactRecord} for warm-starting the next frame.\n *\n * Internal to {@link NativePhysicsBackend}; not part of the public surface.\n */\nexport class ContactSolver {\n private readonly _constraints: ContactConstraint[] = [];\n private _count = 0;\n\n /**\n * Build the per-contact constraints for this frame from the touching solid\n * contacts. `h` is the sub-step duration (`fixedDelta / subStepCount`); the\n * soft factors are derived from it together with `contactHertz`/`dampingRatio`.\n * Runs once per frame (detection is not repeated per sub-step).\n */\n public prepare(contacts: readonly ContactRecord[], h: number, contactHertz: number, dampingRatio: number): void {\n this._count = 0;\n\n // Box2D-v3 soft-constraint factors from a damped spring (hertz, zeta) at the\n // sub-step `h`: omega = 2πf; a1 = 2ζ + hω; a2 = hω·a1; a3 = 1/(1+a2).\n const omega = 2 * Math.PI * contactHertz;\n const a1 = 2 * dampingRatio + h * omega;\n const a2 = h * omega * a1;\n const a3 = 1 / (1 + a2);\n const biasRate = contactHertz > 0 ? omega / a1 : 0;\n const massScale = contactHertz > 0 ? a2 * a3 : 1;\n const impulseScale = contactHertz > 0 ? a3 : 0;\n\n for (const contact of contacts) {\n const manifold = contact.manifold;\n const pointCount = manifold.pointCount;\n\n // A contact the world's `ContactModifier` disabled for this step stays\n // touching geometrically but applies no impulse.\n if (pointCount === 0 || !contact.enabled) {\n continue;\n }\n\n const bodyA = contact.a.body;\n const bodyB = contact.b.body;\n\n // Skip contacts where either body is asleep: a sleeping island's solid\n // contacts are all sleeping↔sleeping or sleeping↔static (both at rest), so\n // there is nothing to solve. A sleeping body touched by an awake one is\n // woken (island merge) before this runs, so it is never skipped wrongly.\n if (bodyA.isSleeping || bodyB.isSleeping) {\n continue;\n }\n\n const constraint = this._acquire();\n const nx = manifold.normalX;\n const ny = manifold.normalY;\n const tx = -ny;\n const ty = nx;\n\n constraint.record = contact;\n constraint.bodyA = bodyA;\n constraint.bodyB = bodyB;\n constraint.nx = nx;\n constraint.ny = ny;\n constraint.tx = tx;\n constraint.ty = ty;\n // Per-step values: derived from the two colliders each pass, then possibly\n // overridden by the world's `ContactModifier`.\n constraint.friction = contact.friction;\n constraint.restitution = contact.restitution;\n constraint.pointCount = pointCount;\n constraint.block = false;\n constraint.biasRate = biasRate;\n constraint.massScale = massScale;\n constraint.impulseScale = impulseScale;\n\n const mA = bodyA.invMass;\n const mB = bodyB.invMass;\n const iA = bodyA.invInertia;\n const iB = bodyB.invInertia;\n const comAx = bodyA.worldCenterOfMassX;\n const comAy = bodyA.worldCenterOfMassY;\n const comBx = bodyB.worldCenterOfMassX;\n const comBy = bodyB.worldCenterOfMassY;\n\n for (let i = 0; i < pointCount; i++) {\n // i in 0..pointCount-1 and pointCount ≤ 2, so the manifold point exists.\n const point = i === 0 ? manifold.points[0] : manifold.points[1];\n const rAx = point.x - comAx;\n const rAy = point.y - comAy;\n const rBx = point.x - comBx;\n const rBy = point.y - comBy;\n\n constraint.rAx[i] = rAx;\n constraint.rAy[i] = rAy;\n constraint.rBx[i] = rBx;\n constraint.rBy[i] = rBy;\n // Frame start: no accumulated rotation yet, so the live arms equal the base arms.\n constraint.rotAx[i] = rAx;\n constraint.rotAy[i] = rAy;\n constraint.rotBx[i] = rBx;\n constraint.rotBy[i] = rBy;\n\n const rnA = rAx * ny - rAy * nx;\n const rnB = rBx * ny - rBy * nx;\n const kn = mA + mB + iA * rnA * rnA + iB * rnB * rnB;\n const rtA = rAx * ty - rAy * tx;\n const rtB = rBx * ty - rBy * tx;\n const kt = mA + mB + iA * rtA * rtA + iB * rtB * rtB;\n\n constraint.normalMass[i] = kn > 0 ? 1 / kn : 0;\n constraint.tangentMass[i] = kt > 0 ? 1 / kt : 0;\n constraint.baseSeparation[i] = -point.penetration;\n constraint.velocityBias[i] = 0;\n\n // Frame-start relative normal velocity (the true impact speed, captured\n // before this frame's gravity since prepare runs ahead of the sub-step\n // loop) - keys the restitution pass so a resting contact does not\n // perpetually micro-bounce off the per-step gravity increment.\n constraint.relativeVelocity[i] = normalVelocity(bodyA, bodyB, rAx, rAy, rBx, rBy, nx, ny);\n }\n\n if (pointCount === 2) {\n const rn1A = n(constraint.rAx, 0) * ny - n(constraint.rAy, 0) * nx;\n const rn1B = n(constraint.rBx, 0) * ny - n(constraint.rBy, 0) * nx;\n const rn2A = n(constraint.rAx, 1) * ny - n(constraint.rAy, 1) * nx;\n const rn2B = n(constraint.rBx, 1) * ny - n(constraint.rBy, 1) * nx;\n const k11 = mA + mB + iA * rn1A * rn1A + iB * rn1B * rn1B;\n const k22 = mA + mB + iA * rn2A * rn2A + iB * rn2B * rn2B;\n const k12 = mA + mB + iA * rn1A * rn2A + iB * rn1B * rn2B;\n const det = k11 * k22 - k12 * k12;\n\n // Only block-solve when `K` is well-conditioned (parallel-ish contacts\n // produce a near-singular matrix → fall back to sequential).\n if (det > 0 && k11 * k11 < maxConditionNumber * det) {\n const invDet = 1 / det;\n\n constraint.k11 = k11;\n constraint.k12 = k12;\n constraint.k22 = k22;\n constraint.invK11 = invDet * k22;\n constraint.invK12 = -invDet * k12;\n constraint.invK22 = invDet * k11;\n constraint.block = true;\n }\n }\n }\n }\n\n /** Re-apply the cached impulses from the previous frame (warm-starting); runs each sub-step. */\n public warmStart(): void {\n for (let ci = 0; ci < this._count; ci++) {\n const constraint = this._at(ci);\n const bodyA = constraint.bodyA;\n const bodyB = constraint.bodyB;\n\n this._updateArms(constraint);\n\n for (let i = 0; i < constraint.pointCount; i++) {\n const normalImpulse = n(constraint.record.normalImpulse, i);\n const tangentImpulse = n(constraint.record.tangentImpulse, i);\n const jx = normalImpulse * constraint.nx + tangentImpulse * constraint.tx;\n const jy = normalImpulse * constraint.ny + tangentImpulse * constraint.ty;\n\n applyImpulse(bodyA, bodyB, n(constraint.rotAx, i), n(constraint.rotAy, i), n(constraint.rotBx, i), n(constraint.rotBy, i), jx, jy);\n }\n }\n }\n\n /**\n * One velocity pass over every contact: the normal constraint (block when\n * possible) then friction (Coulomb cone). With `useBias` the normal solve\n * carries the soft push-out bias (the main pass, recomputed from the live\n * separation); without it the relax pass drives the normal velocity to zero so\n * the bias velocity does not remain in the bodies as injected energy.\n */\n public solveVelocities(useBias: boolean): void {\n for (let ci = 0; ci < this._count; ci++) {\n this._solveVelocityContact(this._at(ci), useBias);\n }\n }\n\n /**\n * Restitution pass, run once after the sub-step loop. For each loaded point\n * whose frame-start impact speed exceeded the threshold, add the impulse that\n * brings the post-solve normal velocity to `−restitution·impactSpeed`. Kept\n * separate from the main solve so resting contacts (impact below threshold) do\n * not micro-bounce.\n */\n public applyRestitution(): void {\n for (let ci = 0; ci < this._count; ci++) {\n const constraint = this._at(ci);\n\n if (constraint.restitution === 0) {\n continue;\n }\n\n const bodyA = constraint.bodyA;\n const bodyB = constraint.bodyB;\n const nx = constraint.nx;\n const ny = constraint.ny;\n\n this._updateArms(constraint);\n\n for (let i = 0; i < constraint.pointCount; i++) {\n const relativeVelocity = n(constraint.relativeVelocity, i);\n\n // Only points that carried load (normalImpulse > 0) and were struck\n // above the resting threshold bounce.\n if (relativeVelocity > -restitutionThreshold || n(constraint.record.normalImpulse, i) <= 0) {\n continue;\n }\n\n const rAx = n(constraint.rotAx, i);\n const rAy = n(constraint.rotAy, i);\n const rBx = n(constraint.rotBx, i);\n const rBy = n(constraint.rotBy, i);\n const vn = normalVelocity(bodyA, bodyB, rAx, rAy, rBx, rBy, nx, ny);\n const oldNormal = n(constraint.record.normalImpulse, i);\n const newNormal = Math.max(0, oldNormal - n(constraint.normalMass, i) * (vn + constraint.restitution * relativeVelocity));\n const deltaNormal = newNormal - oldNormal;\n\n constraint.record.normalImpulse[i] = newNormal;\n applyImpulse(bodyA, bodyB, rAx, rAy, rBx, rBy, deltaNormal * nx, deltaNormal * ny);\n }\n }\n }\n\n /** Refresh the live (rotated) contact arms from each body's accumulated sub-step rotation. */\n private _updateArms(constraint: ContactConstraint): void {\n const cosA = constraint.bodyA._deltaCos;\n const sinA = constraint.bodyA._deltaSin;\n const cosB = constraint.bodyB._deltaCos;\n const sinB = constraint.bodyB._deltaSin;\n\n for (let i = 0; i < constraint.pointCount; i++) {\n const rAx = n(constraint.rAx, i);\n const rAy = n(constraint.rAy, i);\n const rBx = n(constraint.rBx, i);\n const rBy = n(constraint.rBy, i);\n\n constraint.rotAx[i] = rAx * cosA - rAy * sinA;\n constraint.rotAy[i] = rAx * sinA + rAy * cosA;\n constraint.rotBx[i] = rBx * cosB - rBy * sinB;\n constraint.rotBy[i] = rBx * sinB + rBy * cosB;\n }\n }\n\n private _solveVelocityContact(constraint: ContactConstraint, useBias: boolean): void {\n this._updateArms(constraint);\n\n // Recompute the per-point push-out target from the live separation (folds the\n // position constraint into the velocity solve as a soft bias). With useBias\n // off (relax pass) the target is zero - the plain hard normal solve.\n for (let i = 0; i < constraint.pointCount; i++) {\n // Push out only the penetration beyond the slop, capped - leaving the slop\n // keeps the contact overlapping so the narrow phase does not drop it.\n const excess = -currentSeparation(constraint, i) - contactSlop;\n const target = useBias && excess > 0 ? constraint.biasRate * excess : 0;\n\n constraint.velocityBias[i] = Math.min(target, maxBiasVelocity);\n constraint.biasClamped[i] = target > maxBiasVelocity;\n }\n\n // Normal before friction (Box2D-v3 order): friction's Coulomb cone clamps to\n // `μ·normalImpulse`, so it must see this pass's freshly-solved normal impulse -\n // solving friction first uses last pass's cone and lets stacks creep laterally.\n if (constraint.block) {\n this._solveNormalBlock(constraint);\n } else {\n this._solveNormalSequential(constraint, useBias);\n }\n\n this._solveFriction(constraint);\n }\n\n /** Per-point friction: clamp the accumulated tangent impulse to the Coulomb cone `±μ·normalImpulse`. */\n private _solveFriction(constraint: ContactConstraint): void {\n const bodyA = constraint.bodyA;\n const bodyB = constraint.bodyB;\n\n for (let i = 0; i < constraint.pointCount; i++) {\n const rAx = n(constraint.rotAx, i);\n const rAy = n(constraint.rotAy, i);\n const rBx = n(constraint.rotBx, i);\n const rBy = n(constraint.rotBy, i);\n const vtX = bodyB.linearVelocityX - bodyB.angularVelocity * rBy - (bodyA.linearVelocityX - bodyA.angularVelocity * rAy);\n const vtY = bodyB.linearVelocityY + bodyB.angularVelocity * rBx - (bodyA.linearVelocityY + bodyA.angularVelocity * rAx);\n const vt = vtX * constraint.tx + vtY * constraint.ty;\n const maxFriction = constraint.friction * n(constraint.record.normalImpulse, i);\n const oldTangent = n(constraint.record.tangentImpulse, i);\n const newTangent = clamp(oldTangent - n(constraint.tangentMass, i) * vt, -maxFriction, maxFriction);\n const deltaTangent = newTangent - oldTangent;\n\n constraint.record.tangentImpulse[i] = newTangent;\n applyImpulse(bodyA, bodyB, rAx, rAy, rBx, rBy, deltaTangent * constraint.tx, deltaTangent * constraint.ty);\n }\n }\n\n /**\n * Single-point (or ill-conditioned) soft normal solve, accumulated and clamped\n * ≥ 0. The Box2D-v3 incremental form: with the soft bias active the impulse is\n * `−normalMass·massScale·(vn − bias) − impulseScale·accumulated`, which both\n * pushes out the penetration and bleeds a little stored impulse (the damped\n * spring). The relax pass passes `useBias=false`, collapsing it to the hard\n * `−normalMass·vn` (no bias, full mass, no impulse decay).\n *\n * A point whose push-out target was clamped to `maxBiasVelocity` is solved\n * with the hard scale as well: the soft scaling models a spring, and once the\n * target is capped the point would otherwise reach only a fraction of an\n * already limited push-out. That deficit grows with the load, so past the\n * acceleration at which the cap binds the contact would sink without bound\n * instead of settling into a slightly deeper limit cycle.\n */\n private _solveNormalSequential(constraint: ContactConstraint, useBias: boolean): void {\n const bodyA = constraint.bodyA;\n const bodyB = constraint.bodyB;\n const nx = constraint.nx;\n const ny = constraint.ny;\n\n for (let i = 0; i < constraint.pointCount; i++) {\n const rAx = n(constraint.rotAx, i);\n const rAy = n(constraint.rotAy, i);\n const rBx = n(constraint.rotBx, i);\n const rBy = n(constraint.rotBy, i);\n const vn = normalVelocity(bodyA, bodyB, rAx, rAy, rBx, rBy, nx, ny);\n const oldNormal = n(constraint.record.normalImpulse, i);\n // A clamped push-out target is a fixed velocity goal, not a spring\n // response: scaling it down by `massScale` would leave the point short of\n // a target that is already capped, and the deficit is what removes the\n // fixpoint once the cap binds. Solve those points hard, as the two-point\n // block path always does.\n const clamped = constraint.biasClamped[i] ?? false;\n const massScale = useBias && !clamped ? constraint.massScale : 1;\n const impulseScale = useBias && !clamped ? constraint.impulseScale : 0;\n const impulse = -n(constraint.normalMass, i) * massScale * (vn - n(constraint.velocityBias, i)) - impulseScale * oldNormal;\n const newNormal = Math.max(0, oldNormal + impulse);\n const deltaNormal = newNormal - oldNormal;\n\n constraint.record.normalImpulse[i] = newNormal;\n applyImpulse(bodyA, bodyB, rAx, rAy, rBx, rBy, deltaNormal * nx, deltaNormal * ny);\n }\n }\n\n /**\n * Two-point block normal solve (Box2D LCP): find both new normal impulses\n * `x ≥ 0` so the post-solve normal velocities equal the push-out targets\n * (`velocityBias`, zero in the relax pass) and are complementary, trying the\n * four corners (both active, one active, none). The block path carries the\n * soft push-out as its target but solves with a hard mass scale.\n */\n private _solveNormalBlock(constraint: ContactConstraint): void {\n const bodyA = constraint.bodyA;\n const bodyB = constraint.bodyB;\n const nx = constraint.nx;\n const ny = constraint.ny;\n const a1 = n(constraint.record.normalImpulse, 0);\n const a2 = n(constraint.record.normalImpulse, 1);\n const vn1 = normalVelocity(bodyA, bodyB, n(constraint.rotAx, 0), n(constraint.rotAy, 0), n(constraint.rotBx, 0), n(constraint.rotBy, 0), nx, ny);\n const vn2 = normalVelocity(bodyA, bodyB, n(constraint.rotAx, 1), n(constraint.rotAy, 1), n(constraint.rotBx, 1), n(constraint.rotBy, 1), nx, ny);\n\n // Residual at the current impulse: b = (vn − bias) − K·a.\n const bx = vn1 - n(constraint.velocityBias, 0) - (constraint.k11 * a1 + constraint.k12 * a2);\n const by = vn2 - n(constraint.velocityBias, 1) - (constraint.k12 * a1 + constraint.k22 * a2);\n\n // Case 1 - both points active: x = −K⁻¹·b.\n let x1 = -(constraint.invK11 * bx + constraint.invK12 * by);\n let x2 = -(constraint.invK12 * bx + constraint.invK22 * by);\n let solved = x1 >= 0 && x2 >= 0;\n\n if (!solved) {\n // Case 2 - only point 1 active (x2 = 0).\n x1 = -n(constraint.normalMass, 0) * bx;\n x2 = 0;\n solved = x1 >= 0 && constraint.k12 * x1 + by >= 0;\n }\n\n if (!solved) {\n // Case 3 - only point 2 active (x1 = 0).\n x1 = 0;\n x2 = -n(constraint.normalMass, 1) * by;\n solved = x2 >= 0 && constraint.k12 * x2 + bx >= 0;\n }\n\n if (!solved) {\n // Case 4 - neither active (separating). Only valid when both residuals are\n // non-negative; otherwise no corner applies and the impulses stay put.\n if (bx < 0 || by < 0) {\n return;\n }\n\n x1 = 0;\n x2 = 0;\n }\n\n // Applied here rather than through a helper: the deltas are freshly computed\n // doubles, and passing them across a call the optimiser declines to inline\n // boxes each one on the heap for the duration of the call.\n const d1 = x1 - a1;\n const d2 = x2 - a2;\n const jx = (d1 + d2) * nx;\n const jy = (d1 + d2) * ny;\n const torqueA = (n(constraint.rotAx, 0) * ny - n(constraint.rotAy, 0) * nx) * d1 + (n(constraint.rotAx, 1) * ny - n(constraint.rotAy, 1) * nx) * d2;\n const torqueB = (n(constraint.rotBx, 0) * ny - n(constraint.rotBy, 0) * nx) * d1 + (n(constraint.rotBx, 1) * ny - n(constraint.rotBy, 1) * nx) * d2;\n\n bodyA.linearVelocityX -= jx * bodyA.invMass;\n bodyA.linearVelocityY -= jy * bodyA.invMass;\n bodyA.angularVelocity -= torqueA * bodyA.invInertia;\n bodyB.linearVelocityX += jx * bodyB.invMass;\n bodyB.linearVelocityY += jy * bodyB.invMass;\n bodyB.angularVelocity += torqueB * bodyB.invInertia;\n\n constraint.record.normalImpulse[0] = x1;\n constraint.record.normalImpulse[1] = x2;\n }\n\n private _acquire(): ContactConstraint {\n if (this._count === this._constraints.length) {\n this._constraints.push(new ContactConstraint());\n }\n\n return this._at(this._count++);\n }\n\n /**\n * Pooled constraint at `ci`. Every caller indexes within `0..this._count-1`\n * and `_count` never exceeds the pool length, so the entry always exists; the\n * throw is unreachable and only discharges `noUncheckedIndexedAccess` without a\n * cast or non-null assertion.\n */\n private _at(ci: number): ContactConstraint {\n const constraint = this._constraints[ci];\n\n if (constraint === undefined) {\n throw new RangeError(`ContactSolver: constraint pool index ${ci} out of range.`);\n }\n\n return constraint;\n }\n}\n\n/**\n * Live contact separation at point `i`, recomputed from each body's accumulated\n * delta position plus the rotation-induced shift of the (rotated) anchor since\n * frame start, projected onto the normal. Negative when overlapping. This is what\n * folds the position constraint into the velocity solve without a separate\n * geometric pass or re-running detection per sub-step.\n */\nconst currentSeparation = (constraint: ContactConstraint, i: number): number => {\n const bodyA = constraint.bodyA;\n const bodyB = constraint.bodyB;\n // Anchor displacement since frame start = linear delta + (rotated arm − base arm).\n const dispAx = bodyA._deltaPosX + n(constraint.rotAx, i) - n(constraint.rAx, i);\n const dispAy = bodyA._deltaPosY + n(constraint.rotAy, i) - n(constraint.rAy, i);\n const dispBx = bodyB._deltaPosX + n(constraint.rotBx, i) - n(constraint.rBx, i);\n const dispBy = bodyB._deltaPosY + n(constraint.rotBy, i) - n(constraint.rBy, i);\n\n return n(constraint.baseSeparation, i) + (dispBx - dispAx) * constraint.nx + (dispBy - dispAy) * constraint.ny;\n};\n\n/** Relative normal velocity at a contact point: `dot(vB + ωB×rB − vA − ωA×rA, n)`. */\nconst normalVelocity = (bodyA: PhysicsBody, bodyB: PhysicsBody, rAx: number, rAy: number, rBx: number, rBy: number, nx: number, ny: number): number => {\n const dvx = bodyB.linearVelocityX - bodyB.angularVelocity * rBy - (bodyA.linearVelocityX - bodyA.angularVelocity * rAy);\n const dvy = bodyB.linearVelocityY + bodyB.angularVelocity * rBx - (bodyA.linearVelocityY + bodyA.angularVelocity * rAx);\n\n return dvx * nx + dvy * ny;\n};\n\n/** Apply impulse `(jx, jy)` to B and its negation to A about their contact arms. */\nconst applyImpulse = (bodyA: PhysicsBody, bodyB: PhysicsBody, rAx: number, rAy: number, rBx: number, rBy: number, jx: number, jy: number): void => {\n bodyA.linearVelocityX -= jx * bodyA.invMass;\n bodyA.linearVelocityY -= jy * bodyA.invMass;\n bodyA.angularVelocity -= (rAx * jy - rAy * jx) * bodyA.invInertia;\n\n bodyB.linearVelocityX += jx * bodyB.invMass;\n bodyB.linearVelocityY += jy * bodyB.invMass;\n bodyB.angularVelocity += (rBx * jy - rBy * jx) * bodyB.invInertia;\n};\n\nconst clamp = (value: number, low: number, high: number): number => Math.min(Math.max(value, low), high);\n\n/**\n * In-bounds read of a fixed-size (length-2) per-point scratch array. Every\n * caller indexes within `0..pointCount-1` (pointCount ≤ 2), so the element\n * always exists; the `0` fallback only discharges `noUncheckedIndexedAccess`\n * for the unreachable case and keeps the `??` out of caller complexity.\n */\nconst n = (arr: readonly number[], i: number): number => arr[i] ?? 0;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAwBA,MAAM,kBAAkB;;AAExB,MAAM,qBAAqB;;;;;;;;;;AAW3B,IAAM,oBAAN,MAAwB;CACtB,AAAO;CACP,AAAO;CACP,AAAO;CACP,AAAO,KAAK;CACZ,AAAO,KAAK;CACZ,AAAO,KAAK;CACZ,AAAO,KAAK;CACZ,AAAO,WAAW;CAClB,AAAO,cAAc;CACrB,AAAO,aAAa;CAIpB,AAAO,WAAW;CAClB,AAAO,YAAY;CACnB,AAAO,eAAe;CAGtB,AAAgB,MAAM,CAAC,GAAG,CAAC;CAC3B,AAAgB,MAAM,CAAC,GAAG,CAAC;CAC3B,AAAgB,MAAM,CAAC,GAAG,CAAC;CAC3B,AAAgB,MAAM,CAAC,GAAG,CAAC;CAI3B,AAAgB,QAAQ,CAAC,GAAG,CAAC;CAC7B,AAAgB,QAAQ,CAAC,GAAG,CAAC;CAC7B,AAAgB,QAAQ,CAAC,GAAG,CAAC;CAC7B,AAAgB,QAAQ,CAAC,GAAG,CAAC;CAC7B,AAAgB,aAAa,CAAC,GAAG,CAAC;CAClC,AAAgB,cAAc,CAAC,GAAG,CAAC;;CAEnC,AAAgB,iBAAiB,CAAC,GAAG,CAAC;;CAEtC,AAAgB,mBAAmB,CAAC,GAAG,CAAC;;CAExC,AAAgB,eAAe,CAAC,GAAG,CAAC;;;;;;CAMpC,AAAgB,cAAc,CAAC,OAAO,KAAK;CAI3C,AAAO,QAAQ;CACf,AAAO,MAAM;CACb,AAAO,MAAM;CACb,AAAO,MAAM;CACb,AAAO,SAAS;CAChB,AAAO,SAAS;CAChB,AAAO,SAAS;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}
@@ -1,34 +1,2 @@
1
- /**
2
- * Penetration allowance (px) the soft bias leaves uncorrected. The narrow phase
3
- * only produces a manifold while the colliders overlap, so pushing penetration
4
- * fully to zero lets a resting contact wink out for a frame (free-fall, then
5
- * re-detect) - a periodic energy spike. Leaving a small slop keeps the contact
6
- * persistently overlapping and the warm-start cache alive.
7
- * @internal
8
- */
9
- export declare const contactSlop = 0.25;
10
- /**
11
- * Penetration (px) above which a contact still counts as unresolved for the
12
- * sleep decision, so neither of its bodies may bank sleep time.
13
- *
14
- * The solver drives every resting contact down to {@link contactSlop}, but only
15
- * at a capped push-out speed that is below the sleep velocity threshold: a body
16
- * that landed hard therefore looks motionless long before its overlap is worked
17
- * off, and sleeping it would freeze it visibly embedded. Both sides must read
18
- * the same tolerance, or the sleep gate and the constraint it is gating drift
19
- * apart.
20
- *
21
- * The value is empirical, not derived: a face contact converges to exactly one
22
- * slop at any gravity, but a single-point contact rests one static spring
23
- * deflection deeper, and that offset grows with gravity (0.28 px at
24
- * 1 000 px/s², 0.53 px at 10 000, 0.67 px at 15 000). Three slops clears that
25
- * envelope for the gravity range the engine is tuned for while staying far
26
- * below the failure it gates, which starts at several px. Beyond roughly
27
- * 15 000 px/s² the push-out cap binds and the resting depth stops following
28
- * the deflection law, settling into a narrow limit cycle just below this
29
- * tolerance instead - so sleep is delayed there rather than granted to an
30
- * embedded body.
31
- * @internal
32
- */
33
- export declare const sleepPenetrationTolerance: number;
1
+ export {};
34
2
  //# sourceMappingURL=tolerances.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tolerances.d.ts","sourceRoot":"","sources":["../../../src/solver/tolerances.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,OAAO,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,yBAAyB,QAAkB,CAAC"}
1
+ {"version":3,"file":"tolerances.d.ts","sourceRoot":"","sources":["../../../src/solver/tolerances.ts"],"names":[],"mappings":""}
@@ -9,26 +9,24 @@
9
9
  */
10
10
  const contactSlop = .25;
11
11
  /**
12
- * Penetration (px) above which a contact still counts as unresolved for the
13
- * sleep decision, so neither of its bodies may bank sleep time.
12
+ * Penetration (px) below which a contact never blocks the sleep decision,
13
+ * whatever the push-out is doing.
14
14
  *
15
- * The solver drives every resting contact down to {@link contactSlop}, but only
16
- * at a capped push-out speed that is below the sleep velocity threshold: a body
17
- * that landed hard therefore looks motionless long before its overlap is worked
18
- * off, and sleeping it would freeze it visibly embedded. Both sides must read
19
- * the same tolerance, or the sleep gate and the constraint it is gating drift
20
- * apart.
15
+ * The sleep gate has to consult penetration at all because the push-out moves
16
+ * bodies through the solver's position bias, which the relax pass removes from
17
+ * their velocity again: a body still climbing out of geometry looks motionless
18
+ * to the velocity thresholds, and sleeping it would freeze it visibly embedded.
19
+ * Both sides must read the same tolerance, or the sleep gate and the constraint
20
+ * it is gating drift apart.
21
21
  *
22
22
  * The value is empirical, not derived: a face contact converges to exactly one
23
23
  * slop at any gravity, but a single-point contact rests one static spring
24
- * deflection deeper, and that offset grows with gravity (0.28 px at
25
- * 1 000 px/s², 0.53 px at 10 000, 0.67 px at 15 000). Three slops clears that
26
- * envelope for the gravity range the engine is tuned for while staying far
27
- * below the failure it gates, which starts at several px. Beyond roughly
28
- * 15 000 px/s² the push-out cap binds and the resting depth stops following
29
- * the deflection law, settling into a narrow limit cycle just below this
30
- * tolerance instead - so sleep is delayed there rather than granted to an
31
- * embedded body.
24
+ * deflection deeper, and that offset grows with acceleration (0.28 px at
25
+ * 1 000 px/s², 0.53 px at 10 000). Three slops clears that envelope for the
26
+ * gravity range the engine is tuned for, so an ordinary resting contact is
27
+ * settled by depth alone. Equilibria deeper than that - a loaded contact inside
28
+ * a pile, or a lone contact at extreme acceleration - are decided on push-out
29
+ * progress instead, against {@link sleepPushOutProgressSpeed}.
32
30
  * @internal
33
31
  */
34
32
  const sleepPenetrationTolerance = 3 * contactSlop;
@@ -1 +1 @@
1
- {"version":3,"file":"tolerances.js","names":[],"sources":["../../../src/solver/tolerances.ts"],"sourcesContent":["/**\n * Penetration allowance (px) the soft bias leaves uncorrected. The narrow phase\n * only produces a manifold while the colliders overlap, so pushing penetration\n * fully to zero lets a resting contact wink out for a frame (free-fall, then\n * re-detect) - a periodic energy spike. Leaving a small slop keeps the contact\n * persistently overlapping and the warm-start cache alive.\n * @internal\n */\nexport const contactSlop = 0.25;\n\n/**\n * Penetration (px) above which a contact still counts as unresolved for the\n * sleep decision, so neither of its bodies may bank sleep time.\n *\n * The solver drives every resting contact down to {@link contactSlop}, but only\n * at a capped push-out speed that is below the sleep velocity threshold: a body\n * that landed hard therefore looks motionless long before its overlap is worked\n * off, and sleeping it would freeze it visibly embedded. Both sides must read\n * the same tolerance, or the sleep gate and the constraint it is gating drift\n * apart.\n *\n * The value is empirical, not derived: a face contact converges to exactly one\n * slop at any gravity, but a single-point contact rests one static spring\n * deflection deeper, and that offset grows with gravity (0.28 px at\n * 1 000 px/s², 0.53 px at 10 000, 0.67 px at 15 000). Three slops clears that\n * envelope for the gravity range the engine is tuned for while staying far\n * below the failure it gates, which starts at several px. Beyond roughly\n * 15 000 px/s² the push-out cap binds and the resting depth stops following\n * the deflection law, settling into a narrow limit cycle just below this\n * tolerance instead - so sleep is delayed there rather than granted to an\n * embedded body.\n * @internal\n */\nexport const sleepPenetrationTolerance = 3 * contactSlop;\n"],"mappings":";;;;;;;;;AAQA,MAAa,cAAc;;;;;;;;;;;;;;;;;;;;;;;;AAyB3B,MAAa,4BAA4B,IAAI"}
1
+ {"version":3,"file":"tolerances.js","names":[],"sources":["../../../src/solver/tolerances.ts"],"sourcesContent":["/**\n * Penetration allowance (px) the soft bias leaves uncorrected. The narrow phase\n * only produces a manifold while the colliders overlap, so pushing penetration\n * fully to zero lets a resting contact wink out for a frame (free-fall, then\n * re-detect) - a periodic energy spike. Leaving a small slop keeps the contact\n * persistently overlapping and the warm-start cache alive.\n * @internal\n */\nexport const contactSlop = 0.25;\n\n/**\n * Penetration (px) below which a contact never blocks the sleep decision,\n * whatever the push-out is doing.\n *\n * The sleep gate has to consult penetration at all because the push-out moves\n * bodies through the solver's position bias, which the relax pass removes from\n * their velocity again: a body still climbing out of geometry looks motionless\n * to the velocity thresholds, and sleeping it would freeze it visibly embedded.\n * Both sides must read the same tolerance, or the sleep gate and the constraint\n * it is gating drift apart.\n *\n * The value is empirical, not derived: a face contact converges to exactly one\n * slop at any gravity, but a single-point contact rests one static spring\n * deflection deeper, and that offset grows with acceleration (0.28 px at\n * 1 000 px/s², 0.53 px at 10 000). Three slops clears that envelope for the\n * gravity range the engine is tuned for, so an ordinary resting contact is\n * settled by depth alone. Equilibria deeper than that - a loaded contact inside\n * a pile, or a lone contact at extreme acceleration - are decided on push-out\n * progress instead, against {@link sleepPushOutProgressSpeed}.\n * @internal\n */\nexport const sleepPenetrationTolerance = 3 * contactSlop;\n\n/**\n * Speed (px/s) at which an overlap deeper than {@link sleepPenetrationTolerance}\n * still counts as being worked off, so neither of its bodies may bank sleep\n * time. Below it the contact has reached the depth its own load holds it at, and\n * keeping the island awake would only re-solve a scene that has stopped moving.\n *\n * The threshold has to clear the jitter a settled scene's contacts carry while\n * staying well under the speed a genuinely converging contact shows: the soft\n * bias closes the excess beyond the slop at roughly `biasRate` per second\n * (about 9/s at the default 30 Hz over four sub-steps), so a contact converging\n * onto the tolerance is still closing at several px/s when it arrives there.\n * @internal\n */\nexport const sleepPushOutProgressSpeed = 1;\n"],"mappings":";;;;;;;;;AAQA,MAAa,cAAc;;;;;;;;;;;;;;;;;;;;;;AAuB3B,MAAa,4BAA4B,IAAI"}
@@ -1,18 +1,2 @@
1
- /**
2
- * In-place heap sort - deterministic, O(n log n) regardless of input order, and
3
- * allocation-free. `Array.prototype.sort` allocates an internal temp buffer in
4
- * V8's TimSort for arrays larger than ~10 elements; the broad-phase and contact
5
- * sorts run over ~1,000 elements every step, so that temp buffer is per-step
6
- * garbage. Heap sort sorts in place with only a constant number of locals.
7
- *
8
- * Heap sort is not stable, but every physics comparator (`byMinX`, `byPairId`,
9
- * `byRecordPair`, `byColliderPair`, `bySensorPair`) breaks ties on collider id,
10
- * so no two elements ever compare equal - the ordering is total and therefore
11
- * bit-identical to the `Array.prototype.sort` it replaces (replay
12
- * determinism). Do not use this with a comparator that can return 0 for distinct
13
- * elements; the result order would then differ from a stable sort.
14
- *
15
- * @internal
16
- */
17
- export declare const sortInPlace: <T>(array: T[], compare: (a: T, b: T) => number) => void;
1
+ export {};
18
2
  //# sourceMappingURL=sort.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../src/sort.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,KAAG,IAe5E,CAAC"}
1
+ {"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../src/sort.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codexo/exojs-physics",
3
- "version": "0.16.2",
3
+ "version": "0.18.0",
4
4
  "description": "Native 2D collision, query and sensor runtime for ExoJS.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -31,10 +31,10 @@
31
31
  "LICENSE"
32
32
  ],
33
33
  "peerDependencies": {
34
- "@codexo/exojs": "0.16.x"
34
+ "@codexo/exojs": "0.18.x"
35
35
  },
36
36
  "devDependencies": {
37
- "@codexo/exojs": "0.16.2",
37
+ "@codexo/exojs": "0.18.0",
38
38
  "@codexo/exojs-config": "0.0.0"
39
39
  },
40
40
  "license": "MIT",