[ODE] Bug in Ray-Trimesh collision implementation

Simon Barratt Barog at pineapple-interactive.com
Fri Mar 18 14:51:09 MST 2005


> void dGeomRaySetParams (dGeomID g, int FirstContact, int
BackfaceCull); 

You are setting firstContact to 1, this tells OPCODE to return the first
triangle that it checks for a hit. Therefore closesthit never gets the
chance to work.

Working code should be :-

    if ( rayGeom && hitGeom )
    {
      dGeomRaySetParams((dxGeom*)rayGeom, 0, 1); // g, firstcontact=0,
backfacecull=1
      dGeomRaySetClosestHit((dxGeom*)rayGeom, 1); // g, closesthit = 1
      n = dCollide(o1, o2, 1, &contact, sizeof(contact));
      if ( n > 0 )
      {
        if (contact.depth < rayGeom->contactDepth)
        {
          //printf("%p %p %f \n", o1, o2, contact.depth);
          rayGeom->contactDepth = contact.depth;
          rayGeom->contactRetro = hitGeom->GetRetro();
          rayGeom->contactFiducial = hitGeom->GetFiducial();
        }
      }
    }

That will let OPCODE go through all possibly hits and then will just
return the nearest 't' as your contact depth.

Good luck

--
Simon Barratt, Lead Developer, Pineapple Interactive Ltd
e: barog at pineapple-interactive.com
w: http://www.pineapple-interactive.com
t: +44 (0) 1274 480185
 

-----Original Message-----
From: ode-bounces at q12.org [mailto:ode-bounces at q12.org] On Behalf Of
Sawyer
Sent: 17 March 2005 19:50
To: ode at q12.org
Subject: [ODE] Bug in Ray-Trimesh collision implementation

Here are the two compiling and non-crashing variations I tried, neither
of them fixed the problem.

(RayProximity::UpdateCallback)
    // Check for ray/geom intersections
    if ( rayGeom && hitGeom )
    {
      dGeomRaySetParams((dxGeom*)rayGeom, 1, 1);
      dGeomRaySetClosestHit((dxGeom*)rayGeom, 1);
      n = dCollide(o1, o2, 1, &contact, sizeof(contact));
      if ( n > 0 )
      {
        if (contact.depth < rayGeom->contactDepth)
        {
          //printf("%p %p %f \n", o1, o2, contact.depth);
          rayGeom->contactDepth = contact.depth;
          rayGeom->contactRetro = hitGeom->GetRetro();
          rayGeom->contactFiducial = hitGeom->GetFiducial();
        }
      }
    }






More information about the ODE mailing list