[ODE] Simulations running in real time?

Megan Fox shalinor at gmail.com
Tue Mar 29 09:44:34 MST 2005


deltaTime is, as you deduced, the frame time, the time passed since
the last cycle.  totalTime is just a variable that starts off at 0 to
which I add the deltaTIme each frame, and from which I subtract the
time step until it is below the time step's size.

I do this because it doesn't lose time this way.  Imagine if you had a
timestep of size 0.016, and then a delta time of 0.015 came up. 
Consistently.

You would want to carry that 0.015 to the next frame (because you
didn't have enough time to run a physics step yet), add the next delta
time, making your totalTime 0.03, and THEN run a physics step,
subtract your deltaTIme, and pass the remaining 0.014 total time into
the next cycle.

If you don't do it this way (or a similar way), you lose time, and
your system fails to operate in real-time.

-Megan Fox


On Tue, 29 Mar 2005 17:27:36 +0100, Chris Royce <croyce at ntlworld.com> wrote:
> In this example what is totalTime and deltaTime.
> 
> deltaTime is this the time taken for the simLoop method to be run ?
> 
> totalTime is defined as what.
> 
> Sorry im a little lost on which is which.
> 
> Cheers
> 
> Chris
> 
> ----- Original Message -----
> From: "Megan Fox" <shalinor at gmail.com>
> To: "Hampus Soderstrom" <hampus at sxp.se>
> Cc: <ode at q12.org>
> Sent: Monday, March 28, 2005 6:25 PM
> Subject: Re: [ODE] Simulations running in real time?
> 
> > Just use code something like this:
> >
> >    // Make sure time is accrued properly for the phys step count
> >    this->totalTime += deltaTime;
> >
> >    // Then advance the world up to present time
> >    unsigned int iters = 0;
> >    while(this->totalTime > PHYS_STEPSIZE)
> >    {
> >         // ... entity processing
> >
> >        nOpende::JointGroupEmpty(this->physContactJointGroupID);
> >        nOpende::SpaceCollide(this->physColSpaceID, this,
> > this->PhysCollisionCallback);
> >
> >        nOpende::WorldQuickStep(this->physWorldID, PHYS_STEPSIZE);
> >
> >        this->totalTime -= PHYS_STEPSIZE;
> >
> >        iters++;
> >    }
> >
> >
> > Very simple.  It runs ODE in real-time with a fixed timestep, without
> > loosing those fractions of a timestep you'll drop if you're just doing
> > "if deltatime > X"
> >
> > -Megan Fox
> >
> > On Mon, 28 Mar 2005 22:45:21 +0700, Hampus Soderstrom <hampus at sxp.se>
> > wrote:
> >> You could also lock he framerate to 60 pfs or something. On a computer
> >> that is too slow and can't keep up with the framerate you selected it
> >> will run slower though.
> >>
> >> 2005-03-28 kl. 20.28 skrev George Birbilis:
> >>
> >> > use multiple threads
> >> > see a paper at the Novodex website (now called Ageia or something),
> >> > search for Novodex SDK papers and at see the PDF about multithreading.
> >> > You can apply similar technique to ODE I suppose
> >> >
> >> > -----
> >> > George Birbilis (birbilis at kagi.com)
> >> > Microsoft Most Valuable Professional
> >> > MVP J# for 2004 & 2005
> >> > http://www.kagi.com/birbilis
> >> > --------------
> >> > ----- Original Message ----- From: "Chris Royce" <croyce at ntlworld.com>
> >> > To: "ode" <ode at q12.org>
> >> > Sent: Monday, March 28, 2005 4:10 PM
> >> > Subject: [ODE] Simulations running in real time?
> >> >
> >> >
> >> > Hello there I'm trying to get my simulation to run in real time,
> >> >
> >> > Basically the problem I'm having at the moment is that the simulation
> >> > is running at different speeds on different computers. I'm working in
> >> > C++ and using the drawStuff interface.
> >> >
> >> > I'm also noticing that by changing the dWorldStep value the motion
> >> > varies quite considerably, whereas I'd expected to run simply faster
> >> > or slower ?
> >> >
> >> > Thanks for any advice
> >> >
> >> > Chris
> >> >
> >> >
> >> > -----------------------------------------------------------------------
> >> > ---------
> >> >
> >> >
> >> >> _______________________________________________
> >> >> ODE mailing list
> >> >> ODE at q12.org
> >> >> http://q12.org/mailman/listinfo/ode
> >> >
> >> > _______________________________________________
> >> > ODE mailing list
> >> > ODE at q12.org
> >> > http://q12.org/mailman/listinfo/ode
> >> >
> >>
> >> _______________________________________________
> >> ODE mailing list
> >> ODE at q12.org
> >> http://q12.org/mailman/listinfo/ode
> >>
> > _______________________________________________
> > ODE mailing list
> > ODE at q12.org
> > http://q12.org/mailman/listinfo/ode
> >
> 
>


More information about the ODE mailing list