the-world-engine
Version:
three.js based, unity like game engine for browser
651 lines (605 loc) • 26.1 kB
JavaScript
import { b2_linearSlop, b2_maxManifoldPoints, b2_maxLinearCorrection, b2_baumgarte, b2_toiBaumgarte, b2MakeArray } from "../common/b2_settings.js";
import { b2Min, b2Max, b2Clamp, b2Vec2, b2Mat22, b2Rot, b2Transform } from "../common/b2_math.js";
import { b2WorldManifold } from "../collision/b2_collision.js";
import { b2ManifoldType } from "../collision/b2_collision.js";
import { b2TimeStep } from "./b2_time_step.js";
export let g_blockSolve = false;
export function get_g_blockSolve() {
return g_blockSolve;
}
export function set_g_blockSolve(t) {
g_blockSolve = t;
}
export class b2VelocityConstraintPoint {
constructor() {
this.rA = new b2Vec2;
this.rB = new b2Vec2;
this.normalImpulse = 0;
this.tangentImpulse = 0;
this.normalMass = 0;
this.tangentMass = 0;
this.velocityBias = 0;
}
static MakeArray(t) {
return b2MakeArray(t, (t => new b2VelocityConstraintPoint));
}
}
export class b2ContactVelocityConstraint {
constructor() {
this.points = b2VelocityConstraintPoint.MakeArray(b2_maxManifoldPoints);
this.normal = new b2Vec2;
this.tangent = new b2Vec2;
this.normalMass = new b2Mat22;
this.K = new b2Mat22;
this.indexA = 0;
this.indexB = 0;
this.invMassA = 0;
this.invMassB = 0;
this.invIA = 0;
this.invIB = 0;
this.friction = 0;
this.restitution = 0;
this.threshold = 0;
this.tangentSpeed = 0;
this.pointCount = 0;
this.contactIndex = 0;
}
static MakeArray(t) {
return b2MakeArray(t, (t => new b2ContactVelocityConstraint));
}
}
export class b2ContactPositionConstraint {
constructor() {
this.localPoints = b2Vec2.MakeArray(b2_maxManifoldPoints);
this.localNormal = new b2Vec2;
this.localPoint = new b2Vec2;
this.indexA = 0;
this.indexB = 0;
this.invMassA = 0;
this.invMassB = 0;
this.localCenterA = new b2Vec2;
this.localCenterB = new b2Vec2;
this.invIA = 0;
this.invIB = 0;
this.type = b2ManifoldType.e_unknown;
this.radiusA = 0;
this.radiusB = 0;
this.pointCount = 0;
}
static MakeArray(t) {
return b2MakeArray(t, (t => new b2ContactPositionConstraint));
}
}
export class b2ContactSolverDef {
constructor() {
this.step = new b2TimeStep;
this.count = 0;
}
}
export class b2PositionSolverManifold {
constructor() {
this.normal = new b2Vec2;
this.point = new b2Vec2;
this.separation = 0;
}
Initialize(t, o, c, e) {
const n = b2PositionSolverManifold.Initialize_s_pointA;
const s = b2PositionSolverManifold.Initialize_s_pointB;
const b = b2PositionSolverManifold.Initialize_s_planePoint;
const i = b2PositionSolverManifold.Initialize_s_clipPoint;
switch (t.type) {
case b2ManifoldType.e_circles:
{
b2Transform.MulXV(o, t.localPoint, n);
b2Transform.MulXV(c, t.localPoints[0], s);
b2Vec2.SubVV(s, n, this.normal).SelfNormalize();
b2Vec2.MidVV(n, s, this.point);
this.separation = b2Vec2.DotVV(b2Vec2.SubVV(s, n, b2Vec2.s_t0), this.normal) - t.radiusA - t.radiusB;
break;
}
case b2ManifoldType.e_faceA:
{
b2Rot.MulRV(o.q, t.localNormal, this.normal);
b2Transform.MulXV(o, t.localPoint, b);
b2Transform.MulXV(c, t.localPoints[e], i);
this.separation = b2Vec2.DotVV(b2Vec2.SubVV(i, b, b2Vec2.s_t0), this.normal) - t.radiusA - t.radiusB;
this.point.Copy(i);
break;
}
case b2ManifoldType.e_faceB:
{
b2Rot.MulRV(c.q, t.localNormal, this.normal);
b2Transform.MulXV(c, t.localPoint, b);
b2Transform.MulXV(o, t.localPoints[e], i);
this.separation = b2Vec2.DotVV(b2Vec2.SubVV(i, b, b2Vec2.s_t0), this.normal) - t.radiusA - t.radiusB;
this.point.Copy(i);
this.normal.SelfNeg();
break;
}
}
}
}
b2PositionSolverManifold.Initialize_s_pointA = new b2Vec2;
b2PositionSolverManifold.Initialize_s_pointB = new b2Vec2;
b2PositionSolverManifold.Initialize_s_planePoint = new b2Vec2;
b2PositionSolverManifold.Initialize_s_clipPoint = new b2Vec2;
export class b2ContactSolver {
constructor() {
this.m_step = new b2TimeStep;
this.m_positionConstraints = b2ContactPositionConstraint.MakeArray(1024);
this.m_velocityConstraints = b2ContactVelocityConstraint.MakeArray(1024);
this.m_count = 0;
}
Initialize(t) {
this.m_step.Copy(t.step);
this.m_count = t.count;
if (this.m_positionConstraints.length < this.m_count) {
const t = b2Max(this.m_positionConstraints.length * 2, this.m_count);
while (this.m_positionConstraints.length < t) {
this.m_positionConstraints[this.m_positionConstraints.length] = new b2ContactPositionConstraint;
}
}
if (this.m_velocityConstraints.length < this.m_count) {
const t = b2Max(this.m_velocityConstraints.length * 2, this.m_count);
while (this.m_velocityConstraints.length < t) {
this.m_velocityConstraints[this.m_velocityConstraints.length] = new b2ContactVelocityConstraint;
}
}
this.m_positions = t.positions;
this.m_velocities = t.velocities;
this.m_contacts = t.contacts;
for (let t = 0; t < this.m_count; ++t) {
const o = this.m_contacts[t];
const c = o.m_fixtureA;
const e = o.m_fixtureB;
const n = c.GetShape();
const s = e.GetShape();
const b = n.m_radius;
const i = s.m_radius;
const r = c.GetBody();
const a = e.GetBody();
const l = o.GetManifold();
const V = l.pointCount;
const h = this.m_velocityConstraints[t];
h.friction = o.m_friction;
h.restitution = o.m_restitution;
h.threshold = o.m_restitutionThreshold;
h.tangentSpeed = o.m_tangentSpeed;
h.indexA = r.m_islandIndex;
h.indexB = a.m_islandIndex;
h.invMassA = r.m_invMass;
h.invMassB = a.m_invMass;
h.invIA = r.m_invI;
h.invIB = a.m_invI;
h.contactIndex = t;
h.pointCount = V;
h.K.SetZero();
h.normalMass.SetZero();
const S = this.m_positionConstraints[t];
S.indexA = r.m_islandIndex;
S.indexB = a.m_islandIndex;
S.invMassA = r.m_invMass;
S.invMassB = a.m_invMass;
S.localCenterA.Copy(r.m_sweep.localCenter);
S.localCenterB.Copy(a.m_sweep.localCenter);
S.invIA = r.m_invI;
S.invIB = a.m_invI;
S.localNormal.Copy(l.localNormal);
S.localPoint.Copy(l.localPoint);
S.pointCount = V;
S.radiusA = b;
S.radiusB = i;
S.type = l.type;
for (let t = 0; t < V; ++t) {
const o = l.points[t];
const c = h.points[t];
if (this.m_step.warmStarting) {
c.normalImpulse = this.m_step.dtRatio * o.normalImpulse;
c.tangentImpulse = this.m_step.dtRatio * o.tangentImpulse;
} else {
c.normalImpulse = 0;
c.tangentImpulse = 0;
}
c.rA.SetZero();
c.rB.SetZero();
c.normalMass = 0;
c.tangentMass = 0;
c.velocityBias = 0;
S.localPoints[t].Copy(o.localPoint);
}
}
return this;
}
InitializeVelocityConstraints() {
const t = b2ContactSolver.InitializeVelocityConstraints_s_xfA;
const o = b2ContactSolver.InitializeVelocityConstraints_s_xfB;
const c = b2ContactSolver.InitializeVelocityConstraints_s_worldManifold;
const e = 1e3;
for (let n = 0; n < this.m_count; ++n) {
const s = this.m_velocityConstraints[n];
const b = this.m_positionConstraints[n];
const i = b.radiusA;
const r = b.radiusB;
const a = this.m_contacts[s.contactIndex].GetManifold();
const l = s.indexA;
const V = s.indexB;
const h = s.invMassA;
const S = s.invMassB;
const C = s.invIA;
const v = s.invIB;
const f = b.localCenterA;
const w = b.localCenterB;
const m = this.m_positions[l].c;
const M = this.m_positions[l].a;
const p = this.m_velocities[l].v;
const _ = this.m_velocities[l].w;
const d = this.m_positions[V].c;
const P = this.m_positions[V].a;
const k = this.m_velocities[V].v;
const T = this.m_velocities[V].w;
t.q.SetAngle(M);
o.q.SetAngle(P);
b2Vec2.SubVV(m, b2Rot.MulRV(t.q, f, b2Vec2.s_t0), t.p);
b2Vec2.SubVV(d, b2Rot.MulRV(o.q, w, b2Vec2.s_t0), o.p);
c.Initialize(a, t, i, o, r);
s.normal.Copy(c.normal);
b2Vec2.CrossVOne(s.normal, s.tangent);
const y = s.pointCount;
for (let t = 0; t < y; ++t) {
const o = s.points[t];
b2Vec2.SubVV(c.points[t], m, o.rA);
b2Vec2.SubVV(c.points[t], d, o.rB);
const e = b2Vec2.CrossVV(o.rA, s.normal);
const n = b2Vec2.CrossVV(o.rB, s.normal);
const b = h + S + C * e * e + v * n * n;
o.normalMass = b > 0 ? 1 / b : 0;
const i = s.tangent;
const r = b2Vec2.CrossVV(o.rA, i);
const a = b2Vec2.CrossVV(o.rB, i);
const l = h + S + C * r * r + v * a * a;
o.tangentMass = l > 0 ? 1 / l : 0;
o.velocityBias = 0;
const V = b2Vec2.DotVV(s.normal, b2Vec2.SubVV(b2Vec2.AddVCrossSV(k, T, o.rB, b2Vec2.s_t0), b2Vec2.AddVCrossSV(p, _, o.rA, b2Vec2.s_t1), b2Vec2.s_t0));
if (V < -s.threshold) {
o.velocityBias += -s.restitution * V;
}
}
if (s.pointCount === 2 && g_blockSolve) {
const t = s.points[0];
const o = s.points[1];
const c = b2Vec2.CrossVV(t.rA, s.normal);
const n = b2Vec2.CrossVV(t.rB, s.normal);
const b = b2Vec2.CrossVV(o.rA, s.normal);
const i = b2Vec2.CrossVV(o.rB, s.normal);
const r = h + S + C * c * c + v * n * n;
const a = h + S + C * b * b + v * i * i;
const l = h + S + C * c * b + v * n * i;
if (r * r < e * (r * a - l * l)) {
s.K.ex.Set(r, l);
s.K.ey.Set(l, a);
s.K.GetInverse(s.normalMass);
} else {
s.pointCount = 1;
}
}
}
}
WarmStart() {
const t = b2ContactSolver.WarmStart_s_P;
for (let o = 0; o < this.m_count; ++o) {
const c = this.m_velocityConstraints[o];
const e = c.indexA;
const n = c.indexB;
const s = c.invMassA;
const b = c.invIA;
const i = c.invMassB;
const r = c.invIB;
const a = c.pointCount;
const l = this.m_velocities[e].v;
let V = this.m_velocities[e].w;
const h = this.m_velocities[n].v;
let S = this.m_velocities[n].w;
const C = c.normal;
const v = c.tangent;
for (let o = 0; o < a; ++o) {
const e = c.points[o];
b2Vec2.AddVV(b2Vec2.MulSV(e.normalImpulse, C, b2Vec2.s_t0), b2Vec2.MulSV(e.tangentImpulse, v, b2Vec2.s_t1), t);
V -= b * b2Vec2.CrossVV(e.rA, t);
l.SelfMulSub(s, t);
S += r * b2Vec2.CrossVV(e.rB, t);
h.SelfMulAdd(i, t);
}
this.m_velocities[e].w = V;
this.m_velocities[n].w = S;
}
}
SolveVelocityConstraints() {
const t = b2ContactSolver.SolveVelocityConstraints_s_dv;
const o = b2ContactSolver.SolveVelocityConstraints_s_dv1;
const c = b2ContactSolver.SolveVelocityConstraints_s_dv2;
const e = b2ContactSolver.SolveVelocityConstraints_s_P;
const n = b2ContactSolver.SolveVelocityConstraints_s_a;
const s = b2ContactSolver.SolveVelocityConstraints_s_b;
const b = b2ContactSolver.SolveVelocityConstraints_s_x;
const i = b2ContactSolver.SolveVelocityConstraints_s_d;
const r = b2ContactSolver.SolveVelocityConstraints_s_P1;
const a = b2ContactSolver.SolveVelocityConstraints_s_P2;
const l = b2ContactSolver.SolveVelocityConstraints_s_P1P2;
for (let V = 0; V < this.m_count; ++V) {
const h = this.m_velocityConstraints[V];
const S = h.indexA;
const C = h.indexB;
const v = h.invMassA;
const f = h.invIA;
const w = h.invMassB;
const m = h.invIB;
const M = h.pointCount;
const p = this.m_velocities[S].v;
let _ = this.m_velocities[S].w;
const d = this.m_velocities[C].v;
let P = this.m_velocities[C].w;
const k = h.normal;
const T = h.tangent;
const y = h.friction;
for (let o = 0; o < M; ++o) {
const c = h.points[o];
b2Vec2.SubVV(b2Vec2.AddVCrossSV(d, P, c.rB, b2Vec2.s_t0), b2Vec2.AddVCrossSV(p, _, c.rA, b2Vec2.s_t1), t);
const n = b2Vec2.DotVV(t, T) - h.tangentSpeed;
let s = c.tangentMass * -n;
const b = y * c.normalImpulse;
const i = b2Clamp(c.tangentImpulse + s, -b, b);
s = i - c.tangentImpulse;
c.tangentImpulse = i;
b2Vec2.MulSV(s, T, e);
p.SelfMulSub(v, e);
_ -= f * b2Vec2.CrossVV(c.rA, e);
d.SelfMulAdd(w, e);
P += m * b2Vec2.CrossVV(c.rB, e);
}
if (h.pointCount === 1 || g_blockSolve === false) {
for (let o = 0; o < M; ++o) {
const c = h.points[o];
b2Vec2.SubVV(b2Vec2.AddVCrossSV(d, P, c.rB, b2Vec2.s_t0), b2Vec2.AddVCrossSV(p, _, c.rA, b2Vec2.s_t1), t);
const n = b2Vec2.DotVV(t, k);
let s = -c.normalMass * (n - c.velocityBias);
const b = b2Max(c.normalImpulse + s, 0);
s = b - c.normalImpulse;
c.normalImpulse = b;
b2Vec2.MulSV(s, k, e);
p.SelfMulSub(v, e);
_ -= f * b2Vec2.CrossVV(c.rA, e);
d.SelfMulAdd(w, e);
P += m * b2Vec2.CrossVV(c.rB, e);
}
} else {
const t = h.points[0];
const e = h.points[1];
n.Set(t.normalImpulse, e.normalImpulse);
b2Vec2.SubVV(b2Vec2.AddVCrossSV(d, P, t.rB, b2Vec2.s_t0), b2Vec2.AddVCrossSV(p, _, t.rA, b2Vec2.s_t1), o);
b2Vec2.SubVV(b2Vec2.AddVCrossSV(d, P, e.rB, b2Vec2.s_t0), b2Vec2.AddVCrossSV(p, _, e.rA, b2Vec2.s_t1), c);
let V = b2Vec2.DotVV(o, k);
let S = b2Vec2.DotVV(c, k);
s.x = V - t.velocityBias;
s.y = S - e.velocityBias;
s.SelfSub(b2Mat22.MulMV(h.K, n, b2Vec2.s_t0));
for (;;) {
b2Mat22.MulMV(h.normalMass, s, b).SelfNeg();
if (b.x >= 0 && b.y >= 0) {
b2Vec2.SubVV(b, n, i);
b2Vec2.MulSV(i.x, k, r);
b2Vec2.MulSV(i.y, k, a);
b2Vec2.AddVV(r, a, l);
p.SelfMulSub(v, l);
_ -= f * (b2Vec2.CrossVV(t.rA, r) + b2Vec2.CrossVV(e.rA, a));
d.SelfMulAdd(w, l);
P += m * (b2Vec2.CrossVV(t.rB, r) + b2Vec2.CrossVV(e.rB, a));
t.normalImpulse = b.x;
e.normalImpulse = b.y;
break;
}
b.x = -t.normalMass * s.x;
b.y = 0;
V = 0;
S = h.K.ex.y * b.x + s.y;
if (b.x >= 0 && S >= 0) {
b2Vec2.SubVV(b, n, i);
b2Vec2.MulSV(i.x, k, r);
b2Vec2.MulSV(i.y, k, a);
b2Vec2.AddVV(r, a, l);
p.SelfMulSub(v, l);
_ -= f * (b2Vec2.CrossVV(t.rA, r) + b2Vec2.CrossVV(e.rA, a));
d.SelfMulAdd(w, l);
P += m * (b2Vec2.CrossVV(t.rB, r) + b2Vec2.CrossVV(e.rB, a));
t.normalImpulse = b.x;
e.normalImpulse = b.y;
break;
}
b.x = 0;
b.y = -e.normalMass * s.y;
V = h.K.ey.x * b.y + s.x;
S = 0;
if (b.y >= 0 && V >= 0) {
b2Vec2.SubVV(b, n, i);
b2Vec2.MulSV(i.x, k, r);
b2Vec2.MulSV(i.y, k, a);
b2Vec2.AddVV(r, a, l);
p.SelfMulSub(v, l);
_ -= f * (b2Vec2.CrossVV(t.rA, r) + b2Vec2.CrossVV(e.rA, a));
d.SelfMulAdd(w, l);
P += m * (b2Vec2.CrossVV(t.rB, r) + b2Vec2.CrossVV(e.rB, a));
t.normalImpulse = b.x;
e.normalImpulse = b.y;
break;
}
b.x = 0;
b.y = 0;
V = s.x;
S = s.y;
if (V >= 0 && S >= 0) {
b2Vec2.SubVV(b, n, i);
b2Vec2.MulSV(i.x, k, r);
b2Vec2.MulSV(i.y, k, a);
b2Vec2.AddVV(r, a, l);
p.SelfMulSub(v, l);
_ -= f * (b2Vec2.CrossVV(t.rA, r) + b2Vec2.CrossVV(e.rA, a));
d.SelfMulAdd(w, l);
P += m * (b2Vec2.CrossVV(t.rB, r) + b2Vec2.CrossVV(e.rB, a));
t.normalImpulse = b.x;
e.normalImpulse = b.y;
break;
}
break;
}
}
this.m_velocities[S].w = _;
this.m_velocities[C].w = P;
}
}
StoreImpulses() {
for (let t = 0; t < this.m_count; ++t) {
const o = this.m_velocityConstraints[t];
const c = this.m_contacts[o.contactIndex].GetManifold();
for (let t = 0; t < o.pointCount; ++t) {
c.points[t].normalImpulse = o.points[t].normalImpulse;
c.points[t].tangentImpulse = o.points[t].tangentImpulse;
}
}
}
SolvePositionConstraints() {
const t = b2ContactSolver.SolvePositionConstraints_s_xfA;
const o = b2ContactSolver.SolvePositionConstraints_s_xfB;
const c = b2ContactSolver.SolvePositionConstraints_s_psm;
const e = b2ContactSolver.SolvePositionConstraints_s_rA;
const n = b2ContactSolver.SolvePositionConstraints_s_rB;
const s = b2ContactSolver.SolvePositionConstraints_s_P;
let b = 0;
for (let i = 0; i < this.m_count; ++i) {
const r = this.m_positionConstraints[i];
const a = r.indexA;
const l = r.indexB;
const V = r.localCenterA;
const h = r.invMassA;
const S = r.invIA;
const C = r.localCenterB;
const v = r.invMassB;
const f = r.invIB;
const w = r.pointCount;
const m = this.m_positions[a].c;
let M = this.m_positions[a].a;
const p = this.m_positions[l].c;
let _ = this.m_positions[l].a;
for (let i = 0; i < w; ++i) {
t.q.SetAngle(M);
o.q.SetAngle(_);
b2Vec2.SubVV(m, b2Rot.MulRV(t.q, V, b2Vec2.s_t0), t.p);
b2Vec2.SubVV(p, b2Rot.MulRV(o.q, C, b2Vec2.s_t0), o.p);
c.Initialize(r, t, o, i);
const a = c.normal;
const l = c.point;
const w = c.separation;
b2Vec2.SubVV(l, m, e);
b2Vec2.SubVV(l, p, n);
b = b2Min(b, w);
const d = b2Clamp(b2_baumgarte * (w + b2_linearSlop), -b2_maxLinearCorrection, 0);
const P = b2Vec2.CrossVV(e, a);
const k = b2Vec2.CrossVV(n, a);
const T = h + v + S * P * P + f * k * k;
const y = T > 0 ? -d / T : 0;
b2Vec2.MulSV(y, a, s);
m.SelfMulSub(h, s);
M -= S * b2Vec2.CrossVV(e, s);
p.SelfMulAdd(v, s);
_ += f * b2Vec2.CrossVV(n, s);
}
this.m_positions[a].a = M;
this.m_positions[l].a = _;
}
return b > -3 * b2_linearSlop;
}
SolveTOIPositionConstraints(t, o) {
const c = b2ContactSolver.SolveTOIPositionConstraints_s_xfA;
const e = b2ContactSolver.SolveTOIPositionConstraints_s_xfB;
const n = b2ContactSolver.SolveTOIPositionConstraints_s_psm;
const s = b2ContactSolver.SolveTOIPositionConstraints_s_rA;
const b = b2ContactSolver.SolveTOIPositionConstraints_s_rB;
const i = b2ContactSolver.SolveTOIPositionConstraints_s_P;
let r = 0;
for (let a = 0; a < this.m_count; ++a) {
const l = this.m_positionConstraints[a];
const V = l.indexA;
const h = l.indexB;
const S = l.localCenterA;
const C = l.localCenterB;
const v = l.pointCount;
let f = 0;
let w = 0;
if (V === t || V === o) {
f = l.invMassA;
w = l.invIA;
}
let m = 0;
let M = 0;
if (h === t || h === o) {
m = l.invMassB;
M = l.invIB;
}
const p = this.m_positions[V].c;
let _ = this.m_positions[V].a;
const d = this.m_positions[h].c;
let P = this.m_positions[h].a;
for (let t = 0; t < v; ++t) {
c.q.SetAngle(_);
e.q.SetAngle(P);
b2Vec2.SubVV(p, b2Rot.MulRV(c.q, S, b2Vec2.s_t0), c.p);
b2Vec2.SubVV(d, b2Rot.MulRV(e.q, C, b2Vec2.s_t0), e.p);
n.Initialize(l, c, e, t);
const o = n.normal;
const a = n.point;
const V = n.separation;
b2Vec2.SubVV(a, p, s);
b2Vec2.SubVV(a, d, b);
r = b2Min(r, V);
const h = b2Clamp(b2_toiBaumgarte * (V + b2_linearSlop), -b2_maxLinearCorrection, 0);
const v = b2Vec2.CrossVV(s, o);
const k = b2Vec2.CrossVV(b, o);
const T = f + m + w * v * v + M * k * k;
const y = T > 0 ? -h / T : 0;
b2Vec2.MulSV(y, o, i);
p.SelfMulSub(f, i);
_ -= w * b2Vec2.CrossVV(s, i);
d.SelfMulAdd(m, i);
P += M * b2Vec2.CrossVV(b, i);
}
this.m_positions[V].a = _;
this.m_positions[h].a = P;
}
return r >= -1.5 * b2_linearSlop;
}
}
b2ContactSolver.InitializeVelocityConstraints_s_xfA = new b2Transform;
b2ContactSolver.InitializeVelocityConstraints_s_xfB = new b2Transform;
b2ContactSolver.InitializeVelocityConstraints_s_worldManifold = new b2WorldManifold;
b2ContactSolver.WarmStart_s_P = new b2Vec2;
b2ContactSolver.SolveVelocityConstraints_s_dv = new b2Vec2;
b2ContactSolver.SolveVelocityConstraints_s_dv1 = new b2Vec2;
b2ContactSolver.SolveVelocityConstraints_s_dv2 = new b2Vec2;
b2ContactSolver.SolveVelocityConstraints_s_P = new b2Vec2;
b2ContactSolver.SolveVelocityConstraints_s_a = new b2Vec2;
b2ContactSolver.SolveVelocityConstraints_s_b = new b2Vec2;
b2ContactSolver.SolveVelocityConstraints_s_x = new b2Vec2;
b2ContactSolver.SolveVelocityConstraints_s_d = new b2Vec2;
b2ContactSolver.SolveVelocityConstraints_s_P1 = new b2Vec2;
b2ContactSolver.SolveVelocityConstraints_s_P2 = new b2Vec2;
b2ContactSolver.SolveVelocityConstraints_s_P1P2 = new b2Vec2;
b2ContactSolver.SolvePositionConstraints_s_xfA = new b2Transform;
b2ContactSolver.SolvePositionConstraints_s_xfB = new b2Transform;
b2ContactSolver.SolvePositionConstraints_s_psm = new b2PositionSolverManifold;
b2ContactSolver.SolvePositionConstraints_s_rA = new b2Vec2;
b2ContactSolver.SolvePositionConstraints_s_rB = new b2Vec2;
b2ContactSolver.SolvePositionConstraints_s_P = new b2Vec2;
b2ContactSolver.SolveTOIPositionConstraints_s_xfA = new b2Transform;
b2ContactSolver.SolveTOIPositionConstraints_s_xfB = new b2Transform;
b2ContactSolver.SolveTOIPositionConstraints_s_psm = new b2PositionSolverManifold;
b2ContactSolver.SolveTOIPositionConstraints_s_rA = new b2Vec2;
b2ContactSolver.SolveTOIPositionConstraints_s_rB = new b2Vec2;
b2ContactSolver.SolveTOIPositionConstraints_s_P = new b2Vec2;