[ODE] Ray queries with GIMPACT.

Michael Anderson christiancoder at gmail.com
Tue Apr 24 12:33:53 MST 2007


Lately we have been experiencing capsule - mesh jitter with OPCODE. After
reading that GIMPACT seems to solve these collision problems I made the
switch. After adding dInitODE and dCloseODE to our application I was up and
running. GIMPACT appears to have solved the jitter problem, but I have lost
ray - mesh intersections. Our ray cast method follows, it basically takes a
global ray (that does not belong to any collision space) and calls dCollide
passing in our collision space as the second geom. Does GIMPACT support ray
- mesh (in my experience this is the easiest of all intersection tests)?  If
so what am I missing?

//=============================================================================

bool castRay( RayCastResult& result, const VectorF& start, const VectorF&
end, const U32 types )
{
   // Calc direction and length of ray.
   VectorF dir = end - start;
   F32 const len = dir.len();
   dir *= (1.0f / len);

   // Create ray.
   dGeomRaySetLength( gRayId, len );
   dGeomRaySet( gRayId, start.x, start.y, start.z, dir.x, dir.y, dir.z );

   // Set collide bits for ray.
   dGeomSetCollideBits( gRayId, types );

   // Collide ray with world.
   dContactGeom contacts[64];
   const int c = dCollide( gRayId, (dGeomID)gSpace, 64, contacts, sizeof(
dContactGeom ) );

   // Did ray intersect world?
   if (!c)
   {
      return false;
   }

   // Find the closest intersection.
   U32 closest = 0;
   F32 closestDepth = contacts[0].depth;
   for (U32 i = 1; i < c; i++)
   {
      if (contacts[i].depth < closestDepth)
      {
         closest = i;
         closestDepth = contacts[i].depth;
      }
   }

   // Ray intersected world, so get intersection info.
   dContactGeom& closestContact = contacts[closest];
   result.object = (SceneObject*)dGeomGetData( closestContact.g2 );
   result.geom = closestContact.g2;
   result.entityType = dGeomGetCategoryBits( closestContact.g2 );
   result.point.set( closestContact.pos[0], closestContact.pos[1],
closestContact.pos[2] );
   result.normal.set( closestContact.normal[0], closestContact.normal[1],
closestContact.normal[2] );
   result.distance = closestContact.depth;

   return true;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://ode.org/pipermail/ode/attachments/20070424/52917963/attachment.htm


More information about the ODE mailing list