448448
449449 Demo . chains = function ( ) {
450450 var _world = _engine . world ,
451- groupId = Body . nextGroupId ( ) ;
451+ groupId = Body . nextNonCollidingGroupId ( ) ;
452452
453453 Demo . reset ( ) ;
454454
455455 var ropeA = Composites . stack ( 200 , 100 , 5 , 2 , 10 , 10 , function ( x , y , column , row ) {
456- return Bodies . rectangle ( x , y , 50 , 20 , { groupId : groupId } ) ;
456+ return Bodies . rectangle ( x , y , 50 , 20 , { collisionFilter : { group : groupId } } ) ;
457457 } ) ;
458458
459459 Composites . chain ( ropeA , 0.5 , 0 , - 0.5 , 0 , { stiffness : 0.8 , length : 2 } ) ;
466466
467467 World . add ( _world , ropeA ) ;
468468
469- groupId = Body . nextGroupId ( ) ;
469+ groupId = Body . nextNonCollidingGroupId ( ) ;
470470
471471 var ropeB = Composites . stack ( 500 , 100 , 5 , 2 , 10 , 10 , function ( x , y , column , row ) {
472- return Bodies . circle ( x , y , 20 , { groupId : groupId } ) ;
472+ return Bodies . circle ( x , y , 20 , { collisionFilter : { group : groupId } } ) ;
473473 } ) ;
474474
475475 Composites . chain ( ropeB , 0.5 , 0 , - 0.5 , 0 , { stiffness : 0.8 , length : 2 } ) ;
485485
486486 Demo . bridge = function ( ) {
487487 var _world = _engine . world ,
488- groupId = Body . nextGroupId ( ) ;
488+ groupId = Body . nextNonCollidingGroupId ( ) ;
489489
490490 Demo . reset ( ) ;
491491
492492 var bridge = Composites . stack ( 150 , 300 , 9 , 1 , 10 , 10 , function ( x , y , column , row ) {
493- return Bodies . rectangle ( x , y , 50 , 20 , { groupId : groupId } ) ;
493+ return Bodies . rectangle ( x , y , 50 , 20 , { collisionFilter : { group : groupId } } ) ;
494494 } ) ;
495495
496496 Composites . chain ( bridge , 0.5 , 0 , - 0.5 , 0 , { stiffness : 0.9 } ) ;
937937
938938 Demo . reset ( ) ;
939939
940- var groupId = Body . nextGroupId ( ) ,
941- particleOptions = { friction : 0.00001 , groupId : groupId , render : { visible : false } } ,
940+ var groupId = Body . nextNonCollidingGroupId ( ) ,
941+ particleOptions = { friction : 0.00001 , collisionFilter : { group : groupId } , render : { visible : false } } ,
942942 cloth = Composites . softBody ( 200 , 200 , 20 , 12 , 5 , 5 , false , 8 , particleOptions ) ;
943943
944944 for ( var i = 0 ; i < 20 ; i ++ ) {
12311231 var renderOptions = _engine . render . options ;
12321232 } ;
12331233
1234+ Demo . collisionFiltering = function ( ) {
1235+ var _world = _engine . world ;
1236+
1237+ Demo . reset ( ) ;
1238+
1239+ var i ;
1240+
1241+ World . add ( _world ,
1242+ Composites . stack ( 275 , 150 , 5 , 10 , 10 , 10 , function ( x , y , column , row ) {
1243+ return Bodies . circle ( x , y , 20 , {
1244+ collisionFilter : {
1245+ category : row < 7 ? 2 : 4
1246+ } ,
1247+ render : {
1248+ strokeStyle : row < 7 ? 'red' : 'green' ,
1249+ fillStyle : 'transparent'
1250+ }
1251+ } ) ;
1252+ } )
1253+ ) ;
1254+
1255+ World . add ( _world ,
1256+ Bodies . circle ( 400 , 40 , 30 , {
1257+ collisionFilter : {
1258+ mask : 5
1259+ } ,
1260+ render : {
1261+ fillStyle : 'blue'
1262+ }
1263+ } )
1264+ ) ;
1265+
1266+ var renderOptions = _engine . render . options ;
1267+ renderOptions . wireframes = false ;
1268+ renderOptions . background = '#111' ;
1269+ renderOptions . showCollisions = true ;
1270+ } ;
1271+
12341272 // the functions for the demo interface and controls below
12351273
12361274 Demo . initControls = function ( ) {
14001438 renderOptions . showDebug = true ;
14011439 } ;
14021440
1403- } ) ( ) ;
1441+ } ) ( ) ;
0 commit comments