[ODE] Rewinding time / backward time stepping
Martin C. Martin
martin at metahuman.org
Tue Sep 3 19:36:02 2002
Thomas Harte wrote:
>
> I am trying to greatly simplify the mesh on mesh collision problem by being able to
> move backward in time. The process will only ever be to have a particular point, to move
> forward from it and then possibly discard that forward motion and return to the original
> setting. I am wondering about the best way to achieve this.
Save the position and velocities of all bodies (and whatever geoms are
necessary), then after taking the step, if you want to rewind, simply set
the positions and velocities back to their original values.
Application specific code may get in the way though. For example, in my
application, I have a box where one end of it doesn't take part in
collisions. I implement this by having the geom be a little smaller than
the parameters used to compute the inertial matrix, and off center. My
application specific code updates the location of the geom itself after
each time step. In general, geoms can have any relation to bodies that
the application wants. This allows great flexibility, and great access to
the innards of ODE. So, if you want to keep in the same spirit, I think
you'll have to provide your functionality as a set of calls, and users
will have to write their own small wrappers around them. Just like
stepping the world. Or the near callback.
> This is the full definition of dWorldStep from the docs :
>
> "void dWorldStep(dWorldID, dReal stepsize);
>
> Step the world."
>
> So, am I allowed negative step sizes?
That won't put you back to the state before the last timestep. A
simulation like ODE loses information as it goes along. There isn't
enough information in the current state to determine what the previous
state was. For example, if a box slides and then comes to rest, its speed
is zero. Suppose it were zero for five seconds. To play this backward,
ODE would have to keep the speed zero for five seconds worth of timesteps,
then start it moving again. There's just no way for it to know how long
ago it was moving.
- Martin