Kirrana / xivlauncher_physics_plugin

7 stars 12 forks source link

Calculate physics dynamically regardless of ingame FPS #10

Closed rootdarkarchon closed 1 year ago

rootdarkarchon commented 1 year ago

This PR aims to make the physics of the game calculated dynamically based on the frames per second the game is currently running instead a fixed multiplier of 2/3/4 etc.

The AsmHooks have been removed and replaced with the basic Physics that was still present in the Plugin.

The functionality is simple: every Framework execution the Plugin compares the last Framework tick where Physics were allowed to be executed with the current tick. If the tick falls in the expected frame time with tolerance, physics processing is enabled. If not, it is disabled. While this leads to inconsistent Physics execution ticks if the frames are not exactly or approximately a multiplier of 60, it will still execute the physics in an approximately correct fashion.

The UI has been adjusted to remove the previous selectors for Frametimes and added a new Frame Tolerance slider (defaults to 2). The Frame tolerance allows for slightly varying frame times to stay consistent in physics execution, the default value of 2 is fine and typically does not need any adjustments.

Due to this change, the plugin works with any FPS the game will throw at it.