[ODE] Collision triangle culling
Ruud van Gaal
ruud at marketgraph.nl
Wed Dec 5 15:06:01 2001
Hi all,
I have the following situation: in my carsim I have tracks with fences that are
made of 2 polygons; one for each direction it faces (there are no doublesided
faces).
I have an (ODE) OBB for the car body and create an ODE plane when I detect a
hit of the OBB with a track (or fence) triangle. This is done with AABBtrees so
it's quite ok; mostly 0 triangles are even checked, and the tree gets down to
the correct potential triangles in O(logN).
Now the car hits a fence; when colliding with the wrong side (polygon) of the
fence, the normal is flipped, and ODE thinks the OBB is way inside the triangle
(understandably). The result is a fierce push dragging the car *through* the
triangle.
At first I thought I could solve this by checking the car's velocity w.r.t. the
triangle's normal (normal dot car linear velocity for a rough check). This
works a little bit, but as ODE allows penetrations, the *next* step, the car is
still somewhat inside both fence triangles, but this time, it's moving OUT the
fence (because of the previously generated contact points).
Now, the reverse is happening. The car is moving into the other direction
(correctly) but this causes my 'normal dot car velocity' to indicate the OTHER
triangle should now be checked. Since the car isn't taken out of the
penetration entirely, the next collision check indicates the car is very far
into the triangle, and we still get an explosion.
What I've done now is to check both the car's velocity (in the direction of the
fence triangle's normal), and a penetration depth that looks weird; for
example, if(penetration_depth>0.5 (meter) ) then forget about this contact
point. Still, this looks awfully hacked.
Does anybody have a suggestion on how to tackle this? Using just 1 polygon for
the fence doesn't seem an option, as I must pick 1 face normal when the car
hits the triangle from the one or the other side (btw I create the contact
points using ODE's dCollide() with the OBB of the car and the plane of the
triangle).
Thanks, and I hope this is clear enough,
Ruud