[ODE] Collision objects

symeg@tcd.ie symeg at tcd.ie
Sat Apr 27 10:21:01 2002


Thanks!

Quoting Ken M <wgold@flyingplastic.com>:

> Sure!
> Just test for that condition in your nearCallback() routine and don't add a
> dCollideJoint for that collision, call a "handleInvisibleIntersection()"
> method to respond to it instead.  If you don't add a dCollideJoint at the
> time of collision, ODE won't repond at all.  The normal use case for the
> nearCallback() already tests is the objects are joined with a joint, and if
> so ignores the collision.  Your case is a little trickier, as you'll have
> to
> lookup the objects in a table or something of the kind to determine if it's
> one of your invisible objects, but certainly not a insurmountable problem.
> 
> modified From TestBoxstack.cpp
> ---- snip ----
> 
> static void nearCallback (void *data, dGeomID o1, dGeomID o2)
> {
>   int i;
> 
>   // exit without doing anything if the two bodies are connected by a joint
>   dBodyID b1 = dGeomGetBody(o1);
>   dBodyID b2 = dGeomGetBody(o2);
>   if (b1 && b2 && dAreConnected (b1,b2)) return;
> 
>   dContact contact[3];   // up to 3 contacts per box
>   for (i=0; i<3; i++) {
>     contact[i].surface.mode = dContactBounce; //dContactMu2;
>     contact[i].surface.mu = dInfinity;
>     contact[i].surface.mu2 = 0;
>     contact[i].surface.bounce = 0.5;
>     contact[i].surface.bounce_vel = 0.1;
>   }
>   if (int numc = dCollide (o1,o2,3,&contact[0].geom,sizeof(dContact))) {
>     // dMatrix3 RI;
>     // dRSetIdentity (RI);
>     // const dReal ss[3] = {0.02,0.02,0.02};
>     for (i=0; i<numc; i++) {
> 
>     if ( !isIgnoreObject(o1) || !isIgnoreObject(o2) )
>     {
>           dJointID c = dJointCreateContact (world,contactgroup,contact+i);
>           dJointAttach (c,b1,b2);
>       }
>     }
>   }
> }
> 
> bool isIgnoreObject( dGeomID obj )
> {
>     // test for object .. An stl::set would be good here, filled
>     // and managed each frame with your 'ignorable' geom.
> }
> --- snip ---
> 
> Hope this helps.
> 
> Ken