Collision with filters remain undetected - help !

n00vember
Posts: 2
Joined: Mon Mar 15, 2010 9:49 pm

Collision with filters remain undetected - help !

Post by n00vember »

Hello !

I'm having a hard time understanding why a collision remain undetected.
I have two btGhostObject with btSphereShape attached.
First is at world position 50, 50, 50 with a sphere of radius 100, and has been added like this : mCollisionWorld->addCollisionObject(mGhost, 2, 1);
Second object is at world position 0, 50, 0 with a sphere of radius 10, and has been added like this : mCollisionWorld->addCollisionObject(mGhost, 1, 2);
mCollisionWorld has been updated through performDiscreteCollisionDetection()

To detect the collision, I'm using a method described in the wiki :

Code: Select all

        btBroadphasePairArray& pairArray = mGhostObject->getOverlappingPairCache()->getOverlappingPairArray();

        for (int i = 0; i < pairArray.size(); ++i)
        {
               // We never get here
        }
The problem being we never enter the for loop. The first thing I see would be that I didn't quite understand how collision masks work, but I'm not really sure... Also, the collisionWorld is a btDiscreteDynamicsWorld, but it shouldn't matter, should it ?
Any pointers that could help me ?

Thanks in advance !
n00vember
Posts: 2
Joined: Mon Mar 15, 2010 9:49 pm

Re: Collision with filters remain undetected - help !

Post by n00vember »

Found the solution :
In order for the btGhostObject to be updated when new pairs are added, you need to set a callback on the btBroadphaseInterface :
broadphaseInterface->getOverlappingPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());