Because now you can try it out.
Here it is:
It includes the jitter compensation as well as physics based on the render time. So if the time changes or even stops, everything stops.
Edit: OH nearly forgot. You can move your own ship with WASD.
To not have to save past positions of the player ship I limited the time interpolation to only be able to stop time. Not run it backwards.
All i had to do after that is save the renderTime when the last render happend.
Then first run smoothTime.
And after that the physics calculation that calculates physics on the basis of elapsed time since last render instead of just elapsed time like it was before!
The jitter compensation introduces some "bounce" to the timeSmoothing. This is due to a change in latency also being registered as a massive jitter spike. I think that bounce isn't that bad. But one could make the algorithm indentify what is a jitter and what is a permanent change in latency.
I don't think this is needed though. As in real conditions jitter is all that actually happens and the jitter compensator adds enough buffer.
The fixed buffer is actually set to exactly 1 snapshot. This is the lowest it can go!
@cybercritic criticised my heavy use of constants. This is a problem yes. But I think most of those could be found by studying their relations, programatically and on the fly.
I work with regulators all the time and there you have a lot of constants you need to configure to get a system running. This problem is much less dynamic and we have much more, precise information than some of the stuff I work with.
I think either we can find direct relations to the settings. Like with the snapRate thing or the timeOffset = snapStep.
Or in the worser case have code adjust the settings based on real world conditions at the client.
Also. If you wonder why you break formation when you change speed. This is due to the change speed command being transmitted FTL to the server. But you receiving the packet takes some time.
For instance. You are at snapshot 104. The newest Snapshot on the Server is 122,
When you change speed you change the speed of your ship in snapshot 105. But the other ship changes speed in snaphot 123.
This is why you can shoot people that have already moved behind corners.
What my solution solves on the other hand is that you can keep formation even if your internet connection changes.
Edit: I should have put in a "speed of time" indicator in the top bar. O welp. You can see how time slows when your ship seems to fly slower but its speed is still the same.
Edit Edit: Sorry forgot the contrast thing.