-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This provides a better estimate of a typical frametime in reactive mode. From the docstring of `stable_dt`: Time since last frame (in seconds), but gracefully handles the first frame after sleeping in reactive mode. In reactive mode (available in e.g. `eframe`), `egui` only updates when there is new input or something animating. This can lead to large gaps of time (sleep), leading to large [`Self::unstable_dt`]. If `egui` requested a repaint the previous frame, then `egui` will use `stable_dt = unstable_dt;`, but if `egui` did not not request a repaint last frame, then `egui` will assume `unstable_dt` is too large, and will use `stable_dt = predicted_dt;`. This means that for the first frame after a sleep, `stable_dt` will be a prediction of the delta-time until the next frame, and in all other situations this will be an accurate measurement of time passed since the previous frame. Note that a frame can still stall for various reasons, so `stable_dt` can still be unusually large in some situations. When animating something, it is recommended that you use something like `stable_dt.min(0.1)` - this will give you smooth animations when the framerate is good (even in reactive mode), but will avoid large jumps when framerate is bad, and will effectively slow down the animation when FPS drops below 10.
- Loading branch information
Showing
3 changed files
with
54 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters