Skip to content

Commit 4c64f4d

Browse files
committed
refactor: minor refactorings
1 parent 39a983b commit 4c64f4d

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/collision/Distance.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ export const Distance = function (output: DistanceOutput, cache: SimplexCache, i
112112
let saveCount = 0;
113113

114114
let distanceSqr1 = Infinity;
115-
let distanceSqr2 = Infinity;
116115

117116
// Main iteration loop.
118117
let iter = 0;
@@ -133,7 +132,7 @@ export const Distance = function (output: DistanceOutput, cache: SimplexCache, i
133132

134133
// Compute closest point.
135134
const p = simplex.getClosestPoint();
136-
distanceSqr2 = p.lengthSquared();
135+
const distanceSqr2 = p.lengthSquared();
137136

138137
// Ensure progress
139138
if (distanceSqr2 >= distanceSqr1) {

src/collision/shape/ChainShape.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ export class ChainShape extends Shape {
148148
_createLoop(vertices: Vec2Value[]): ChainShape {
149149
_ASSERT && console.assert(this.m_vertices.length == 0 && this.m_count == 0);
150150
_ASSERT && console.assert(vertices.length >= 3);
151+
if (vertices.length < 3) {
152+
return;
153+
}
154+
151155
for (let i = 1; i < vertices.length; ++i) {
152156
const v1 = vertices[i - 1];
153157
const v2 = vertices[i];

src/dynamics/Contact.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import { ContactImpulse, TimeStep } from "./Solver";
3939
const _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;
4040

4141

42+
// Solver debugging is normally disabled because the block solver sometimes has to deal with a poorly conditioned effective mass matrix.
4243
const DEBUG_SOLVER = false;
4344

4445
/**
@@ -910,8 +911,7 @@ export class Contact {
910911
// 01/07 on Box2D_Lite).
911912
// Build the mini LCP for this contact patch
912913
//
913-
// vn = A * x + b, vn >= 0, , vn >= 0, x >= 0 and vn_i * x_i = 0 with i =
914-
// 1..2
914+
// vn = A * x + b, vn >= 0, x >= 0 and vn_i * x_i = 0 with i = 1..2
915915
//
916916
// A = J * W * JT and J = ( -n, -r1 x n, n, r2 x n )
917917
// b = vn0 - velocityBias

0 commit comments

Comments
 (0)