[ODE] Re: Heightfield / Collision.

Amund Børsand amund at c2i.net
Tue Feb 18 05:49:02 2003


<skjold@cistron.nl> skreiv:

> Actually, on a side note, I'm wondering if it's really desirable to
> use triangles for collisions when it comes to heightfields. Like you
> illustrate below, the same heightfield can be drawn using triangles
> in several ways, but it all boils down to drawing an approximation
> much like the way you do with spheres and cylinders, which you
> usually smooth out with some shading technique (e.g. goroud).

> The actual heightfield is a 'sampling' at some resolution, that
> represents a smooth, unfaceted terrain. Isn't it possible to test for
> intersections against some form of interpolation function (e.g.
> bilinear or bicubic), instead of triangles? Wouldn't colliding

That's what I meant, but I don't know if my reply ever got to the list,
as I always forget to change the adress to ode@q12.org, instead of a
private reply..

My thoughts were that such a test would be extremely quick for any point
in the map, which could be calculated instantaneously (or by looking up
the 4 nearest vertices/heights, which would be just an array lookup if
you have equal vertex spacing), instead of with triangles, where you'd
have to seek through a lot of triangles to find which triangle the point
lies within, before you could interpolate it linearly to get the exact
height of the point. Come to think of it, bilinear or bicubic
interpolation should be just as possible here. The only trouble is the
lookup, as I see it.

> against a relief made of triangles cause unexpected bouncing
> behaviour that awkwardly gives away this granularity? I don't know
> much about collision detection, really. I was just wondering.

If it's done correctly there should be no more "bouncing" with triangles
than with a heightfield, there are no holes or gaps between the
triangles (if they are connected of course). You would run into further
problems if let's say the terrain has more levels (a parking garage with
several floors above eachother, for instance, how can the collision
routine find out which floor you are "colliding" with?). But of course,
if you need terrain/world that has a tunnel, for instance, a bridge, or
any surface that is steeper than 90 degrees (that is, "inwards"), you'd
need full triangle collision detection.