0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2025-03-14 00:38:41 -04:00

Fixed precomputed axis projections updates

This commit is contained in:
Brice Chevalier 2018-01-30 12:43:41 +09:00
parent d3d72b11c8
commit 5fd302f896
3 changed files with 9 additions and 17 deletions

View file

@ -43,8 +43,6 @@ var Projections = require('../geometry/Projections');
id: Common.nextId(),
type: 'body',
label: 'Body',
pairs: [],
region: null,
parts: [],
plugin: {},
angle: 0,
@ -89,6 +87,9 @@ var Projections = require('../geometry/Projections');
lineWidth: 0
},
pairs: [],
region: null,
events: null,
bounds: null,
chamfer: null,
@ -111,8 +112,6 @@ var Projections = require('../geometry/Projections');
_initProperties(body, options);
Projections.verticesOntoAxes(body.projections, body.vertices, body.axes);
return body;
};
@ -167,6 +166,7 @@ var Projections = require('../geometry/Projections');
Vertices.rotate(body.vertices, body.angle, body.position);
Axes.rotate(body.axes, body.angle);
Bounds.update(body.bounds, body.vertices, body.velocity);
Projections.verticesOntoAxes(body.projections, body.vertices, body.axes);
// allow options to override the automatically calculated properties
var properties = {};
@ -370,6 +370,7 @@ var Projections = require('../geometry/Projections');
Vertices.translate(body.vertices, body.position);
Body.setAxes(body, Axes.fromVertices(body.vertices));
Bounds.update(body.bounds, body.vertices, body.velocity);
Projections.verticesOntoAxes(body.projections, body.vertices, body.axes);
};
Body.setAxes = function (body, axes) {
@ -457,6 +458,7 @@ var Projections = require('../geometry/Projections');
part.position.y += delta.y;
Vertices.translate(part.vertices, delta);
Bounds.update(part.bounds, part.vertices, body.velocity);
Projections.verticesOntoAxes(part.projections, part.vertices, part.axes);
}
};
@ -476,6 +478,7 @@ var Projections = require('../geometry/Projections');
Vertices.rotate(part.vertices, delta, body.position);
Axes.rotate(part.axes, delta);
Bounds.update(part.bounds, part.vertices, body.velocity);
Projections.verticesOntoAxes(part.projections, part.vertices, part.axes);
if (i > 0) {
Vector.rotateAbout(part.position, delta, body.position, part.position);
}
@ -584,6 +587,7 @@ var Projections = require('../geometry/Projections');
// update bounds
Bounds.update(part.bounds, part.vertices, body.velocity);
Projections.verticesOntoAxes(part.projections, part.vertices, part.axes);
}
// handle parent body
@ -670,6 +674,7 @@ var Projections = require('../geometry/Projections');
}
Bounds.update(part.bounds, partVertices, velocity);
Projections.verticesOntoAxes(part.projections, part.vertices, part.axes);
}
};

View file

@ -76,15 +76,6 @@ var Common = require('../core/Common');
if (body.isSleeping)
continue;
if (!body.isStatic) {
// updating body projection
var parts = body.parts;
for (var j = parts.length > 1 ? 1 : 0; j < parts.length; j++) {
var part = parts[j];
Projections.verticesOntoAxes(part.projections, part.vertices, part.axes);
}
}
// don't update out of world bodies
var bounds = body.bounds;

View file

@ -161,10 +161,6 @@ var Body = require('../body/Body');
// broadphase pass: find potential collision pairs
if (broadphase.controller) {
// if world is dirty, we must flush the whole grid
// if (world.isModified)
// broadphase.controller.reset(broadphase, allBodies, engine);
// update the grid buckets based on current bodies
broadphase.controller.update(broadphase, allBodies, engine);
}