btCollisionObject::CheckCollideWith() always returns true!

EGD Eric
Posts: 3
Joined: Sun Feb 08, 2009 9:12 pm

btCollisionObject::CheckCollideWith() always returns true!

Post by EGD Eric »

Hi, I'm trying to use this engine to make a demo with physics, but I need to be able to detect when a collision happened between two rigid bodies. I tried checkCollideWith() function, but it always returns true, regardless of whether the two objects are actually colliding! One object is a rigid body that has a sphere as its shape, the other is a rigid body with a cylinder as its shape. All I do is:

Code: Select all

if(m_headbody->checkCollideWith( m_ballbody))
{
//collision!
}
Any advice? Maybe you prefer some other method that works for you? Any input would be appreciated.
pico
Posts: 229
Joined: Sun Sep 30, 2007 7:58 am

Re: btCollisionObject::CheckCollideWith() always returns true!

Post by pico »

Bullet supplies no high level functions to check if bodies collided.
the function you use tests only if the collision filters of those two bodies match.

To see if two bodies have collided in the last physics step you need to iterate over the contact manifolds.
Check out the Wiki entry: http://www.bulletphysics.com/mediawiki- ... d_Triggers
"Contact Information" is what you are looking for.
Dominik
Posts: 32
Joined: Fri Dec 19, 2008 2:51 pm

Re: btCollisionObject::CheckCollideWith() always returns true!

Post by Dominik »

The way I check direct collisions between two distinct bodies

Code: Select all

btCollisionAlgorithm* pAlgorithm = pBtWorld->getDispatcher()->findAlgorithm( pBulletObj1, pBulletObj2 );
btManifoldResult oManifoldResult( pBulletObj1, pBulletObj2 );
pAlgorithm->processCollision( pBulletObj1, pBulletObj2, pBtWorld->getDispatchInfo(), &oManifoldResult );
btPersistentManifold* pManifold = oManifoldResult.getPersistentManifold();
However, I have no idea how good this approach is. In any case, he ignores the broad phase test, thus not being overly efficient