[ODE] Re: Heightfield / Collision.
skjold@cistron.nl
skjold at cistron.nl
Tue Feb 18 09:25:02 2003
Maths isn't among my strongest points, but isn't it possible to solve the intersection between a convex hull and some two-dimensional function? The function presents the transition between four neighbouring points in the heightfield, possibly using a selectable interpolation method (such as a linear variant for optimal performance, or a polynomial variant for improved accuracy).
If that is possible at an acceptable speed, then you wouldn't have to find the exact x and y coordinates in advance; they would result from the intersection calculation. All you would need to solve the intersection (aside from the maths expression of which I know very little) are a set of candidate points from the heightmap (possibly selected by use of bounding boxes like Amund suggests), and then find four or nine neighbouring ones among the candidates that are closest to the geometry being tested (or possibly already penetrating - in which case the check boils down to determining whether a point is inside a convex hull or not).
Again, I don't know if this is feasible as a real-time thing. Just brainstorming turning a gaze towards the maths gurus among us ;)
Greets,
Mark
> > 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.
>
> But, won't you be using a bounding box test first? Then the corners of
> the box would be four different points, right? Or do you use a
> sphere-test right away, ie distance from center=r? There has to be some
> way to do this with a heightmap as well, just find the highest points
> under the sphere and interpolate exact points later, maybe?