[ODE] ODE behavior depends on frame rate. How to avoid this?
David McClurg
dmcclurg at pandemicstudios.com.au
Sun Feb 2 18:26:02 2003
I just realized that you don't have to run your collisions (dSpaceCollide()) at the same rate as your movement (dWorldStep()). You could run collisions every other or every third tick since they are so expensive but still run your movement every tick for visual smoothness.
that's a good thing imo for a simple game running in a single thread and needing some determinism for network play.
-----Original Message-----
From: David McClurg
Sent: Monday, 3 February 2003 10:36 AM
To: Sergey; ode@q12.org
Subject: RE: [ODE] ODE behavior depends on frame rate. How to avoid
this?
what about replacing
dWorldStep (worldID, fTimeBetweenFrames);
with...
while (simTime < curTime)
{
dWorldStep (worldID, simTick);
simTime += simTick;
}
where curTime is the current time, simTime is the accumulated simulation time, and simTick is a small constant increment.
sometimes with this approach you'll need to monitor the number of sim ticks per frame and if they oscillate back and forth like 1,2,1,2,1,2 you need to ideally make your sim tick smaller (1/120.f) or (1/180.f) or add some smoothing so it goes 1,1,1,2,2,2,1,1,1,2,2,2
-----Original Message-----
From: Sergey [mailto:sergey_eu@cea.ru]
Sent: Sunday, 2 February 2003 5:33 AM
To: ode@q12.org
Subject: [ODE] ODE behavior depends on frame rate. How to avoid this?
Hello,
I am creating simple arcade racing game and recently have faced the
following problem: ODE behavior depends on frame rate because I use
dWorldStep (worldID, fTimeBetweenFrames)
I've read suggestion to divide physics and render cycles: use thread
for physics step and use main game cycle for rendering, but this won't
work in my case because I use modified Windows messaging cycle
(PeekMessage () instead of GetMessage ()) and unfortunately threads
does not work with PeekMessage () :(
How can I avoid dependency on frame rate? Any suggestions are welcome.
Sergei.