Using ghost objects with dynamic rigid bodies

varun
Posts: 3
Joined: Sat Aug 14, 2010 6:46 am

Using ghost objects with dynamic rigid bodies

Post by varun »

Hello everyone,
I'm trying to use ghost objects to detect collisions for both triggers and for normal rigid bodies as well. For dynamic rigid bodies I create a ghost object using the shape of the rigid body and sync the transforms of both the rigid body and it's ghost object each frame. Now the problem arises when I check for collisions using the ghost object. When a collision occurs, it reports a contact manifold correctly but the manifold is empty, as in there are no contact points in it. So is this because of using an exact copy of a rigid body as the ghost? Could that be preventing the ghost object from detecting contacts correctly?


Thanks
pico
Posts: 229
Joined: Sun Sep 30, 2007 7:58 am

Re: Using ghost objects with dynamic rigid bodies

Post by pico »

As far as i know the ghost only recognizes aabb overlaps and does not create real contacts. If you need contacts you should use the pairCaching ghost object.
varun
Posts: 3
Joined: Sat Aug 14, 2010 6:46 am

Re: Using ghost objects with dynamic rigid bodies

Post by varun »

Hi,
Thanks for the reply. I'm already using the pair caching ghost object but it still gives me that problem.
pico
Posts: 229
Joined: Sun Sep 30, 2007 7:58 am

Re: Using ghost objects with dynamic rigid bodies

Post by pico »

varun wrote:Hi,
Thanks for the reply. I'm already using the pair caching ghost object but it still gives me that problem.
Ok. Below is the code i use to get the manifolds. Maybe it helps..

collisionWorld->getDispatcher()->dispatchAllCollisionPairs(m_ghostPairCache->getOverlappingPairCache(), collisionWorld->getDispatchInfo(), collisionWorld->getDispatcher());

for (int i = 0; i < m_ghostPairCache->getOverlappingPairCache()->getNumOverlappingPairs(); i++)
{
m_manifoldArray.resize(0);
btBroadphasePair* collisionPair = &m_ghostPairCache->getOverlappingPairCache()->getOverlappingPairArray();
if (collisionPair->m_algorithm)
collisionPair->m_algorithm->getAllContactManifolds(m_manifoldArray);
for (int j=0;j<m_manifoldArray.size();j++)
{
btPersistentManifold* manifold = m_manifoldArray[j];
if (!manifold->getNumContacts())continue;
//process contacts
}
}
varun
Posts: 3
Joined: Sat Aug 14, 2010 6:46 am

Re: Using ghost objects with dynamic rigid bodies

Post by varun »

Thanks pico, but I think I've figured out the problem. :) I went back to traversing the complete list of contact manifolds in the tick callback and that too had the same problem. That's when I realized the problem wasn't specific to ghost objects. It turns out the body size was too small and I had to scale it up! Is that a known issue? If the body is too small, does it fail to generate contact points even though it generates contact manifolds?