Collision detection : tracking btManifoldPoint in time

Post Reply
Kalinarm
Posts: 6
Joined: Tue May 08, 2012 2:46 pm

Collision detection : tracking btManifoldPoint in time

Post by Kalinarm »

Hi,

I'm using Bullet only for collision detection with my own integrator.
To do complex collision response with friction, I need to keep track of the contact in time.

I retrieve contactPoint for each contact and inject them in my collision computation. But these contacts points are sorted by penetration distance, so they cannot be "identified" by their index. So if penetration distance change, the order change too, and i cannot retrieve in the new frame which contact point correspond to the old contact point.

I'm looking for a way to identify these contact point in this forum, but i found nothing to solve my problem.
Do i miss something ? Is there a way to do that in bullet ?
I see that btManifoldPoint has a lifetime : can i use this information for my purpose ?

I retrieve the contacts points with :

Code: Select all

m_world->performDiscreteCollisionDetection();
int numManifolds = m_world->getDispatcher()->getNumManifolds();
for (int i=0;i<numManifolds;i++) {
    btPersistentManifold* contactManifold =  m_world->getDispatcher()->getManifoldByIndexInternal(i);
    for (int j = 0; j< contactManifold->getNumContacts(); ++j) {
        btManifoldPoint pt = contactManifold ->getContactPoint(j);
        // process contact point
    }
}
Thanks in advance
and forgive my English :)
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Collision detection : tracking btManifoldPoint in time

Post by Erwin Coumans »

The m_lifeTime is a counter that keeps track of the 'lifetime' of a contact point, starting at 0 and increasing 1 after each collision detection update.

If you only use collision detection, you could store extra information in one of the contact point fields, such as m_userPersistentData (type void*) or m_appliedImpulse (type float)?
These fields are persistent over the life time of a contact point, so you could store a pointer or identifier there.

Does that help?
Kalinarm
Posts: 6
Joined: Tue May 08, 2012 2:46 pm

Re: Collision detection : tracking btManifoldPoint in time

Post by Kalinarm »

Yes ! It does !
Thanks a lot. I will try with m_userPersistentData.
Kalinarm
Posts: 6
Joined: Tue May 08, 2012 2:46 pm

Re: Collision detection : tracking btManifoldPoint in time

Post by Kalinarm »

I have just a little problem with :

Code: Select all

btAssert(m_pointCache[lastUsedIndex].m_userPersistentData==0);
(line 172 btPersistentManifold.h )

What is this assert for ? Check if user has released his data ? If yes, I probably miss something :)
Post Reply