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 redundant commented-out code #297

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions build-utils/declarationTransformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ function visitor(factory, node, options) {
!isClassIncluded(node.name.escapedText, options)) {
return node;
}
// if (isClassDerived(node)) {
// // workaround for https://github.com/microsoft/TypeScript/issues/46503
// return splitClassIntoConstAndInterface(factory, node);
// }
return createNodeWithFactories(factory, node);
}

Expand Down
3 changes: 0 additions & 3 deletions example/Asteroid.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ function addAsteroids() {
while (asteroidBodies.length) {
const asteroidBody = asteroidBodies.shift();
world.destroyBody(asteroidBody);
// asteroidBody.uiRemove();
}

for (let i = 0; i < level; i++) {
Expand Down Expand Up @@ -269,12 +268,10 @@ function hit(asteroidBody, bulletBody) {
// Remove asteroid
world.destroyBody(asteroidBody);
asteroidBodies.splice(aidx, 1);
// asteroidBody.uiRemove();

// Remove bullet
world.destroyBody(bulletBody);
bulletBodies.splice(bidx, 1);
// bulletBody.uiRemove();

// Add new sub-asteroids
splitAsteroid(asteroidBody);
Expand Down
3 changes: 1 addition & 2 deletions example/Breakout.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,12 @@ function State() {

!_bricks.length && createRow();
_score += _combo;
// _combo++;

updateStatus();
createDrop(brick);
};

state.hitBall = function() {
// _combo = 1;
};

state.missBall = function(ball) {
Expand Down
1 change: 0 additions & 1 deletion example/BulletTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ ground.createFixture(new Box(0.2, 1.0, new Vec2(0.5, 1.0), 0.0), 0.0);
let body = world.createDynamicBody(new Vec2(0.0, 4.0));
body.createFixture(new Box(2.0, 0.1), 1.0);

// x = Math.random(-1.0, 1.0);
let x = 0.20352793;

let bullet = world.createBody({
Expand Down
1 change: 0 additions & 1 deletion example/CollisionProcessing.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ world.on('pre-solve', function(contact, oldManifold) {
cp.fixtureB = fixtureB;
cp.position = worldManifold.points[i];
cp.normal = worldManifold.normal;
// cp.state = state2[i];
cp.normalImpulse = manifold.points[i].normalImpulse;
cp.tangentImpulse = manifold.points[i].tangentImpulse;
cp.separation = worldManifold.separations[i];
Expand Down
16 changes: 2 additions & 14 deletions example/Confined.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ for (let j = 0; j < e_columnCount; ++j) {

function CreateCircle() {
let body = world.createDynamicBody(new Vec2(Math.random() * 10 - 5, Math.random() * 10 + 5));
// bd.allowSleep = false;

body.createFixture(new Circle(Math.random() * 2.5 + 0.5), {
density : 1.0,
friction : 0.0
Expand Down Expand Up @@ -91,16 +91,4 @@ testbed.step = function() {
if (sleeping) {
CreateCircle();
}

// for (let b = world.getBodyList(); b; b = b.getNext()) {
// if (!b.isDynamic()) {
// continue;
// }
//
// let p = b.getPosition();
// if (p.x <= -10.0 || 10.0 <= p.x || p.y <= 0.0 || 20.0 <= p.y) {
// // why?
// p.x += 0.0;
// }
// }
};
};
5 changes: 0 additions & 5 deletions example/ConvexHull.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,8 @@ testbed.step = function() {

for (let i = 0; i < points.length; ++i) {
testbed.drawPoint(points[i], 3.0, testbed.color(0.3, 0.9, 0.3));
// testbed.drawString(points[i] + new Vec2(0.05, 0.05), "%d", i);
}

// if (shape.validate() == false) {
// m_textLine += 0;
// }

if (auto) {
generate();
}
Expand Down
16 changes: 3 additions & 13 deletions example/DynamicTreeTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let queryAABB = new AABB();
let rayCastInput = {};
let rayCastOutput = {};
let rayActor;
let actors = []; // Actor[e_actorCount];
let actors = [];
let automated = false;

for (let i = 0; i < ACTOR_COUNT; ++i) {
Expand All @@ -34,8 +34,6 @@ queryAABB.upperBound.set(5.0, 6.0 + h);

rayCastInput.p1 = new Vec2(-5.0, 5.0 + h);
rayCastInput.p2 = new Vec2(7.0, -4.0 + h);
// rayCastInput.p1 = new Vec2(0.0, 2.0 + h);
// rayCastInput.p2 = new Vec2(0.0, -2.0 + h);
rayCastInput.maxFraction = 1.0;

testbed.step = function() {
Expand Down Expand Up @@ -138,17 +136,14 @@ function Actor() {

function getRandomAABB(aabb) {
let w = new Vec2(2.0 * proxyExtent, 2.0 * proxyExtent);
// aabb.lowerBound.x = -proxyExtent;
// aabb.lowerBound.y = -proxyExtent + worldExtent;
aabb.lowerBound.x = Math.random(-worldExtent, worldExtent);
aabb.lowerBound.y = Math.random(0.0, 2.0 * worldExtent);
aabb.upperBound = Vec2.add(w, aabb.lowerBound);
}

function moveAABB(aabb) {
let d = new Vec2(Math.random(-0.5, 0.5), Math.random(-0.5, 0.5));
// d.x = 2.0;
// d.y = 0.0;

aabb.lowerBound.add(d);
aabb.upperBound.add(d);

Expand Down Expand Up @@ -227,7 +222,6 @@ function runQuery() {
}

let overlap = AABB.testOverlap(queryAABB, actors[i].aabb);
// assert(overlap == actors[i].overlap);
}
}

Expand Down Expand Up @@ -255,8 +249,4 @@ function rayCast() {
input.maxFraction = output.fraction;
}
}

if (bruteActor != null) {
// Assert(bruteOutput.fraction == rayCastOutput.fraction);
}
}
}
2 changes: 1 addition & 1 deletion example/EdgeShapes.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function rayCastReset () {
}

testbed.step = function() {
let advanceRay = !pause; // settings.pause == 0 || settings.singleStep;
let advanceRay = !pause;

let L = 25.0;
let point1 = new Vec2(0.0, 10.0);
Expand Down
2 changes: 1 addition & 1 deletion example/PolyShapes.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function drawFixture(fixture) {
case 'polygon': {
let poly = fixture.getShape();
let vertexCount = poly.m_count;
// assert(vertexCount <= b2_maxPolygonVertices);

let vertices = poly.m_vertices.map(v => Transform.mul(xf, v));
testbed.drawPolygon(vertices, color);
}
Expand Down
2 changes: 0 additions & 2 deletions example/Pulleys.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@ let b = 2.0;

let ground = world.createBody();

// ground.createFixture(new Edge(new Vec2(-40.0, 0.0), new Vec2(40.0, 0.0)), 0.0);

ground.createFixture(new Circle(new Vec2(-10.0, y + b + L), 2.0), 0.0);
ground.createFixture(new Circle(new Vec2(10.0, y + b + L), 2.0), 0.0);

let shape = new Box(a, b);

// bd.fixedRotation = true;
let box1 = world.createDynamicBody(new Vec2(-10.0, y));
box1.createFixture(shape, 5.0);

Expand Down
4 changes: 0 additions & 4 deletions example/Pyramid.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,4 @@ for (let i = 0; i < COUNT; ++i) {
}

testbed.step = function() {
// let tree = world.m_broadPhase.m_tree;
// if (stepCount++ == 400) {
// tree.rebuildBottomUp();
// }
};
2 changes: 0 additions & 2 deletions example/RayCast.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ let RayCastAny = (function() {
// the closest fixture.
let RayCastMultiple = (function() {
let def = {};
// let MAX_COUNT = 3;

def.reset = function() {
def.points = [];
Expand Down Expand Up @@ -329,7 +328,6 @@ testbed.step = function() {
let input = {}; // RayCastInput
input.p1 = new Vec2(10.2725, 1.71372);
input.p2 = new Vec2(10.2353, 2.21807);
// input.maxFraction = 0.567623;
input.maxFraction = 0.56762173;

let xf = new Transform(new Vec2(23.0, 5.0));
Expand Down
7 changes: 1 addition & 6 deletions example/Revolute.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,5 @@ testbed.keydown = function(code, char) {
};

testbed.step = function() {
// if (stepCount++ == 360) {
// ball.setTransform(new Vec2(0.0, 0.5), 0.0);
// }

testbed.status('Motor Torque', joint.getMotorTorque(testbed.hz));
// testbed.status('Motor Force', joint.getMaxForce());
};
};
1 change: 0 additions & 1 deletion example/Soccer.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ world.on('post-solve', function(contact) {
if (ball && goal) {
ball.setPosition(new Vec2(0, 0));
ball.setLinearVelocity(new Vec2(0, 0));
// world.destroyBody(ball);
}
}, 1);
});
Expand Down
5 changes: 0 additions & 5 deletions example/Tiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,4 @@ testbed.step = function() {
testbed.status('min', minimumHeight);
testbed.status('create time', createTime + 'ms');
testbed.status('fixture count', fixtureCount);

// let tree = world.m_broadPhase.m_tree;
// if (stepCount++ == 400) {
// tree.rebuildBottomUp();
// }
};
7 changes: 2 additions & 5 deletions example/TimeOfImpact.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,11 @@ sweepA.localCenter.setZero();
let shapeB = new Box(2.5, 2.5);
let sweepB = new Sweep();
sweepB.c0.set(20, 20);
sweepB.a0 = 0.1; // - 162.0 * Math.PI;
sweepB.a0 = 0.1;
sweepB.c.set(-20, -20);
sweepB.a = 3.1; // - 162.0 * Math.PI;
sweepB.a = 3.1;
sweepB.localCenter.setZero();

// sweepB.a0 -= 300.0 * Math.PI;
// sweepB.a -= 300.0 * Math.PI;

let input = new TOIInput();
input.proxyA.set(shapeA, 0);
input.sweepA.set(sweepA);
Expand Down
2 changes: 0 additions & 2 deletions src/__test__/Basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ describe('Basic', function(): void {

world.step(1 / 20);

// console.log(b2.getPosition());

var p = b1.getPosition();
expect(p.x).closeTo(0.0, 1e-12);
expect(p.y).closeTo(0.0, 1e-12);
Expand Down
2 changes: 0 additions & 2 deletions src/__test__/World.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ describe('World', function(): void {
// Now print the position and angle of the body.
position = body.getPosition();
angle = body.getAngle();

// console.log("%s %s %s", position.x.toFixed(4), position.y.toFixed(4), angle.toFixed(4));
}

expect(position.x).closeTo(0.0, 1e-5);
Expand Down
9 changes: 0 additions & 9 deletions src/collision/DynamicTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ export class DynamicTree<T> {
index = index.parent;
}

// validate();
}

removeLeaf(leaf: TreeNode<T>): void {
Expand Down Expand Up @@ -372,8 +371,6 @@ export class DynamicTree<T> {
sibling.parent = null;
this.freeNode(parent);
}

// validate();
}

/**
Expand Down Expand Up @@ -537,8 +534,6 @@ export class DynamicTree<T> {
node = this.m_root;
}

// _ASSERT && console.assert(0 <= id && id < this.m_nodeCapacity);

if (node.isLeaf()) {
return 0;
}
Expand Down Expand Up @@ -567,8 +562,6 @@ export class DynamicTree<T> {
return;
}

// _ASSERT && console.assert(0 <= child1 && child1 < this.m_nodeCapacity);
// _ASSERT && console.assert(0 <= child2 && child2 < this.m_nodeCapacity);

_ASSERT && console.assert(child1.parent === node);
_ASSERT && console.assert(child2.parent === node);
Expand All @@ -592,8 +585,6 @@ export class DynamicTree<T> {
return;
}

// _ASSERT && console.assert(0 <= child1 && child1 < this.m_nodeCapacity);
// _ASSERT && console.assert(0 <= child2 && child2 < this.m_nodeCapacity);

const height1 = child1.height;
const height2 = child2.height;
Expand Down
5 changes: 0 additions & 5 deletions src/collision/Manifold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,6 @@ export function getPointStates(
): void {
// state1, state2: PointState[Settings.maxManifoldPoints]

// for (var i = 0; i < Settings.maxManifoldPoints; ++i) {
// state1[i] = PointState.nullState;
// state2[i] = PointState.nullState;
// }

// Detect persists and removes.
for (let i = 0; i < manifold1.pointCount; ++i) {
const id = manifold1.points[i].id;
Expand Down
18 changes: 0 additions & 18 deletions src/collision/TimeOfImpact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,24 +181,6 @@ export const TimeOfImpact = function (output: TOIOutput, input: TOIInput): void
// Initialize the separating axis.
separationFunction.initialize(cache, proxyA, sweepA, proxyB, sweepB, t1);

// if (false) {
// // Dump the curve seen by the root finder
// const N = 100;
// const dx = 1.0 / N;
// const xs = []; // [ N + 1 ];
// const fs = []; // [ N + 1 ];
// const x = 0.0;
// for (const i = 0; i <= N; ++i) {
// sweepA.getTransform(xfA, x);
// sweepB.getTransform(xfB, x);
// const f = fcn.evaluate(xfA, xfB) - target;
// printf("%g %g\n", x, f);
// xs[i] = x;
// fs[i] = f;
// x += dx;
// }
// }

// Compute the TOI on the separating axis. We do this by successively
// resolving the deepest point. This loop is bounded by the number of
// vertices.
Expand Down
1 change: 0 additions & 1 deletion src/collision/shape/CollideCircle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,5 @@ export const CollideCircles = function (manifold: Manifold, circleA: CircleShape
manifold.pointCount = 1;
matrix.copyVec2(manifold.points[0].localPoint, circleB.m_p);

// manifold.points[0].id.key = 0;
manifold.points[0].id.setFeatures(0, ContactFeatureType.e_vertex, 0, ContactFeatureType.e_vertex)
}
Loading