[ODE] performance with rays
Erwin de Vries
erwin at vo.com
Wed Feb 5 01:16:02 2003
> I'm not using the latest ODE but I've noticed something about rays...
>
> I use rays for ground height detection and line of sight (LOS). For
ground height, the ray points straight down and no worries. For line of
sight, my ray is very long (150m), crosses alot of terrain, and it ends up
checking thousands of triangles in my static geometry, thus killing my frame
rate.
>
> Proposal: What I propose is that rays only return one contact point --
the nearest one. The test should be iterative with an early out. Perhaps
grow the AABB each step or some other incremental approach.
>
> If this is already handled or there is another solution, let me know.
Otherwise, I'll have to patch this before I can use rays in ode for LOS.
I've included this and backface culling for triangles in my own private
version, but this is not compatible with the public one. Still using my
custom collision detection for everything. :-( This is what it does:
void dcGeomRaySetParams(dxGeom* g, int FirstContact, int BackfaceCull);
void dcGeomRayGetParams(dxGeom* g, int* FirstContact, int* BackfaceCull);
In dTrilist_Ray.cpp insert the following code somewhere in the beginning of
the function.
int FirstContact, BackfaceCull;
dcGeomRayGetParams(RayGeom, &FirstContact, &BackfaceCull);
Collider.SetClosestHit(FirstContact);
Collider.SetCulling(BackfaceCull);
Collider.SetMaxDist(Length);
All you need to do is find a good place to store this data. I stored it in
the upper bits of the general flags of a dxGeom, which i reserved for these
kinds of things.
I only implemented it for triangle stuff though, because this is all i use
of it. It would be nice to have the backface culling work as well. This
basically says only to return 1 contact for simple primitives, because they
are all convex.
Hope this helps. Cheers,
Erwin