[ODE] Ray queries with GIMPACT.
Michael Anderson
christiancoder at gmail.com
Tue Apr 24 14:01:46 MST 2007
Okay, changing the following GIMPACT code in gim_geometry.h fixes the
problem for me:
// BUGFIX: modified if (_dotdir<PLANEDIREPSILON) to if
(-_dotdir<PLANEDIREPSILON)
#define RAY_PLANE_COLLISION(plane,vDir,vPoint,pout,tparam,does_intersect)\
{\
GREAL _dis,_dotdir; \
_dotdir = VEC_DOT(plane,vDir);\
if(-_dotdir<PLANEDIREPSILON)\
{\
does_intersect = 0;\
}\
else\
{\
_dis = DISTANCE_PLANE_POINT(plane,vPoint); \
tparam = -_dis/_dotdir;\
VEC_SCALE(pout,tparam,vDir);\
VEC_SUM(pout,vPoint,pout); \
does_intersect = 1;\
}\
}\
On 4/24/07, Michael Anderson <christiancoder at gmail.com> wrote:
>
> Hmmm, looks like it's a vertex winding issue. If I flip the vertex winding
> ray - mesh tests work, but everything else fails...
>
> On 4/24/07, Michael Anderson <christiancoder at gmail.com> wrote:
> >
> > 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/f86c8969/attachment-0001.htm
More information about the ODE
mailing list