Skip to content

Overhaul Fixed Update system #143

@SoloByte

Description

@SoloByte

I want to clean up everything regarding frame rate control. Currently, there are fps settings in WindowSettings and GameSettings. Additionally, the 2 api paths for Update and FixedUpdate complicate everything and introduce problems and bugs (see #141).
I want to remove the FixedUpdate() path completely and just use Update(). When delta times are too big substepping or accumulator and delta capping steps in.

Having Update() and FixedUpdate() makes only sense if you want to run your physics update at a lower rate then the rest. So you would run fixed at 60 fps and the rest at 120 fps for instance. But to make physics appear smooth you would have to use the interpolation function because the logical change of objects in FixedUpdate is no longer in sync with the visual appearance on screen in Draw. All of this is a lot of complexity. If you can run everything at 120 fps you dont need this and otherwise (if you cant run everything at 120fps) you would probably want to step down to 60fps for everything anyway (or something in between). So the only important thing for physics is to have predictable delta time (ideally always exactly the same).

GameTime will keep fixed setting but fixed step is no longer needed. I will also add the interpolation factor of substepping to the game time.

I am going to add FpsSettings:

  • FramerateLimit
  • UnfocusedFramerateLimit
  • IdleFramerateLimit
  • IdleThreshold
  • AdaptiveFpsLimiterSettings
  • New Stuff:
  • Max Delta Time (used for capping large delta times to this value at the beginning of the frame - prevents excessive substepping for instance)
  • MinFrameRateLimit
  • MaxSubsteps (if delta time can not be consumed with max substeps, then drop down to min frame rate limit and consume as much as possibe, up to max substeps) - If enabled interpolation factor will be set in GameTime.
  • FixedFrameRate? - will lock only the update loop into this framerate.

If fixed frame rate is not set then delta time limiting will still happen (first) and substeps will still smooth out large spikes/lags. There should be some threshold were no substepping happens (accumulator resets to 0).

  • Add Interpolation factor to GameTime (if it is still needed)
  • Remove FixedStep from GameTime
  • Create FpsSettings and remove fps related settings from the other structs.
  • Use FpsSettings
  • Remove entire FixedUpdate() api path
  • Implement new fixed system (should work with all the rest)

Metadata

Metadata

Assignees

Labels

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions