[ODE] Re: Heightfield / Collision.

Nate W coding at natew.com
Tue Feb 18 12:01:02 2003


On Tue, 18 Feb 2003, Amund [ISO-8859-1] Børsand wrote:

> > Then the trick is finding the right X and Y coordinates for your
> > Z-and-normal lookup (assuming the height map builds on the XY plane, with
> > Z being "up").  If you have a sphere falling straight down toward a steep
> > section of terrain, how do you compute the X and Y for the contact point?  
> > You can't look straight down from the sphere's center, because steep
> > terrain is going to contact the sphere from the side.  Is there a fast way
> > to get the answer?  
> 
> Hmm, very good point indeed. But this would be no easier with triangles,
> unless the triangles on the ground are larger than the whole sphere.

Actually, there's a simple algorithm for edge-sphere intersection.  I
suppose you could run that test repeatedly, using all 8 possible edges
radiating from a given vertex to its neighbors... 

1	2	3
4	*	5
6	7	8

And maybe 4 more times for the 4-2, 2-5, 5-7, and 7-2 edges?  I'm making
this stuff up as I go along, but I think that might give a solution better
than any single triangle tiling - but with a performance penalty.

-- 

Nate Waddoups
Redmond WA USA
http://www.natew.com