[ODE] 3 out of 4 contacts box->plane?

Kevin Quigley kevin.quigley at gmail.com
Tue Oct 9 19:17:37 MST 2007


I'm seeing 3 contact points generated by a box geometry sitting on (or
through) a plane.  I can't figure out what's gone wrong in my
callback.  This is a mixture of various bits I found in the
wiki/manual.  Any ideas?

The three contact points are not always the same, either.  When drawn,
some or all of them flicker as one contact is not drawn during that
step.

thanks,
quig


void nearCallback (void *data, dGeomID o1, dGeomID o2) {
  // colliding two non-space geoms, so generate contact
  // points between o1 and o2
  dContact new_contacts[MAX_CONTACTS];
  for (int i = 0; i < MAX_CONTACTS; i++) {
    new_contacts[i].surface.mode = dContactBounce;
    if ( dGeomGetClass(o1) != dPlaneClass
	 && dGeomGetClass(o2) != dPlaneClass ) {
      new_contacts[i].surface.mode |= dContactSoftCFM;
    }
    new_contacts[i].surface.mu = 0;
    new_contacts[i].surface.mu2 = 0;
    new_contacts[i].surface.bounce = 0.1;
    new_contacts[i].surface.bounce_vel = mps(0.1);
    new_contacts[i].surface.soft_cfm = mm(0.01);
  }

  int numc = 0;
  numc =
    dCollide( o1, o2, MAX_CONTACTS, &new_contacts[0].geom, sizeof(dContact) );

  if (numc > 0 ) {printf( "got %d contacts\n", numc );}

  // add these contact points to the simulation ...
  for ( int i = 0; i < numc; i++ ) {
    dJointID c = dJointCreateContact( world, contacts, &new_contacts[i] );
    dJointAttach(c, dGeomGetBody(o1), dGeomGetBody(o2) );
    if (show_contacts) {
      dMatrix3 RI;
      dRSetIdentity (RI);
      const dReal ct[3] = {cSize, cSize, cSize };
      dsDrawBox (new_contacts[i].geom.pos,RI,ct);
    }
  }
}


-- 
There was a pirate's parrot who got a bad case of sunstroke and was
heard crowing, "Pieces of seven, pieces of seven," which was clearly a
parroty error.


More information about the ODE mailing list