0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-12-25 13:39:06 -05:00

preserve pair.contacts order

This commit is contained in:
liabru 2024-03-03 21:50:40 +00:00
parent 89963f77a0
commit e891d37b65

View file

@ -74,29 +74,21 @@ var Contact = require('./Contact');
pair.contactCount = supportCount; pair.contactCount = supportCount;
collision.pair = pair; collision.pair = pair;
var support = supports[0], var supportA = supports[0],
contact = contacts[0]; contactA = contacts[0],
supportB = supports[1],
contactB = contacts[1];
// reset first contact if support changed // match contacts to supports
if (contact.vertex !== support) { if (contactB.vertex === supportA || contactA.vertex === supportB) {
contact.vertex = support; contacts[1] = contactA;
contact.normalImpulse = 0; contacts[0] = contactA = contactB;
contact.tangentImpulse = 0; contactB = contacts[1];
} }
if (supportCount < 2) { // update contacts
return; contactA.vertex = supportA;
} contactB.vertex = supportB;
support = supports[1];
contact = contacts[1];
// reset second contact if support changed
if (contact.vertex !== support) {
contact.vertex = support;
contact.normalImpulse = 0;
contact.tangentImpulse = 0;
}
}; };
/** /**