mirror of
https://github.com/liabru/matter-js.git
synced 2024-12-25 13:39:06 -05:00
optimised Resolver.postSolvePosition
This commit is contained in:
parent
c7cec16eb7
commit
fceb0cab68
1 changed files with 7 additions and 4 deletions
|
@ -121,9 +121,12 @@ var Bounds = require('../geometry/Bounds');
|
||||||
* @param {body[]} bodies
|
* @param {body[]} bodies
|
||||||
*/
|
*/
|
||||||
Resolver.postSolvePosition = function(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],
|
var body = bodies[i],
|
||||||
positionImpulse = body.positionImpulse,
|
positionImpulse = body.positionImpulse,
|
||||||
positionImpulseX = positionImpulse.x,
|
positionImpulseX = positionImpulse.x,
|
||||||
|
@ -137,8 +140,8 @@ var Bounds = require('../geometry/Bounds');
|
||||||
// update body geometry
|
// update body geometry
|
||||||
for (var j = 0; j < body.parts.length; j++) {
|
for (var j = 0; j < body.parts.length; j++) {
|
||||||
var part = body.parts[j];
|
var part = body.parts[j];
|
||||||
Vertices.translate(part.vertices, positionImpulse);
|
verticesTranslate(part.vertices, positionImpulse);
|
||||||
Bounds.update(part.bounds, part.vertices, velocity);
|
boundsUpdate(part.bounds, part.vertices, velocity);
|
||||||
part.position.x += positionImpulseX;
|
part.position.x += positionImpulseX;
|
||||||
part.position.y += positionImpulseY;
|
part.position.y += positionImpulseY;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue