Handling time in a physics engine?

Started by
4 comments, last by aggieblue92 10 years ago

When building a physics engine, how do we handle simulation time, how can it be controlled from system to system (different hardware), how is it maintained? Can you also explain to me the most efficient way to handle frame data, for backtracking and so on.

Thanks in advance.

Cheers!!

Advertisement

You often use a fix simulation step timeframe (eg 20 ms). A longer frame time would result in more simulation steps in a single frame, and really fast FPS would result in skipping the simulation for some frames.

PS: writing your own physics engine is really hard and frustrating, I would suggest to think about using an existing physics engine. There are many engines around like the free bullet physics engine

Am doing this, only to brush up and strengthen my skills here and there. How do we find a balance?

When building a physics engine, how do we handle simulation time, how can it be controlled from system to system (different hardware), how is it maintained? Can you also explain to me the most efficient way to handle frame data, for backtracking and so on.

Thanks in advance.

Cheers!!

These two articles do a good job of introducing the topic:

- Fix Your Timestep! by Glenn Fiedler

- deWiTTERS Game Loop by Koen Witters

There is not a "most efficient way", it depends on a number of factors. You have to find out on your own the way that suits your scenario best.

Thanks :)

Kudos on building your own, it is rewarding and empowering for a programmer. You're in for a wild ride though, so I'd recommend reading Game Physics Engine Development by Ian Millington (http://www.amazon.com/gp/aw/d/0123819768/ref=mp_s_a_1_1?qid=1396511885&sr=8-1&pi=SY200_QL40)

It's really good, has great examples and aimed toward first time physics engine developers. It's missing a bit on rigid body contact resolution in terms of code samples, but all the theory is there.

Best of luck! I'm just finishing my custom physics engine and can honestly say it was worth it, for me at least.

This topic is closed to new replies.

Advertisement