Skip to main content
GameDev.net gamedev.net
🔒 Locked

Sync physics with FrameTime...

Started by ogracian May 20, 2003 at 7:22 PM 1 replies 250+ views
Original Post
ogracian
ogracian
Hello I am coding a "simple" pool sim and it works fine, but I cant figure out how can I syncronize my physics movement with my frame time, I mean, to integrate all my physics objects I use a STEP_TIME of 0.001f to get a accuarate simulation. But my trouble is that all my objects are moving at FIXED STEP_TIME(used to integrate)and not synced with FRAME_TIME. By the other hand I cant use a different STEP_TIME to integrate because it could hurt my sim. Please I appreciate any help about this. PS: STEP_TIME = time used to integrate in my physics engine. FRAME_TIME = time taked since last frame. Regards, Oscar
bzroom
bzroom
you can recursively call your physcis function


  
const float phystime = .001;
float timeleftover = 0;
const int maxinterations = 10;
int its;

while(1)
{
its = 0;
timeleftover += dimesincelastframe();
while (timeleftover > phystime && its < maxiterations)
{
its ++;
callphysics(phystime);
timeleftover -= phystime;
}
render();
}

eventualy u can get sucked into a recursive black hole, u call your physics more so the frame slows down so u call physics more and then ur frame slows down,a dn then u call your physics more, hten your frame slows down then you call your physics 1 millions times.

hope that helped

of cap you fram rates, and just call your physcis at that time interval




}

JohnBolton
JohnBolton
Could you do this each frame?

  
for ( t = 0; t < FRAME_TIME; t+= STEP_TIME )
{
//integrate

}


Can you improve your numerical integration so that longer interval is possible?
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.