-
Emil Ernerfeldt authored
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.
Emil Ernerfeldt authoredThis 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.
To find the state of this project's repository at the time of any of these versions, check out the tags.
Loading