-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the FPS reported by Engine.get_frames_per_second()
smoother
#63356
base: master
Are you sure you want to change the base?
Conversation
f0d342e
to
8682301
Compare
8682301
to
342a789
Compare
342a789
to
cc5a0c2
Compare
8b2b0e6
to
ad72599
Compare
Rebased and tested again, it works as expected. I update the MRP in OP. A strange issue occurs now when the engine starts: the reported FPS is negative for a brief period of time. I don't recall this happening previously, despite having made no code changes to the PR itself. This is a video of the MRP being run at 120 FPS, slowed down to 10% so you can see it more easily: negative_fps.mp4This does not occur with the script-based implementation in the MRP. |
You probably want to make sure the ratio doesn't exceed 1.0 since you're subtracting it from 1.0 on the line below. |
That does the trick, thanks 🙂 |
This uses an averaging algorithm to smooth out the FPS counter.
ad72599
to
7826d68
Compare
This uses an averaging algorithm to smooth out the FPS counter. As a bonus, this also makes the reported FPS value an actual float, rather than returning a float constrained to integer steps.
This also improves the documentation a bit.
This PR can be remade for 3.6 if desired. See also #18998, which is an earlier attempt at providing something like this (with a different formula). The same formula is included in the MRP (but commented out) for reference.
Testing project: test_fps_counter.zip
Press Space to toggle between core and script-based FPS reporting. Use core-based reporting to test this PR (or the current behavior, with a vanilla
master
build).Press Up/Down arrows to increase/decrease maximum FPS. Note that it's capped by V-Sync for testing purposes, but you can disable V-Sync in the project settings or run with
--disable-vsync
CLI argument if needed.TODO
frame_time
actually defines (I've also triedprocess_ticks
to no avail). - For comparison, the script approach in the MRP does not have this issue.