Skip to content

Commit be9b789

Browse files
committed
clean up assert and unused statements
1 parent 3aee543 commit be9b789

File tree

5 files changed

+35
-28
lines changed

5 files changed

+35
-28
lines changed

src/collision/Distance.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ class Simplex {
452452
getSearchDirection(): Vec2Value {
453453
const v1 = this.m_v1;
454454
const v2 = this.m_v2;
455-
const v3 = this.m_v3;
455+
// const v3 = this.m_v3;
456456
switch (this.m_count) {
457457
case 1:
458458
return matrix.setVec2(searchDirection_reuse, -v1.w.x, -v1.w.y);
@@ -478,7 +478,7 @@ class Simplex {
478478
getClosestPoint(): Vec2Value {
479479
const v1 = this.m_v1;
480480
const v2 = this.m_v2;
481-
const v3 = this.m_v3;
481+
// const v3 = this.m_v3;
482482
switch (this.m_count) {
483483
case 0:
484484
if (_ASSERT) console.assert(false);

src/collision/DynamicTree.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -578,15 +578,18 @@ export class DynamicTree<T> {
578578
// if (_ASSERT) console.assert(0 <= child1 && child1 < this.m_nodeCapacity);
579579
// if (_ASSERT) console.assert(0 <= child2 && child2 < this.m_nodeCapacity);
580580

581-
const height1 = child1.height;
582-
const height2 = child2.height;
583-
const height = 1 + math_max(height1, height2);
584-
if (_ASSERT) console.assert(node.height === height);
585-
586-
const aabb = new AABB();
587-
aabb.combine(child1.aabb, child2.aabb);
581+
if (_ASSERT) {
582+
const height1 = child1.height;
583+
const height2 = child2.height;
584+
const height = 1 + math_max(height1, height2);
585+
console.assert(node.height === height);
586+
}
588587

589-
if (_ASSERT) console.assert(AABB.areEqual(aabb, node.aabb));
588+
if (_ASSERT) {
589+
const aabb = new AABB();
590+
aabb.combine(child1.aabb, child2.aabb);
591+
console.assert(AABB.areEqual(aabb, node.aabb));
592+
}
590593

591594
this.validateMetrics(child1);
592595
this.validateMetrics(child2);

src/collision/shape/ChainShape.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,13 @@ export class ChainShape extends Shape {
145145
return;
146146
}
147147

148-
for (let i = 1; i < vertices.length; ++i) {
149-
const v1 = vertices[i - 1];
150-
const v2 = vertices[i];
151-
// If the code crashes here, it means your vertices are too close together.
152-
if (_ASSERT) console.assert(Vec2.distanceSquared(v1, v2) > Settings.linearSlopSquared);
148+
if (_ASSERT) {
149+
for (let i = 1; i < vertices.length; ++i) {
150+
const v1 = vertices[i - 1];
151+
const v2 = vertices[i];
152+
// If the code crashes here, it means your vertices are too close together.
153+
console.assert(Vec2.distanceSquared(v1, v2) > Settings.linearSlopSquared);
154+
}
153155
}
154156

155157
this.m_vertices = [];
@@ -175,11 +177,13 @@ export class ChainShape extends Shape {
175177
_createChain(vertices: Vec2Value[]): ChainShape {
176178
if (_ASSERT) console.assert(this.m_vertices.length == 0 && this.m_count == 0);
177179
if (_ASSERT) console.assert(vertices.length >= 2);
178-
for (let i = 1; i < vertices.length; ++i) {
179-
const v1 = vertices[i - 1];
180-
const v2 = vertices[i];
181-
// If the code crashes here, it means your vertices are too close together.
182-
if (_ASSERT) console.assert(Vec2.distanceSquared(v1, v2) > Settings.linearSlopSquared);
180+
if (_ASSERT) {
181+
for (let i = 1; i < vertices.length; ++i) {
182+
const v1 = vertices[i - 1];
183+
const v2 = vertices[i];
184+
// If the code crashes here, it means your vertices are too close together.
185+
console.assert(Vec2.distanceSquared(v1, v2) > Settings.linearSlopSquared);
186+
}
183187
}
184188

185189
this.m_vertices = [];

src/dynamics/Contact.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,8 @@ export class Contact {
626626
const bodyB = fixtureB.m_body;
627627
if (bodyA === null || bodyB === null) return minSeparation;
628628

629-
const velocityA = bodyA.c_velocity;
630-
const velocityB = bodyB.c_velocity;
629+
// const velocityA = bodyA.c_velocity;
630+
// const velocityB = bodyB.c_velocity;
631631
const positionA = bodyA.c_position;
632632
const positionB = bodyB.c_position;
633633

@@ -882,8 +882,8 @@ export class Contact {
882882

883883
const velocityA = bodyA.c_velocity;
884884
const velocityB = bodyB.c_velocity;
885-
const positionA = bodyA.c_position;
886-
const positionB = bodyB.c_position;
885+
// const positionA = bodyA.c_position;
886+
// const positionB = bodyB.c_position;
887887

888888
const mA = this.v_invMassA;
889889
const iA = this.v_invIA;
@@ -932,10 +932,10 @@ export class Contact {
932932
if (bodyA === null || bodyB === null) return;
933933

934934
const velocityA = bodyA.c_velocity;
935-
const positionA = bodyA.c_position;
935+
// const positionA = bodyA.c_position;
936936

937937
const velocityB = bodyB.c_velocity;
938-
const positionB = bodyB.c_position;
938+
// const positionB = bodyB.c_position;
939939

940940
const mA = this.v_invMassA;
941941
const iA = this.v_invIA;

src/dynamics/Solver.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,8 @@ export class Solver {
564564
const indexA = c.getChildIndexA();
565565
const indexB = c.getChildIndexB();
566566

567-
const sweepA = bA.m_sweep;
568-
const sweepB = bB.m_sweep;
567+
// const sweepA = bA.m_sweep;
568+
// const sweepB = bB.m_sweep;
569569

570570
// Compute the time of impact in interval [0, minTOI]
571571
input.proxyA.set(fA.getShape(), indexA);

0 commit comments

Comments
 (0)