Skip to content

Commit

Permalink
refactor: minor refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
zOadT committed Aug 3, 2023
1 parent 39a983b commit 4c64f4d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/collision/Distance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ export const Distance = function (output: DistanceOutput, cache: SimplexCache, i
let saveCount = 0;

let distanceSqr1 = Infinity;
let distanceSqr2 = Infinity;

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

// Compute closest point.
const p = simplex.getClosestPoint();
distanceSqr2 = p.lengthSquared();
const distanceSqr2 = p.lengthSquared();

// Ensure progress
if (distanceSqr2 >= distanceSqr1) {
Expand Down
4 changes: 4 additions & 0 deletions src/collision/shape/ChainShape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ export class ChainShape extends Shape {
_createLoop(vertices: Vec2Value[]): ChainShape {
_ASSERT && console.assert(this.m_vertices.length == 0 && this.m_count == 0);
_ASSERT && console.assert(vertices.length >= 3);
if (vertices.length < 3) {
return;
}

for (let i = 1; i < vertices.length; ++i) {
const v1 = vertices[i - 1];
const v2 = vertices[i];
Expand Down
4 changes: 2 additions & 2 deletions src/dynamics/Contact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { ContactImpulse, TimeStep } from "./Solver";
const _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT;


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

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

0 comments on commit 4c64f4d

Please sign in to comment.