@@ -21,27 +21,25 @@ var Contact = require('./Contact');
2121 */
2222 Pair . create = function ( collision , timestamp ) {
2323 var bodyA = collision . bodyA ,
24- bodyB = collision . bodyB ,
25- parentA = collision . parentA ,
26- parentB = collision . parentB ;
24+ bodyB = collision . bodyB ;
2725
2826 var pair = {
2927 id : Pair . id ( bodyA , bodyB ) ,
3028 bodyA : bodyA ,
3129 bodyB : bodyB ,
32- contacts : { } ,
30+ contacts : [ ] ,
3331 activeContacts : [ ] ,
3432 separation : 0 ,
3533 isActive : true ,
3634 confirmedActive : true ,
3735 isSensor : bodyA . isSensor || bodyB . isSensor ,
3836 timeCreated : timestamp ,
3937 timeUpdated : timestamp ,
40- inverseMass : parentA . inverseMass + parentB . inverseMass ,
41- friction : parentA . friction < parentB . friction ? parentA . friction : parentB . friction ,
42- frictionStatic : parentA . frictionStatic > parentB . frictionStatic ? parentA . frictionStatic : parentB . frictionStatic ,
43- restitution : parentA . restitution > parentB . restitution ? parentA . restitution : parentB . restitution ,
44- slop : parentA . slop > parentB . slop ? parentA . slop : parentB . slop
38+ inverseMass : 0 ,
39+ friction : 0 ,
40+ frictionStatic : 0 ,
41+ restitution : 0 ,
42+ slop : 0
4543 } ;
4644
4745 Pair . update ( pair , collision , timestamp ) ;
@@ -61,34 +59,31 @@ var Contact = require('./Contact');
6159 supports = collision . supports ,
6260 activeContacts = pair . activeContacts ,
6361 parentA = collision . parentA ,
64- parentB = collision . parentB ;
62+ parentB = collision . parentB ,
63+ parentAVerticesLength = parentA . vertices . length ;
6564
65+ pair . isActive = true ;
66+ pair . timeUpdated = timestamp ;
6667 pair . collision = collision ;
68+ pair . separation = collision . depth ;
6769 pair . inverseMass = parentA . inverseMass + parentB . inverseMass ;
6870 pair . friction = parentA . friction < parentB . friction ? parentA . friction : parentB . friction ;
6971 pair . frictionStatic = parentA . frictionStatic > parentB . frictionStatic ? parentA . frictionStatic : parentB . frictionStatic ;
7072 pair . restitution = parentA . restitution > parentB . restitution ? parentA . restitution : parentB . restitution ;
7173 pair . slop = parentA . slop > parentB . slop ? parentA . slop : parentB . slop ;
74+
7275 activeContacts . length = 0 ;
7376
74- if ( collision . collided ) {
75- for ( var i = 0 ; i < supports . length ; i ++ ) {
76- var support = supports [ i ] ,
77- contactId = Contact . id ( support ) ,
78- contact = contacts [ contactId ] ;
77+ for ( var i = 0 ; i < supports . length ; i ++ ) {
78+ var support = supports [ i ] ,
79+ contactId = support . body === parentA ? support . index : parentAVerticesLength + support . index ,
80+ contact = contacts [ contactId ] ;
7981
80- if ( contact ) {
81- activeContacts . push ( contact ) ;
82- } else {
83- activeContacts . push ( contacts [ contactId ] = Contact . create ( support ) ) ;
84- }
82+ if ( contact ) {
83+ activeContacts . push ( contact ) ;
84+ } else {
85+ activeContacts . push ( contacts [ contactId ] = Contact . create ( support ) ) ;
8586 }
86-
87- pair . separation = collision . depth ;
88- Pair . setActive ( pair , true , timestamp ) ;
89- } else {
90- if ( pair . isActive === true )
91- Pair . setActive ( pair , false , timestamp ) ;
9287 }
9388 } ;
9489
0 commit comments