[ODE] Geometry passing through / timestep size

Chris Campbell chris.campbell at l8tech.com
Tue Aug 6 20:45:02 2002


> 
> "I do it because my body moves fast, has few collisions and 
> passing through
> geometry
> is not acceptable (pod-racer type game). "
> 
> So have you already implemented this method of ensuring 
> objects don't pass
> through? If so, can you share it?
> 

Yeah it works ok so far. The main difference is just doing the collision
detection yourself. If you mean share source code I think that might be more
confusing than useful, so here's a slightly more detailed pseudocode of the
interaction with ode. For each body keep a position and lastPosition vec.

dWorldStep

lastPos = pos
pos = dBodyGetPosition
moved = pos - lastPos

d = fraction of moved travellable before colliding (between 0 - 1)
if (d < lengthOf(moved)) { //collision
	pos = lastPos + (max(0, d - epsilon)) * moved
	dBodySetPosition(pos)
	dContact* c
	set friction, bounce, position, normal etc in c as usual
	set depth of c to epsilon 
	dJointAttach(c, thisbody, 0) //in my case
}

add forces, torque etc as usual 

dWorldStep 

etc etc....

(The two epsilons don't need to be the same value.) As long as your CD code
gets the collision location and normal correct, you should get a realistic
looking reaction. Like Adam said there may be problems when two or more
bodies do this though. Perhaps after moving all bodies back to their first
point of collision the standard ode collision could be used to check them
for penetration into each other... seems feasible but I haven't tried it.

ChrisC