[ODE] Heightfield / Collision.
Micheál O'Brien
mobrien at europe.com
Wed Feb 19 07:31:01 2003
>
> > /--\
> > | | sphere
> > \__/
> > /\<-edge of two triangles
> > / \
> > / \<-triangle face
> > / \
> > /terrain \
> >
> > One thing is contact normals:
> > In this case we had just two possible normals: one to the upper
> > right, the other to the upper left. But you would the sphere expect
> > to bounce upwards. This is the sphere-edge collision.
>
> This is exactly the case I was thinking of, so let me attach a rough
(hand
> drawn) picture. I'm thinking that if the two resulting face contact
normals
> (green and blue) are combined, you do get the right resulting normal,
right?
>
Almost. In the case above the normal is correct, but in the case
when the sphere doesn't hit the edge straight on, the normal would
not be correct and the bounce might look strange.
____
/ N \ Sphere
| | |
___\__|_/___ Tangent plane
/\
/ \ Terrain
/ \
/ \
____
/ N \ Sphere
| \ | _/
\___\/_/ Tangent plane
_//\
/ / \ Terrain
/ \
/ \
If the second diagram isn't clear there's a better one at
http://www.peroxide.dk/download/tutorials/tut10/pics/pic12.jpg
The sphere can be considered to bounce off a tangent plane that
runs through the edge.
The normal can be got by subtracting the sphere centre from the
contact point and scaling the result to 1.
I appreciate all the effort ye are going to in order to produce a
generic heightfield collider. It's noble to produce something that
people can easily use rather than stuff that is pretty much
hardcoded for one landscape format which is what i've done with
Slickworm's heightfield collider.
I've changed Slickworm to use the BSD licence (rather than GPL as
it was previously). The code in CVS is now all labeled as BSD but there
won't be a 0.2.0 release until there's some gameplay. Feel free to use
code at leisure from the heightfield collider or any other part of
Slickworm.
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/slickworm/slickworm/src/
I've been planning to do a heightfield-capped cylinder for a while but
haven't started yet (I'm lazy, bite me!). I think it'll be useful for
others too.
Some caveats to be aware of with my heightfield collider are that it's
quite slow (judging from profile results, but be aware that my landscape
is quite detailed and it's not unusual for 16 or more triangles to get
tested against a wheel sphere) and that spheres can go through the
ground if they go fast enough (not a big problem for me).
Micheál
http://slickworm.sourceforge.net
(Website still says it's GPL, must update that to saying BSD license)