Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/remove unused functions params and values to improve code readability and performance #299

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
16 changes: 8 additions & 8 deletions dist/planck-with-testbed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1442,12 +1442,12 @@ declare class Contact {
endContact(contact: Contact): void;
preSolve(contact: Contact, oldManifold: Manifold): void;
}): void;
solvePositionConstraint(step: TimeStep): number;
solvePositionConstraintTOI(step: TimeStep, toiA: Body, toiB: Body): number;
solvePositionConstraint(): number;
solvePositionConstraintTOI(toiA: Body, toiB: Body): number;
private _solvePositionConstraint;
initVelocityConstraint(step: TimeStep): void;
warmStartConstraint(step: TimeStep): void;
storeConstraintImpulses(step: TimeStep): void;
warmStartConstraint(): void;
storeConstraintImpulses(): void;
solveVelocityConstraint(step: TimeStep): void;
}
type BodyType = "static" | "kinematic" | "dynamic";
Expand Down Expand Up @@ -5766,12 +5766,12 @@ declare namespace planck {
endContact(contact: Contact): void;
preSolve(contact: Contact, oldManifold: Manifold): void;
}): void;
solvePositionConstraint(step: TimeStep): number;
solvePositionConstraintTOI(step: TimeStep, toiA: Body, toiB: Body): number;
solvePositionConstraint(): number;
solvePositionConstraintTOI(toiA: Body, toiB: Body): number;
private _solvePositionConstraint;
initVelocityConstraint(step: TimeStep): void;
warmStartConstraint(step: TimeStep): void;
storeConstraintImpulses(step: TimeStep): void;
warmStartConstraint(): void;
storeConstraintImpulses(): void;
solveVelocityConstraint(step: TimeStep): void;
}
type BodyType = "static" | "kinematic" | "dynamic";
Expand Down
40 changes: 11 additions & 29 deletions dist/planck-with-testbed.js
Original file line number Diff line number Diff line change
Expand Up @@ -4826,7 +4826,6 @@
Simplex.prototype.getSearchDirection = function () {
var v1 = this.m_v1;
var v2 = this.m_v2;
this.m_v3;
switch (this.m_count) {
case 1:
return setVec2(searchDirection_reuse, -v1.w.x, -v1.w.y);
Expand All @@ -4849,7 +4848,6 @@
Simplex.prototype.getClosestPoint = function () {
var v1 = this.m_v1;
var v2 = this.m_v2;
this.m_v3;
switch (this.m_count) {
case 0:
return zeroVec2(closestPoint_reuse);
Expand Down Expand Up @@ -5946,7 +5944,7 @@
// Warm start.
for (var i = 0; i < this.m_contacts.length; ++i) {
var contact = this.m_contacts[i];
contact.warmStartConstraint(step);
contact.warmStartConstraint();
}
}
for (var i = 0; i < this.m_joints.length; ++i) {
Expand All @@ -5967,7 +5965,7 @@
// Store impulses for warm starting
for (var i = 0; i < this.m_contacts.length; ++i) {
var contact = this.m_contacts[i];
contact.storeConstraintImpulses(step);
contact.storeConstraintImpulses();
}
// Integrate positions
for (var i = 0; i < this.m_bodies.length; ++i) {
Expand Down Expand Up @@ -6002,7 +6000,7 @@
var minSeparation = 0.0;
for (var j = 0; j < this.m_contacts.length; ++j) {
var contact = this.m_contacts[j];
var separation = contact.solvePositionConstraint(step);
var separation = contact.solvePositionConstraint();
minSeparation = math_min$6(minSeparation, separation);
}
// We can't expect minSpeparation >= -Settings.linearSlop because we don't
Expand Down Expand Up @@ -6129,8 +6127,6 @@
}
var indexA = c_3.getChildIndexA();
var indexB = c_3.getChildIndexB();
bA_1.m_sweep;
bB_1.m_sweep;
// Compute the time of impact in interval [0, minTOI]
input.proxyA.set(fA_1.getShape(), indexA);
input.proxyB.set(fB_1.getShape(), indexB);
Expand Down Expand Up @@ -6295,7 +6291,7 @@
var minSeparation = 0.0;
for (var j = 0; j < this.m_contacts.length; ++j) {
var contact = this.m_contacts[j];
var separation = contact.solvePositionConstraintTOI(subStep, toiA, toiB);
var separation = contact.solvePositionConstraintTOI(toiA, toiB);
minSeparation = math_min$6(minSeparation, separation);
}
// We can't expect minSpeparation >= -Settings.linearSlop because we don't
Expand Down Expand Up @@ -7452,13 +7448,13 @@
listener.preSolve(this, oldManifold);
}
};
Contact.prototype.solvePositionConstraint = function (step) {
return this._solvePositionConstraint(step, null, null);
Contact.prototype.solvePositionConstraint = function () {
return this._solvePositionConstraint(null, null);
};
Contact.prototype.solvePositionConstraintTOI = function (step, toiA, toiB) {
return this._solvePositionConstraint(step, toiA, toiB);
Contact.prototype.solvePositionConstraintTOI = function (toiA, toiB) {
return this._solvePositionConstraint(toiA, toiB);
};
Contact.prototype._solvePositionConstraint = function (step, toiA, toiB) {
Contact.prototype._solvePositionConstraint = function (toiA, toiB) {
var toi = toiA !== null && toiB !== null ? true : false;
var minSeparation = 0.0;
var fixtureA = this.m_fixtureA;
Expand All @@ -7469,8 +7465,6 @@
var bodyB = fixtureB.m_body;
if (bodyA === null || bodyB === null)
return minSeparation;
bodyA.c_velocity;
bodyB.c_velocity;
var positionA = bodyA.c_position;
var positionB = bodyB.c_position;
var localCenterA = this.p_localCenterA;
Expand Down Expand Up @@ -7663,7 +7657,7 @@
copyVec2(velocityB.v, vB);
velocityB.w = wB;
};
Contact.prototype.warmStartConstraint = function (step) {
Contact.prototype.warmStartConstraint = function () {
var fixtureA = this.m_fixtureA;
var fixtureB = this.m_fixtureB;
if (fixtureA === null || fixtureB === null)
Expand All @@ -7674,8 +7668,6 @@
return;
var velocityA = bodyA.c_velocity;
var velocityB = bodyB.c_velocity;
bodyA.c_position;
bodyB.c_position;
var mA = this.v_invMassA;
var iA = this.v_invIA;
var mB = this.v_invMassB;
Expand All @@ -7699,7 +7691,7 @@
copyVec2(velocityB.v, vB);
velocityB.w = wB;
};
Contact.prototype.storeConstraintImpulses = function (step) {
Contact.prototype.storeConstraintImpulses = function () {
var manifold = this.m_manifold;
for (var j = 0; j < this.v_pointCount; ++j) {
manifold.points[j].normalImpulse = this.v_points[j].normalImpulse;
Expand All @@ -7716,9 +7708,7 @@
if (bodyA === null || bodyB === null)
return;
var velocityA = bodyA.c_velocity;
bodyA.c_position;
var velocityB = bodyB.c_velocity;
bodyB.c_position;
var mA = this.v_invMassA;
var iA = this.v_invIA;
var mB = this.v_invMassB;
Expand Down Expand Up @@ -12008,7 +11998,6 @@
this.m_perp = Rot.mulVec2(qA, this.m_localYAxisA);
this.m_s1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_perp);
this.m_s2 = Vec2.crossVec2Vec2(rB, this.m_perp);
Vec2.crossVec2Vec2(rA, this.m_perp);
var k11 = mA + mB + iA * this.m_s1 * this.m_s1 + iB * this.m_s2 * this.m_s2;
var k12 = iA * this.m_s1 + iB * this.m_s2;
var k13 = iA * this.m_s1 * this.m_a1 + iB * this.m_s2 * this.m_a2;
Expand Down Expand Up @@ -15683,13 +15672,6 @@
EPAxisType[EPAxisType["e_edgeA"] = 1] = "e_edgeA";
EPAxisType[EPAxisType["e_edgeB"] = 2] = "e_edgeB";
})(EPAxisType || (EPAxisType = {}));
// unused?
/** @internal */ var VertexType;
(function (VertexType) {
VertexType[VertexType["e_isolated"] = 0] = "e_isolated";
VertexType[VertexType["e_concave"] = 1] = "e_concave";
VertexType[VertexType["e_convex"] = 2] = "e_convex";
})(VertexType || (VertexType = {}));
/**
* This structure is used to keep track of the best separating axis.
*/
Expand Down
2 changes: 1 addition & 1 deletion dist/planck-with-testbed.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/planck-with-testbed.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/planck-with-testbed.min.js.map

Large diffs are not rendered by default.

40 changes: 11 additions & 29 deletions dist/planck-with-testbed.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4820,7 +4820,6 @@ var Simplex = /** @class */ (function () {
Simplex.prototype.getSearchDirection = function () {
var v1 = this.m_v1;
var v2 = this.m_v2;
this.m_v3;
switch (this.m_count) {
case 1:
return setVec2(searchDirection_reuse, -v1.w.x, -v1.w.y);
Expand All @@ -4843,7 +4842,6 @@ var Simplex = /** @class */ (function () {
Simplex.prototype.getClosestPoint = function () {
var v1 = this.m_v1;
var v2 = this.m_v2;
this.m_v3;
switch (this.m_count) {
case 0:
return zeroVec2(closestPoint_reuse);
Expand Down Expand Up @@ -5940,7 +5938,7 @@ var Solver = /** @class */ (function () {
// Warm start.
for (var i = 0; i < this.m_contacts.length; ++i) {
var contact = this.m_contacts[i];
contact.warmStartConstraint(step);
contact.warmStartConstraint();
}
}
for (var i = 0; i < this.m_joints.length; ++i) {
Expand All @@ -5961,7 +5959,7 @@ var Solver = /** @class */ (function () {
// Store impulses for warm starting
for (var i = 0; i < this.m_contacts.length; ++i) {
var contact = this.m_contacts[i];
contact.storeConstraintImpulses(step);
contact.storeConstraintImpulses();
}
// Integrate positions
for (var i = 0; i < this.m_bodies.length; ++i) {
Expand Down Expand Up @@ -5996,7 +5994,7 @@ var Solver = /** @class */ (function () {
var minSeparation = 0.0;
for (var j = 0; j < this.m_contacts.length; ++j) {
var contact = this.m_contacts[j];
var separation = contact.solvePositionConstraint(step);
var separation = contact.solvePositionConstraint();
minSeparation = math_min$6(minSeparation, separation);
}
// We can't expect minSpeparation >= -Settings.linearSlop because we don't
Expand Down Expand Up @@ -6123,8 +6121,6 @@ var Solver = /** @class */ (function () {
}
var indexA = c_3.getChildIndexA();
var indexB = c_3.getChildIndexB();
bA_1.m_sweep;
bB_1.m_sweep;
// Compute the time of impact in interval [0, minTOI]
input.proxyA.set(fA_1.getShape(), indexA);
input.proxyB.set(fB_1.getShape(), indexB);
Expand Down Expand Up @@ -6289,7 +6285,7 @@ var Solver = /** @class */ (function () {
var minSeparation = 0.0;
for (var j = 0; j < this.m_contacts.length; ++j) {
var contact = this.m_contacts[j];
var separation = contact.solvePositionConstraintTOI(subStep, toiA, toiB);
var separation = contact.solvePositionConstraintTOI(toiA, toiB);
minSeparation = math_min$6(minSeparation, separation);
}
// We can't expect minSpeparation >= -Settings.linearSlop because we don't
Expand Down Expand Up @@ -7446,13 +7442,13 @@ var Contact = /** @class */ (function () {
listener.preSolve(this, oldManifold);
}
};
Contact.prototype.solvePositionConstraint = function (step) {
return this._solvePositionConstraint(step, null, null);
Contact.prototype.solvePositionConstraint = function () {
return this._solvePositionConstraint(null, null);
};
Contact.prototype.solvePositionConstraintTOI = function (step, toiA, toiB) {
return this._solvePositionConstraint(step, toiA, toiB);
Contact.prototype.solvePositionConstraintTOI = function (toiA, toiB) {
return this._solvePositionConstraint(toiA, toiB);
};
Contact.prototype._solvePositionConstraint = function (step, toiA, toiB) {
Contact.prototype._solvePositionConstraint = function (toiA, toiB) {
var toi = toiA !== null && toiB !== null ? true : false;
var minSeparation = 0.0;
var fixtureA = this.m_fixtureA;
Expand All @@ -7463,8 +7459,6 @@ var Contact = /** @class */ (function () {
var bodyB = fixtureB.m_body;
if (bodyA === null || bodyB === null)
return minSeparation;
bodyA.c_velocity;
bodyB.c_velocity;
var positionA = bodyA.c_position;
var positionB = bodyB.c_position;
var localCenterA = this.p_localCenterA;
Expand Down Expand Up @@ -7657,7 +7651,7 @@ var Contact = /** @class */ (function () {
copyVec2(velocityB.v, vB);
velocityB.w = wB;
};
Contact.prototype.warmStartConstraint = function (step) {
Contact.prototype.warmStartConstraint = function () {
var fixtureA = this.m_fixtureA;
var fixtureB = this.m_fixtureB;
if (fixtureA === null || fixtureB === null)
Expand All @@ -7668,8 +7662,6 @@ var Contact = /** @class */ (function () {
return;
var velocityA = bodyA.c_velocity;
var velocityB = bodyB.c_velocity;
bodyA.c_position;
bodyB.c_position;
var mA = this.v_invMassA;
var iA = this.v_invIA;
var mB = this.v_invMassB;
Expand All @@ -7693,7 +7685,7 @@ var Contact = /** @class */ (function () {
copyVec2(velocityB.v, vB);
velocityB.w = wB;
};
Contact.prototype.storeConstraintImpulses = function (step) {
Contact.prototype.storeConstraintImpulses = function () {
var manifold = this.m_manifold;
for (var j = 0; j < this.v_pointCount; ++j) {
manifold.points[j].normalImpulse = this.v_points[j].normalImpulse;
Expand All @@ -7710,9 +7702,7 @@ var Contact = /** @class */ (function () {
if (bodyA === null || bodyB === null)
return;
var velocityA = bodyA.c_velocity;
bodyA.c_position;
var velocityB = bodyB.c_velocity;
bodyB.c_position;
var mA = this.v_invMassA;
var iA = this.v_invIA;
var mB = this.v_invMassB;
Expand Down Expand Up @@ -12002,7 +11992,6 @@ var PrismaticJoint = /** @class */ (function (_super) {
this.m_perp = Rot.mulVec2(qA, this.m_localYAxisA);
this.m_s1 = Vec2.crossVec2Vec2(Vec2.add(d, rA), this.m_perp);
this.m_s2 = Vec2.crossVec2Vec2(rB, this.m_perp);
Vec2.crossVec2Vec2(rA, this.m_perp);
var k11 = mA + mB + iA * this.m_s1 * this.m_s1 + iB * this.m_s2 * this.m_s2;
var k12 = iA * this.m_s1 + iB * this.m_s2;
var k13 = iA * this.m_s1 * this.m_a1 + iB * this.m_s2 * this.m_a2;
Expand Down Expand Up @@ -15677,13 +15666,6 @@ Contact.addType(ChainShape.TYPE, PolygonShape.TYPE, ChainPolygonContact);
EPAxisType[EPAxisType["e_edgeA"] = 1] = "e_edgeA";
EPAxisType[EPAxisType["e_edgeB"] = 2] = "e_edgeB";
})(EPAxisType || (EPAxisType = {}));
// unused?
/** @internal */ var VertexType;
(function (VertexType) {
VertexType[VertexType["e_isolated"] = 0] = "e_isolated";
VertexType[VertexType["e_concave"] = 1] = "e_concave";
VertexType[VertexType["e_convex"] = 2] = "e_convex";
})(VertexType || (VertexType = {}));
/**
* This structure is used to keep track of the best separating axis.
*/
Expand Down
2 changes: 1 addition & 1 deletion dist/planck-with-testbed.mjs.map

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions dist/planck.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1442,12 +1442,12 @@ declare class Contact {
endContact(contact: Contact): void;
preSolve(contact: Contact, oldManifold: Manifold): void;
}): void;
solvePositionConstraint(step: TimeStep): number;
solvePositionConstraintTOI(step: TimeStep, toiA: Body, toiB: Body): number;
solvePositionConstraint(): number;
solvePositionConstraintTOI(toiA: Body, toiB: Body): number;
private _solvePositionConstraint;
initVelocityConstraint(step: TimeStep): void;
warmStartConstraint(step: TimeStep): void;
storeConstraintImpulses(step: TimeStep): void;
warmStartConstraint(): void;
storeConstraintImpulses(): void;
solveVelocityConstraint(step: TimeStep): void;
}
type BodyType = "static" | "kinematic" | "dynamic";
Expand Down Expand Up @@ -7747,12 +7747,12 @@ declare namespace planck {
endContact(contact: Contact): void;
preSolve(contact: Contact, oldManifold: Manifold): void;
}): void;
solvePositionConstraint(step: TimeStep): number;
solvePositionConstraintTOI(step: TimeStep, toiA: Body, toiB: Body): number;
solvePositionConstraint(): number;
solvePositionConstraintTOI(toiA: Body, toiB: Body): number;
private _solvePositionConstraint;
initVelocityConstraint(step: TimeStep): void;
warmStartConstraint(step: TimeStep): void;
storeConstraintImpulses(step: TimeStep): void;
warmStartConstraint(): void;
storeConstraintImpulses(): void;
solveVelocityConstraint(step: TimeStep): void;
}
type BodyType = "static" | "kinematic" | "dynamic";
Expand Down
Loading