0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-11-27 09:50:52 -05:00

changed engine collisionStart event to trigger after resolving and after updating body velocities

This commit is contained in:
liabru 2022-01-04 10:54:34 +00:00
parent d52f7e6dcf
commit 70600a8c11

View file

@ -147,10 +147,6 @@ var Body = require('../body/Body');
if (engine.enableSleeping)
Sleeping.afterCollisions(pairs.list, delta);
// trigger collision events
if (pairs.collisionStart.length > 0)
Events.trigger(engine, 'collisionStart', { pairs: pairs.collisionStart });
// iteratively resolve position between collisions
Resolver.preSolvePosition(pairs.list);
for (i = 0; i < engine.positionIterations; i++) {
@ -175,6 +171,9 @@ var Body = require('../body/Body');
Engine._bodiesUpdateVelocities(allBodies);
// trigger collision events
if (pairs.collisionStart.length > 0)
Events.trigger(engine, 'collisionStart', { pairs: pairs.collisionStart });
if (pairs.collisionActive.length > 0)
Events.trigger(engine, 'collisionActive', { pairs: pairs.collisionActive });