Getting Triangle from Contact Manifold

scarypajamas
Posts: 3
Joined: Thu Mar 17, 2011 5:16 am

Getting Triangle from Contact Manifold

Post by scarypajamas »

I'm using the contact manifold method for checking collision between objects as seen here in the first code snippet. For my project, the collision will always be done between trimeshes. The problem I'm having is I need a way to retrieve the triangle's that are touching with one another.

How would I go about this?
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: Getting Triangle from Contact Manifold

Post by Flix »

Don't know the exact answer, but I suppose that if if triangle index is not available in the "contact manifold method" (is it true?), you have to additionally use the contact added callback (or custom material callback?) and store the triangle index somewhere inside your collision object user ptr (or inside the class that inherits from btRigidBody, if you use one...).

Hope it works (maybe I've done something similiar in the past, but for compound shapes child indices... but I'm not sure about it).

P.S. You may not use the "contact manifold method" at all if you, every few frames, check if one of your triangle indices "stored somewhere" has changed...
scarypajamas
Posts: 3
Joined: Thu Mar 17, 2011 5:16 am

Re: Getting Triangle from Contact Manifold

Post by scarypajamas »

Thanks for the reply Flix. Fortunately, I found what I've been looking for! If you check out the btManifoldPoint class, you'll see it has the following fields.

Code: Select all

//BP mod, store contact triangles.
int      m_partId0;
int      m_partId1;
Both m_partId0 and m_partId1 contain the index of the triangle that received contact for the first and second mesh.

This was exactly what I needed.