@@ -8,8 +8,6 @@ var Pair = {};
88
99module . exports = Pair ;
1010
11- var Contact = require ( './Contact' ) ;
12-
1311( function ( ) {
1412
1513 /**
@@ -21,27 +19,26 @@ var Contact = require('./Contact');
2119 */
2220 Pair . create = function ( collision , timestamp ) {
2321 var bodyA = collision . bodyA ,
24- bodyB = collision . bodyB ,
25- parentA = collision . parentA ,
26- parentB = collision . parentB ;
22+ bodyB = collision . bodyB ;
2723
2824 var pair = {
2925 id : Pair . id ( bodyA , bodyB ) ,
3026 bodyA : bodyA ,
3127 bodyB : bodyB ,
32- contacts : { } ,
3328 activeContacts : [ ] ,
3429 separation : 0 ,
3530 isActive : true ,
3631 confirmedActive : true ,
3732 isSensor : bodyA . isSensor || bodyB . isSensor ,
3833 timeCreated : timestamp ,
3934 timeUpdated : timestamp ,
40- inverseMass : parentA . inverseMass + parentB . inverseMass ,
41- friction : Math . min ( parentA . friction , parentB . friction ) ,
42- frictionStatic : Math . max ( parentA . frictionStatic , parentB . frictionStatic ) ,
43- restitution : Math . max ( parentA . restitution , parentB . restitution ) ,
44- slop : Math . max ( parentA . slop , parentB . slop )
35+
36+ collision : null ,
37+ inverseMass : 0 ,
38+ friction : 0 ,
39+ frictionStatic : 0 ,
40+ restitution : 0 ,
41+ slop : 0
4542 } ;
4643
4744 Pair . update ( pair , collision , timestamp ) ;
@@ -57,31 +54,41 @@ var Contact = require('./Contact');
5754 * @param {number } timestamp
5855 */
5956 Pair . update = function ( pair , collision , timestamp ) {
60- var contacts = pair . contacts ,
61- supports = collision . supports ,
62- activeContacts = pair . activeContacts ,
63- parentA = collision . parentA ,
64- parentB = collision . parentB ;
57+ // var contacts = pair.contacts,
58+ // supports = collision.supports,
59+ // activeContacts = pair.activeContacts,
60+ // parentA = collision.parentA,
61+ // parentB = collision.parentB;
6562
6663 pair . collision = collision ;
67- pair . inverseMass = parentA . inverseMass + parentB . inverseMass ;
68- pair . friction = Math . min ( parentA . friction , parentB . friction ) ;
69- pair . frictionStatic = Math . max ( parentA . frictionStatic , parentB . frictionStatic ) ;
70- pair . restitution = Math . max ( parentA . restitution , parentB . restitution ) ;
71- pair . slop = Math . max ( parentA . slop , parentB . slop ) ;
72- activeContacts . length = 0 ;
64+ // pair.inverseMass = parentA.inverseMass + parentB.inverseMass;
65+ // pair.friction = Math.min(parentA.friction, parentB.friction);
66+ // pair.frictionStatic = Math.max(parentA.frictionStatic, parentB.frictionStatic);
67+ // pair.restitution = Math.max(parentA.restitution, parentB.restitution);
68+ // pair.slop = Math.max(parentA.slop, parentB.slop);
69+ // activeContacts.length = 0;
7370
7471 if ( collision . collided ) {
72+
73+ var supports = collision . supports ,
74+ activeContacts = pair . activeContacts ,
75+ parentA = collision . parentA ,
76+ parentB = collision . parentB ;
77+
78+ pair . inverseMass = parentA . inverseMass + parentB . inverseMass ;
79+ pair . friction = Math . min ( parentA . friction , parentB . friction ) ;
80+ pair . frictionStatic = Math . max ( parentA . frictionStatic , parentB . frictionStatic ) ;
81+ pair . restitution = Math . max ( parentA . restitution , parentB . restitution ) ;
82+ pair . slop = Math . max ( parentA . slop , parentB . slop ) ;
83+
7584 for ( var i = 0 ; i < supports . length ; i ++ ) {
76- var support = supports [ i ] ,
77- contactId = Contact . id ( support ) ,
78- contact = contacts [ contactId ] ;
79-
80- if ( contact ) {
81- activeContacts . push ( contact ) ;
82- } else {
83- activeContacts . push ( contacts [ contactId ] = Contact . create ( support ) ) ;
84- }
85+ activeContacts [ i ] = supports [ i ] . contact ;
86+ }
87+
88+ var supportCount = supports . length ;
89+
90+ if ( supportCount < activeContacts . length ) {
91+ activeContacts . length = supportCount ;
8592 }
8693
8794 pair . separation = collision . depth ;
0 commit comments