Page 1 of 1

currentTimeStep issues

Posted: Sun Jul 07, 2013 4:24 pm
by horseshoe7
from the name of the property, currentTimeStep suggests to me that one can use this as a way to keep track of how many steps have occurred in the simulation. this therefore suggests that this value will either be the same, or greater than any other point in your code you access it.

Code: Select all

    // update the timestamp
    cpFloat timestamp = _space.currentTimeStep;

    // check if anything is new
    if(timestamp < _lastTimestamp)
        return; // this should never happen, and yet it does...
Have I misunderstood? How would I accomplish what I'm hoping to. i.e. 'simulated amount of time thus far' ??

Re: currentTimeStep issues

Posted: Sun Jul 07, 2013 10:22 pm
by slembcke
I guess the docs could be more clear on that, but it's the most current delta time value (the timestep) you passed to cpSpaceStep().

Re: currentTimeStep issues

Posted: Mon Jul 08, 2013 3:10 am
by horseshoe7
So if I wanted to keep track of 'simulation time' i could just subclass a ChipmunkSpace, add this property, and whenever step: is called, just add that to my new ivar?

UPDATE: I'll just answer my own question. Yes. This is what I did and it's working as expected. Thanks again for your speedy replies!