Skip to content

Commit

Permalink
optimised Resolver.postSolvePosition
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Apr 29, 2021
1 parent c7cec16 commit fceb0ca
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/collision/Resolver.js
Expand Up @@ -121,9 +121,12 @@ var Bounds = require('../geometry/Bounds');
* @param {body[]} bodies
*/
Resolver.postSolvePosition = function(bodies) {
var positionWarming = Resolver._positionWarming;
var positionWarming = Resolver._positionWarming,
bodiesLength = bodies.length,
verticesTranslate = Vertices.translate,
boundsUpdate = Bounds.update;

for (var i = 0; i < bodies.length; i++) {
for (var i = 0; i < bodiesLength; i++) {
var body = bodies[i],
positionImpulse = body.positionImpulse,
positionImpulseX = positionImpulse.x,
Expand All @@ -137,8 +140,8 @@ var Bounds = require('../geometry/Bounds');
// update body geometry
for (var j = 0; j < body.parts.length; j++) {
var part = body.parts[j];
Vertices.translate(part.vertices, positionImpulse);
Bounds.update(part.bounds, part.vertices, velocity);
verticesTranslate(part.vertices, positionImpulse);
boundsUpdate(part.bounds, part.vertices, velocity);
part.position.x += positionImpulseX;
part.position.y += positionImpulseY;
}
Expand Down

0 comments on commit fceb0ca

Please sign in to comment.