Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

d000hg

Updating physics at a fixed time interval in windows

This topic is 5249 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

I''m writing my physics engine and I have a choice: 1)Let you update a body with the elapsed time since last update and scale the linear and angular velocity accordingly. I can do this but scaling a the angle rotated around an axis for quaternions requires an acos() for each body each update, not good. 2)Run the physics updates on the assumption that the frames are at a constant interval. To do the math it doesn''t matter if they actually are but it''ll look bad if the rate keeps changing. So how can I update the physics independantly from graphics which is just running as fast as possible on the remaining cycles? In DOS you could hook the timer interrupt but I''m with Win/DX. I have used windows API timers before but I''ve heard they''re not accurate. If you missed a timer event due to really slow fps would it get queued so you''d have two to deal with at once or just lost? I''d want the physics to update at 50-100fps; can windows timers take this? Can you recommend which option is better and help me out about my problems with option2? Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
1) If you use elapsed time you can get a smoother result by using the average of the last few frames.
2) You might find this flipcode article and the following discussion to be of help.


pan narrans | My Website | Study + Hard Work + Loud Profanity = Good Code

Share this post


Link to post
Share on other sites
Yes that''s one option which avoids messing about with timers.
Out of interest, is my concern about acos() with a variable time system valid? Are they that bad to perform compared to doing the whole physics update 3 times per rendered frame? Although collision deteection maybe needs running that frequently anyway...

Share this post


Link to post
Share on other sites

  • 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!