hi,
if you use fixed time steps in your game,
whether with your own physics library or Intel Havok, nVidia PhysX, Bullet, ODE...
you are most likely using this algorithm that deals with the maximum number of iterations in the following way:
//-------------------------- *** ORIGINAL algo - capping the NUMBER
cnt= 0;
time= 10;
maxSteps= 5;
while(time > 0 && cnt < maxSteps)
{
step(); cnt++;
time--;
}
//--------------------------
Iterations, cnt= 5
"Time left", time= 5
most might recognize that the inner part of your 'stepSimulation' function resembles this algorithm, best described here:
"Fix Your Timestep!"
now, the problem with its practical implementation is in that you have to guess the NUMBER, and it manifests in two ways under certain circumstances:
1.) guess was too low for target CPU - "moon gravity effect"
2.) no matter how high - on some target 'slow enough CPU' it will "spiral to death"
which is not a "real problem",
because you can sort it out in design-time, but the peculiar thing is that it also seem to try to deal with the reminder of the time after the iterations have finished, with -interpolation- , which i think only introduces the errors and its not really necessary?
//-----------------------------------------------------------------------------------------
i propose two solutions,
this practically solves both problems and removes any errors possibly introduced by "interpolation":
//-------------------------- *** 1st algo - scaling the TIME "inside"
cnt= 0;
time= 10;
scaleFactor= 1;
while(time > 0)
{
step(); cnt++;
time--; time-= scaleFactor;
}
//--------------------------
Iterations, cnt= 5
"Time left", time= 0
//-------------------------- *** 2st algo - capping the TIME "outside"
cnt= 0;
time= 10;
if(time > 5) time= 5;
while(time > 0)
{
step(); cnt++;
time--;
}
//--------------------------
Iterations, cnt= 5
"Time left", time= 0
there is "a paper" on this and there you can find practical implementation and copy/paste source code to REPLACE your existing algorithm, so this can be easily tested in 5-10 minutes, and the difference is very obvious:
"sampleTest.html"
in essence, these are the solutions related to these discussions:
http://www.gamedev.net/community/forums/..452753
http://www.gamedev.net/community/forums/..393475
what do you think?
does this approach solves some of your problems?
thank you,
gameBoX Linux
//-----------------------------------------------------------------------------------------
ApochPiQ,
Quote:For better or worse, people are powerfully impacted by presentation.
- absolutely,
how to make TAGS in this forum? are there buttons for TAGS like in other forums on the internet?
Quote:There are many places to submit such papers; a little bit of research can find several candidates for you, or you are free to ask where to publish it in a forum such as this one
- i cant find anything,
can someone give me a name or link or organization or some address?
[Edited by - abaraba1 on September 19, 2008 7:26:17 AM]