CollisionData

View source

Stores the geometric result of narrowphase collision detection for one body pair.

Collision detection writes the minimum-overlap axis, tangent, penetration, and contact points here. A CollisionManifold keeps one instance and CollisionManifold.prepare reads it when building solver constraints. The default constructor creates an empty result with reusable vectors and two contact-point slots.

Examples

import { Contacts } from '@wimaengine/narrowphase'

const manifold = world.getResource(Contacts)[0]
const collision = manifold?.contactData
if (collision?.done) {
  console.log(`${collision.contactNo} contact point(s)`)
}

Constructor


constructor()

Properties


overlap: number

View source

Penetration depth selected by the SAT projection.

The narrowphase may reset this to -Infinity before testing a pair so that the smallest valid overlap can replace it. A new instance starts at 0.

Default: 0

done: boolean

View source

Whether the SAT projection found a valid overlapping result.

The narrowphase resets this flag before testing a pair and sets it after all axes produce a valid minimum-overlap result.

Default: false

axis: Vector2

View source

Collision axis selected by the minimum-overlap SAT test.

The narrowphase uses this axis as the contact normal and derives tangent from it.

Default: ...

tangent: Vector2

View source

Tangent corresponding to axis.

The narrowphase derives this vector after the collision axis is selected; the solver uses it to build tangential Jacobian constraints.

Default: ...

contactPoints: Vector2[]

View source

Reusable world-space contact-point slots.

Only the first contactNo entries are valid for the current collision. The array is initialized with two vectors because the solver supports at most two contact points for a manifold.

Default: ...

contactNo: number

View source

Number of valid entries in contactPoints.

The narrowphase sets this to 1 for circle contacts or clamps the support-point count to the range 0–2 for other shapes.

Default: 0