public class ContactFilter {
public boolean shouldCollide(Fixture fixtureA, Fixture fixtureB){
Filter filterA = fixtureA.getFilterData();
Filter filterB = fixtureB.getFilterData();
if (filterA.groupIndex == filterB.groupIndex && filterA.groupIndex != 0){
return filterA.groupIndex > 0;
}
boolean collide = (filterA.maskBits & filterB.categoryBits) != 0 &&
(filterA.categoryBits & filterB.maskBits) != 0;
return collide;
}
}
碰撞过滤,如果碰撞发生了就返回true.它主要是通过判断刚体所在的组以及位信息,两个刚体是否会发生碰撞。
网友评论