Collision Flags

Archeron
Posts: 1
Joined: Mon Mar 01, 2010 12:41 am

Collision Flags

Post by Archeron »

Hi, by using bullet library I found a strange thing about collision flags. I show you an example of the problem i got :

So first I create a rigid body :

Code: Select all

btRigidBody* Body = new btRigidBody(//some stuff);
then my own collision flag and filter :

Code: Select all

short COL_TEST  = 1<<5;
short FLT_TEST = COL_TEST | CF_STATIC_OBJECT;
and to finish I add my Body to the world with the collision flag and filter :

Code: Select all

World->addRigidBody( body, COL_TEST, FLT_TEST );
Later in the code I use the ghostObject of my kinematicCharacterController, it collides fine with the body I created by respecting the collision flag and filter. But when I want to compare the flag of the btCollisionObject with my collision flag, like that :

Code: Select all

If(GhostObject->getOverlappingObject(i)->getCollisionFlags() == COL_TEST)
It is always false because it is not the good value. I need to set the collision flag of my Body to have the result I expect :

Code: Select all

World->addRigidBody( body, COL_TEST, FLT_TEST );
Body->setCollsionFlag(COL_TEST);
Without this instruction I can’t know when I have a btCollisionObject with my personnal collision flag. It is very strange because Bullet know what is the collision flag and if it is not in the filter of my kynematic character, I don’t have physic collision with it.
But when I want to get the collision flag it is not the good value, I need to add the collision flag in an explicit way to get the good value for the flag.

So, what are your feelings about this ? May be it is normal but it looks very strange for me.
If you want more details I can provide them, just ask :wink: .
betacub
Posts: 1
Joined: Fri Sep 11, 2009 10:59 pm

Re: Collision Flags

Post by betacub »

This interface is setting the collision filter group and mask, respectively, not the collision flags and filter:

Code: Select all

World->addRigidBody( body, COL_TEST, FLT_TEST );
To set collision flags, you have to call the method on the body directly, as you identified yourself:

Code: Select all

Body->setCollisionFlags(COL_TEST)