Skip to content

1681-engine / index / Contact

Class: Contact ​

Defined in: src/physics/Contact.ts:35

One touching pair, kept from step to step while they touch: the impulses it ended the last step with start the next one (warm starting), which is what lets a stack settle in a few solver iterations instead of shivering.

Implements ​

Constructors ​

Constructor ​

ts
new Contact(
   a, 
   b, 
   key
): Contact;

Defined in: src/physics/Contact.ts:51

Parameters ​

ParameterType
aBody
bBody
keynumber

Returns ​

Contact

Properties ​

a ​

ts
readonly a: Body;

Defined in: src/physics/Contact.ts:52

Implementation of ​

ContactInfo.a


b ​

ts
readonly b: Body;

Defined in: src/physics/Contact.ts:53

Implementation of ​

ContactInfo.b


count ​

ts
count: number = 0;

Defined in: src/physics/Contact.ts:41


depth ​

ts
depth: number = 0;

Defined in: src/physics/Contact.ts:38

Overlap along the normal, px (slightly negative while resting just apart).

Implementation of ​

ContactInfo.depth


enabled ​

ts
enabled: boolean = true;

Defined in: src/physics/Contact.ts:44

Solved this sub-step (false when the pre-solve hook turned it off).


key ​

ts
readonly key: number;

Defined in: src/physics/Contact.ts:54


mu ​

ts
mu: number = 0;

Defined in: src/physics/Contact.ts:42


nx ​

ts
nx: number = 0;

Defined in: src/physics/Contact.ts:36

Implementation of ​

ContactInfo.nx


ny ​

ts
ny: number = 1;

Defined in: src/physics/Contact.ts:37

Implementation of ​

ContactInfo.ny


pts ​

ts
readonly pts: [ContactPoint, ContactPoint];

Defined in: src/physics/Contact.ts:40

One or two points; only the first count are in use.


reported ​

ts
reported: boolean = false;

Defined in: src/physics/Contact.ts:49

Reported as touching (a begin went out and no end yet).


seenStep ​

ts
seenStep: number = -1;

Defined in: src/physics/Contact.ts:46

The world step and sub-step that last found it.


seenSub ​

ts
seenSub: number = -1;

Defined in: src/physics/Contact.ts:47

Accessors ​

normalImpulse ​

Get Signature ​

ts
get normalImpulse(): number;

Defined in: src/physics/Contact.ts:69

Accumulated normal impulse over the points: how hard the pair pressed together on the last sub-step.

Returns ​

number


points ​

Get Signature ​

ts
get points(): Vec2[];

Defined in: src/physics/Contact.ts:62

Where the two touch, world px.

Returns ​

Vec2[]

Where the two touch, world px: one or two points (two where an edge lies along an edge).

Implementation of ​

ContactInfo.points


sensor ​

Get Signature ​

ts
get sensor(): boolean;

Defined in: src/physics/Contact.ts:57

Either body is a sensor: reported, never resolved.

Returns ​

boolean

Either body is a sensor: reported, never resolved.

Implementation of ​

ContactInfo.sensor

Methods ​

other() ​

ts
other(body): Body;

Defined in: src/physics/Contact.ts:76

The other body of the pair.

Parameters ​

ParameterType
bodyBody

Returns ​

Body


keyOf() ​

ts
static keyOf(a, b): number;

Defined in: src/physics/Contact.ts:81

A stable number for the pair, whichever order it is asked in.

Parameters ​

ParameterType
aBody
bBody

Returns ​

number

Released under the MIT License.