mirror of
https://github.com/liabru/matter-js.git
synced 2025-01-12 16:08:50 -05:00
fix pair properties for compounds
This commit is contained in:
parent
685f2bdc54
commit
b8f3784b76
1 changed files with 14 additions and 10 deletions
|
@ -16,7 +16,9 @@ var Pair = {};
|
||||||
*/
|
*/
|
||||||
Pair.create = function(collision, timestamp) {
|
Pair.create = function(collision, timestamp) {
|
||||||
var bodyA = collision.bodyA,
|
var bodyA = collision.bodyA,
|
||||||
bodyB = collision.bodyB;
|
bodyB = collision.bodyB,
|
||||||
|
parentA = collision.parentA,
|
||||||
|
parentB = collision.parentB;
|
||||||
|
|
||||||
var pair = {
|
var pair = {
|
||||||
id: Pair.id(bodyA, bodyB),
|
id: Pair.id(bodyA, bodyB),
|
||||||
|
@ -28,10 +30,10 @@ var Pair = {};
|
||||||
isActive: true,
|
isActive: true,
|
||||||
timeCreated: timestamp,
|
timeCreated: timestamp,
|
||||||
timeUpdated: timestamp,
|
timeUpdated: timestamp,
|
||||||
inverseMass: bodyA.inverseMass + bodyB.inverseMass,
|
inverseMass: parentA.inverseMass + parentB.inverseMass,
|
||||||
friction: Math.min(bodyA.friction, bodyB.friction),
|
friction: Math.min(parentA.friction, parentB.friction),
|
||||||
restitution: Math.max(bodyA.restitution, bodyB.restitution),
|
restitution: Math.max(parentA.restitution, parentB.restitution),
|
||||||
slop: Math.max(bodyA.slop, bodyB.slop)
|
slop: Math.max(parentA.slop, parentB.slop)
|
||||||
};
|
};
|
||||||
|
|
||||||
Pair.update(pair, collision, timestamp);
|
Pair.update(pair, collision, timestamp);
|
||||||
|
@ -48,13 +50,15 @@ var Pair = {};
|
||||||
Pair.update = function(pair, collision, timestamp) {
|
Pair.update = function(pair, collision, timestamp) {
|
||||||
var contacts = pair.contacts,
|
var contacts = pair.contacts,
|
||||||
supports = collision.supports,
|
supports = collision.supports,
|
||||||
activeContacts = pair.activeContacts;
|
activeContacts = pair.activeContacts,
|
||||||
|
parentA = collision.parentA,
|
||||||
|
parentB = collision.parentB;
|
||||||
|
|
||||||
pair.collision = collision;
|
pair.collision = collision;
|
||||||
pair.inverseMass = collision.bodyA.inverseMass + collision.bodyB.inverseMass;
|
pair.inverseMass = parentA.inverseMass + parentB.inverseMass;
|
||||||
pair.friction = Math.min(collision.bodyA.friction, collision.bodyB.friction);
|
pair.friction = Math.min(parentA.friction, parentB.friction);
|
||||||
pair.restitution = Math.max(collision.bodyA.restitution, collision.bodyB.restitution);
|
pair.restitution = Math.max(parentA.restitution, parentB.restitution);
|
||||||
pair.slop = Math.max(collision.bodyA.slop, collision.bodyB.slop);
|
pair.slop = Math.max(parentA.slop, parentB.slop);
|
||||||
activeContacts.length = 0;
|
activeContacts.length = 0;
|
||||||
|
|
||||||
if (collision.collided) {
|
if (collision.collided) {
|
||||||
|
|
Loading…
Reference in a new issue