Triggers and contact breaking.

Antonz
Posts: 16
Joined: Wed Nov 17, 2010 10:57 am

Triggers and contact breaking.

Post by Antonz »

Hi.

I want to use a convex collision object with and check for touch events with particular type of objects (with a given mask). I found it convenient to use global callbacks gContactAddedCallback and gContactDestroyedCallback . So, this trigger has btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK set, I'm doing quick test in my gContactAddedCallback to decide if this is a trigger (I'm storing pointer to my data in user data member of collision object). When moving dynamic body object and my trigger object have collision response, everything seems OK. But if I want a "passable" trigger with btCollisionObject::CF_NO_CONTACT_RESPONSE turned on, I have a problems. Contacts points created and destroyed every tick when dynamic object passes through my trigger object. Manifold is created only when objects starts colliding, but points created and destroyed every time, so callbacks is called too. I've traced removal of contact point and found that it happens here:
//contact also becomes invalid when relative movement orthogonal to normal exceeds margin
projectedPoint = manifoldPoint.m_positionWorldOnA - manifoldPoint.m_normalWorldOnB * manifoldPoint.m_distance1;
projectedDifference = manifoldPoint.m_positionWorldOnB - projectedPoint;
distance2d = projectedDifference.dot(projectedDifference);
if (distance2d > getContactBreakingThreshold()*getContactBreakingThreshold() )
{
removeContactPoint(i);
} else
{
//contact point processed callback
if (gContactProcessedCallback)
(*gContactProcessedCallback)(manifoldPoint,m_body0,m_body1);
}
So, orthogonal movement is bigger than threshold and contact "breaks" and then gets created again.
How I can tune this contact breaking threshold only for this one case, so it doesn't breaks on movement of dynamic rigid body inside of trigger, but only when object really leaves it? Obviously I should tweak contact breaking threshold for this particular manifold, but how to find it right from my gContactAddedCallback handler? It receives only contact point, not a manifold.