[ODE] ODE collisions with a terrain mesh question

Burton Radons loth at users.sourceforge.net
Fri Feb 1 06:26:01 2002


McEvoy, Nick wrote:

> I was wondering if ODE has the ability to determine collisions between its
> basic shapes (sphere, box, cylinder) and a given polygon (ie. a triangle) ?
> 
> The reason why is that ... I have a terrain mesh ... I currently feed ODE
> the plane that the ODE body (I should say geometry) is touching ... the
> problem is that ODE plane geometries are infinite in size (and the piece of
> terrain that the body is touching is actually a finite plane ... its a
> triangle) ... this causes my body to 'bounce' off the screen when at an
> intersection between two planes (due to ODE thinking my body is penetrating
> the plane) ... (maybe the AABB() methods could be a solution ... but it
> doesn't look finished ???).


For boxes, I just compare their eight points (four could be managed but 
probably not worth bothering with) with the terrain at that point.  It's 
not accurate, it has visual glitches, but generally those are invisible, 
it's very fast, the glitches are stabilizers, and it works good enough 
for gaming.  For spheres I could have six points on the leading curve of 
the sphere, or just a bunch around it - since the sphere will be 
approximating a mesh, the error is not as relevant as in boxes.  My 
purposes make it more useful for the objects to be stable than for them 
to teeter on mountain peaks.

If you need high accuracy, go with COLLIDE or, alternatively, get out a 
pad of paper and work out a polygon-to-terrain collision algorithm. 
It's not complex, although it will take quite a lot of code, and it may 
be more efficient than COLLIDE - certainly more cost-effective, as it 
won't require preprocessing, hence won't interfere with dynamicism.