Set Box2D collision filter/groupIndex after physics body added

Add a SetCollisionFilter function to physics API so filter bits can be changed after body is created. Something like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
      //------------------------------------------
      //sets the maskbits for collision
      //------------------------------------------
      public static function SetBits(body:b2Body , bits:uint):void
      {
         var newFilter: b2FilterData = new b2FilterData();
         var oldFilter: b2FilterData = new b2FilterData();
 
         //get shape and old filter data
         var shape:b2Shape = body.GetShapeList();
         oldFilter = shape.GetFilterData();
         
         //set new filter data
         newFilter.maskBits = bits;
         shape.SetFilterData(newFilter);
         
         //update box2D filtering
         Game.world.Refilter(shape);         
      }
views:2123 update:2011/9/18 10:09:28
corona forums © 2003-2011