From 653a110d64fbab9a7ddd4775719be6dcec9b7220 Mon Sep 17 00:00:00 2001 From: liabru Date: Sun, 23 Jul 2023 11:20:28 +0100 Subject: [PATCH] optimised Collision._findSupports --- src/collision/Collision.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/collision/Collision.js b/src/collision/Collision.js index 40b6cdfb..86634e65 100644 --- a/src/collision/Collision.js +++ b/src/collision/Collision.js @@ -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);