Class: Manifold
physics/manifold.Manifold
Information about a collision which has occured between two objects.
Constructors
constructor
โข new Manifold(a
, b
, collision
, gravity
, delta
)
Creates a Manifold describing a collision between a and b in detail.
Parameters
Name | Type | Description |
---|---|---|
a | CollisionObject | First collision object |
b | CollisionObject | Second collision object |
collision | CollisionResult | CollisionResult from collision test |
gravity | vec2 | The collision world's gravity vector |
delta | number | The time since the last update |
Defined in
src/physics/manifold.ts:103
Properties
a
โข a: CollisionObject
An object in the collision.
Defined in
src/physics/manifold.ts:40
b
โข b: CollisionObject
Another object in the collision.
Defined in
src/physics/manifold.ts:45
contactPoints
โข contactPoints: ContactPoint
[]
The contact points of the collision.
Defined in
src/physics/manifold.ts:80
depth
โข depth: number
The penetration depth of the collision.
Defined in
src/physics/manifold.ts:50
df
โข df: number
dynamic friction scalar.
Defined in
src/physics/manifold.ts:75
edges
โข edges: Edge
[] = []
store used edges [inc, ref]
Defined in
src/physics/manifold.ts:85
epsilon
โข epsilon: number
Minimum restitution between a and b.
Defined in
src/physics/manifold.ts:65
isDead
โข isDead: boolean
= false
Defined in
src/physics/manifold.ts:92
normal
โข normal: vec2
The collision normal, should always point from a to b.
Defined in
src/physics/manifold.ts:55
penetration
โข penetration: vec2
The penetration vector, this is the collision normal scaled by the penetration depth.
Defined in
src/physics/manifold.ts:60
positionImpulse
โข positionImpulse: Object
Type declaration
Name | Type |
---|---|
a | vec2 |
b | vec2 |
Defined in
src/physics/manifold.ts:87
sf
โข sf: number
static friction scalar.
Defined in
src/physics/manifold.ts:70
Methods
bestEdge
โธ Private
bestEdge(obj
, direction
): Edge
Finds the best edge of a CollisionObject in a given direction.
The best edge is defined as the edge most perpendicular to the given direction.
Parameters
Name | Type | Description |
---|---|---|
obj | CollisionObject | The collision object to calculate the edge for |
direction | vec2 | The direction in which to calculate the edge |
Returns
Edge
The best edge of obj
for the direction given
Defined in
src/physics/manifold.ts:461
calculateContactPoints
โธ Private
calculateContactPoints(): ContactPoint
[]
Calculates the contact points of the collision.
Returns
The points of contact for the collision
Defined in
src/physics/manifold.ts:362
clipPoints
โธ Private
clipPoints(p0
, p1
, direction
, o
): ContactPoint
[]
Clips the edge points (p0, p1) if they are past o along the direction.
Parameters
Name | Type | Description |
---|---|---|
p0 | ContactPoint | The first point to clip |
p1 | ContactPoint | The second point to clip |
direction | vec2 | The direction to clip in |
o | number | The vector to clip past |
Returns
Defined in
src/physics/manifold.ts:499
compareContacts
โธ Private
compareContacts(c1
, c2
): boolean
Compares two contact points using a distance heuristic to determine wether they should be considered the same contact.
Parameters
Name | Type | Description |
---|---|---|
c1 | ContactPoint | A contact point |
c2 | ContactPoint | A contact point |
Returns
boolean
If the 2 contact points match
Defined in
src/physics/manifold.ts:227
kill
โธ kill(): void
Marks the manifold as dead and decrements the objects involved's totalContacts
counts.
Returns
void
Defined in
src/physics/manifold.ts:236
mergeManifold
โธ Private
mergeManifold(m
, contacts
): void
Merge this manifold with the given manifold and contact points.
Parameters
Name | Type | Description |
---|---|---|
m | Manifold | The manifold to merge with |
contacts | ContactPoint [] | The manifold's new contact points |
Returns
void
Defined in
src/physics/manifold.ts:205
preStepImpulse
โธ preStepImpulse(delta
): void
Precompute some additional information about the contact points for impulse resolution.
Calculates and applies accumulative impulse.
Parameters
Name | Type | Description |
---|---|---|
delta | number | The time since the last udpate |
Returns
void
Defined in
src/physics/manifold.ts:296
solvePositionImpulse
โธ solvePositionImpulse(delta
): void
Calculates the position impulse for objects a
and b
in the manifold.
Parameters
Name | Type | Description |
---|---|---|
delta | number | The time since the last update |
Returns
void
Defined in
src/physics/manifold.ts:251
translateEdge
โธ Private
translateEdge(edge
, v
): void
Translates the provided edge by the given vector.
Parameters
Name | Type | Description |
---|---|---|
edge | Edge | The edge to translate |
v | vec2 | The vector to translate by |
Returns
void
Defined in
src/physics/manifold.ts:550
translateIncEdge
โธ translateIncEdge(v
): void
Translates the manifold's incident edge by the given vector.
Parameters
Name | Type | Description |
---|---|---|
v | vec2 | The vector to translate by |
Returns
void
Defined in
src/physics/manifold.ts:540
update
โธ update(m
): void
Parameters
Name | Type |
---|---|
m | Manifold |
Returns
void
Defined in
src/physics/manifold.ts:158