Jump to content
  • Advertisement
Sign in to follow this  
EternityZA

fixed timestep and slerp!?

This topic is 3447 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hey. i dont know if this is a very clear question. I dont realy know how to ask this but please bear with me my game has 2 main Threads 1. game logic and physics thread wich runs at a constant 100 iterations per sec 2. render thread which runs up to 60 fps in my render loop i interpolate all my vectors and unit quaternions between the current "physical state" and the previous "physical state" based on the time that has passed since the last physics loop iteration, for instance a time value of 0.6 implies 0.006 sec has passed since the last iteration and 0.004 sec is left before the next iteration will ooccur. with "physical state" i mean all the position vectors and unit quaternions representing rotation thats part of my scene graph. i use slerp to interpolate between the unit queternions, but i was wondering if this is realy the best thing to do? the way im currently doing it is not giving me the smooth animation i desire and my list of possible reasons i can think of is: 1. my logic about Fixed timestep and interpolation is wrong 2. slerp is not the best thing to use for interpolating between quaternions with such minor differences (100 different "physical state"'s per sec and interpolating between two seqeuntial ones) 3. my logic is correct and the problem lies in my code so i just have to work through it to find it what do you think is causing/is not causing my not so smoothed out animation? any other suggestions? thnx EDIT: if you cant answer any of it maybe someone can just confirm to me wheather or not Fixed timestep is supposed to be used with slerp at all? [Edited by - EternityZA on January 12, 2009 5:33:40 AM]

Share this post


Link to post
Share on other sites
Advertisement
I don't know what slerp is, but if you want a smooth animation in relation to the frames being displayed you need to find how much time it takes for the previous frame to be drawn, instead of going by how much time has elapsed since the last iteration. If it took the first time at say 7 milliseconds past the last iter, and the next one is 5 milliseconds past the iter, then really 8 milliseconds have gone by for that frame but only 5 is being registered. Hope this is what you're getting after.

Share this post


Link to post
Share on other sites
nevermind all that rambling i just had a simple mistake in my code that i kept on missing, sorry for making u read all that, my fixed timestep is working perfectly now :P

EDIT:

wel maybe not prefectly but close enough for now, no more in my animations staggering unles u look realy fine

Share this post


Link to post
Share on other sites
hi,

can you describe what kind of game it is and what is the situation where the problem is most obvious - how does it look?

can you tell what turned out to be the problem and how did you fix it - how the old situation looks now?


Quote:

1. game logic and physics thread wich runs at a constant 100 iterations per sec
2. render thread which runs up to 60 fps



i suppose the reason for high frequency of physic update is to avoid "tunneling"?

in my crystal ball, i see...
you problem is connected with high physics update. your CPU can not manage that amount of computations per second. what happens next is that your interpolation algorithm tries to smooth this lag and you are seeing a problem when you have increased number of objects interacting, i.e. when physics get computationally expensive for your CPU.

there should be no reason to run physics on higher frequency than that of video display. the interpolation could be used for interpolating collision detection as opposed to motion interpolation. even better, separate those really fast objects that cause trouble and handle their collision by projecting a vector, which then can be called "extrapolation", but take a note that this is about collision detection rather than motion.



to confirm if crystal ball tells the truth, try the following diagnostics:

1.) lower your physics update to 60Hz
2.) lower your physics update to 30Hz, 15Hz...

if such change directly impacts your problem and make it look less bad, then there you go

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!