linuxgurugamer / BetterTimeWarpContinued

A Kerbal Space Program mod that enables customized time warping
Other
16 stars 5 forks source link

Max physics delta time is locked to 0.02 on lossless warp #20

Open Tuupertunut opened 5 years ago

Tuupertunut commented 5 years ago

This setting which lets us do more physics frames per gameplay frame is now locked into 0.02. This forces the game to draw a gameplay frame on every physics frame, improving framerate but slowing physics down on slower computers. I don't see how adding more gameplay frames is relevant to lossless warp, which should ideally just calculate an adjustable amount of physics frames for one gameplay frame.

linuxgurugamer commented 5 years ago

Physics delta time is not the same as lossless warp

Tuupertunut commented 5 years ago

That's correct, it isn't. But why is the setting "Max physics delta time per frame" locked into 0.02?

In case you don't know what this setting does, here's a nice explanation: https://forum.kerbalspaceprogram.com/index.php?/topic/132637-fps-and-physics-timesteps/

TLDR:

The physics timestep is always constant at 0.02 seconds (20 ms). Max physics delta time per frame tells how much game time the game can use to calculate physics frames before it is forced to draw a gameplay frame. 0.02 means max one physics frame before a forced gameplay frame, 0.04 means max two physics frames before a forced gameplay frame and so on.

So why is a time warp mod forcing the game to draw a gameplay frame between every physics frame?

linuxgurugamer commented 5 years ago

It only does that when Timescale is one (ie: no warping). I didn't write this, and would have to research it a bit. It may be a holdover from an earlier version of the game.

And yes, I do know what the setting does.

linuxgurugamer commented 5 years ago

Just an FYI, it's entirely possible that changing that can really mess things up. The mod is written around the idea of the timestep being 0.02, if it's not, then odd things may happen. This will need extensive testing to be sure

Tuupertunut commented 5 years ago

Ideas:

Where lossy (normal) time warp increases the timestep size, an ideal lossless warp should just calculate more physics frames in the same time period. Gameplay frames per real time second would stay the same and it would just fit more physics frames between two gameplay frames.

So if the user has selected 0.02 as the max physics delta time (max 1 physics frame between gameplay frames), then it would compute 2 phys frames at 2x time warp, 4 phys frames at 4x time warp and so on.

If the user has selected 0.06 as the max physics delta time (3 physics frames between gameplay frames), then it would compute 6 phys frames at 2x time warp, 12 phys frames at 4x time warp and so on.

This is assuming lossless warp accuracy of 1. On lower accuracies the timestep would be longer and amount of computed physics frames lower.