1
votes

I have three b2Body-s. Head, chin and one static type b2Body. I add a b2Joint from static b2Body to head and another b2Joint for head and chin. Head ignore static body because collideConnected is false for joint, but chin is not ignore it. How to make this ? Please suggestions.

1

1 Answers

1
votes
enum CATEGORY_BITS
{
    BODY1_CATEGORY_BITS = 0x00000001,
    BODY2_CATEGORY_BITS = 0x00000002,
    BODY3_CATEGORY_BITS = 0x00000004,

};

and when you create bodies ...

    b2FixtureDef fixtureForBODY1;
    fixtureForBODY1.shape = &shapeForBODY1;
    fixtureForBODY1.filter.categoryBits = BODY1_CATEGORY_BITS;
    fixtureForBODY1.filter.maskBits = BODY1_CATEGORY_BITS | BODY3_CATEGORY_BITS;


    b2FixtureDef fixtureForBODY2;
    fixtureForBODY2.shape = &shapeForBODY2;
    fixtureForBODY2.filter.categoryBits = BODY2_CATEGORY_BITS;
    fixtureForBODY2.filter.maskBits = BODY2_CATEGORY_BITS | BODY4_CATEGORY_BITS;

    b2FixtureDef fixtureForBODY3;
    fixtureForBODY3.shape = &shapeForBODY3;
    fixtureForBODY3.filter.categoryBits = BODY3_CATEGORY_BITS;
    fixtureForBODY3.filter.maskBits = BODY3_CATEGORY_BITS | BODY1_CATEGORY_BITS;

    b2FixtureDef fixtureForBODY4;
    fixtureForBODY4.shape = &shapeForBODY4;
    fixtureForBODY4.filter.categoryBits = BODY4_CATEGORY_BITS;
    fixtureForBODY4.filter.maskBits = BODY4_CATEGORY_BITS | BODY2_CATEGORY_BITS;



// BODY1 -> not collide connected (BODY2 and BODY4)
// BODY1 -> collide connected (BODY1 and BODY3)