Skip to content

Commit

Permalink
optimised Collision._findSupports
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Jul 23, 2023
1 parent ce03208 commit 653a110
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/collision/Collision.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,15 +275,15 @@ var Pair = require('./Pair');
bodyAPositionY = bodyA.position.y,
normalX = normal.x * direction,
normalY = normal.y * direction,
nearestDistance = Number.MAX_VALUE,
vertexA,
vertexB,
vertexA = vertices[0],
vertexB = vertexA,
nearestDistance = normalX * (bodyAPositionX - vertexB.x) + normalY * (bodyAPositionY - vertexB.y),
vertexC,
distance,
j;

// find deepest vertex relative to the axis
for (j = 0; j < verticesLength; j += 1) {
for (j = 1; j < verticesLength; j += 1) {
vertexB = vertices[j];
distance = normalX * (bodyAPositionX - vertexB.x) + normalY * (bodyAPositionY - vertexB.y);

Expand Down

0 comments on commit 653a110

Please sign in to comment.