Kirrana / xivlauncher_physics_plugin

7 stars 12 forks source link

Past 120 FPS physics seem to die out again #3

Closed Gaudrec closed 1 year ago

Gaudrec commented 2 years ago

Past 120 FPS physics seem to die out again. If i force the FPS to 120 or lower it works again with the plugin. Is there a way to manually adjust this to test with higher FPS?

Kirrana commented 2 years ago

Not super trivially no, the way it's implemented currently it effectively just flips a bit (actually 4 bytes iirc) every frame, and if the bit is flipped it skips the physics update for that frame, causing the physics to run at half frame rate, so 60FPS when the game is at 120FPS (which obviously just moves the problem, causing the physics to break above 120 again).

It should be possible to edit the assembly so that it counts up every frame and runs the physics update every n frames instead of every 2nd, letting the physics "work" at any FPS value that is a multiple of 60. Changing it to work at more arbitrary frame rates is something I currently have no clue how to do.

Unfortunately I don't currently have the time to look into this myself right now, but I think it should just be a matter of replacing the test opcode so it tests for the 4 bytes equaling n, replacing the negation with adding 1, and adding a reset to 0 if the test equaled n (and maybe adjusting jump offsets if this moves stuff around), or some smarter solution from someone actually good at assembly ^^.

Gaudrec commented 2 years ago

Is there anything i can change on my end in the files to test? And thank you for your time!

Kirrana commented 2 years ago

As far as I know the only way would be to edit HighFpsPhysicsPlugin.cs and then rebuild the plugin