|
Unravel Engine C++ Reference
|
Class responsible for timers. More...
#include <simulation.h>
Public Types | |
| using | clock_t = std::chrono::steady_clock |
| using | timepoint_t = clock_t::time_point |
| using | duration_t = clock_t::duration |
| using | delta_t = std::chrono::duration<float> |
Public Member Functions | |
| simulation () | |
| void | run_one_frame (bool is_active) |
| Perform on frame computations with specified fps. | |
| void | reset_delta_clock () |
| auto | get_frame () const -> uint64_t |
| void | set_min_fps (uint32_t fps) |
| Set minimum frames per second. If fps goes lower than this, time will appear to slow. | |
| void | set_max_fps (uint32_t fps) |
| Set maximum frames per second. The engine will sleep if fps is higher than this. | |
| void | set_max_inactive_fps (uint32_t fps) |
| Set maximum frames per second when the application does not have input focus. | |
| void | set_time_smoothing_step (uint32_t step) |
| Set how many frames to average for timestep smoothing. | |
| auto | get_time_since_launch () const -> duration_t |
| Returns duration since launch. | |
| auto | get_fps () const -> float |
| Returns frames per second. | |
| auto | get_delta_time () const -> delta_t |
| Returns the delta time in seconds. | |
| void | set_time_scale (float time_scale=1.0f) |
| auto | get_time_scale () const -> float |
| auto | get_max_fps () const -> uint32_t |
| Returns the configured software FPS cap (0 means uncapped). | |
| auto | get_last_sleep_duration () const -> duration_t |
| Returns how long run_one_frame spent sleeping during the last call. Useful for stats overlays so they can distinguish actual CPU work from time spent in the software frame limiter. | |
Protected Attributes | |
| float | time_scale_ {1.0f} |
| uint32_t | min_fps_ = 0 |
| minimum/maximum frames per second | |
| uint32_t | max_fps_ = 0 |
| uint32_t | max_inactive_fps_ = 20 |
| std::vector< duration_t > | previous_timesteps_ |
| previous time steps for smoothing in seconds | |
| duration_t | timestep_ = duration_t::zero() |
| next frame time step in seconds | |
| duration_t | last_sleep_duration_ = duration_t::zero() |
| time spent sleeping inside the last run_one_frame call | |
| uint64_t | frame_ = 0 |
| current frame | |
| uint32_t | smoothing_step_ = 11 |
| how many frames to average for the smoothed time step | |
| timepoint_t | last_frame_timepoint_ = clock_t::now() |
| frame update timer | |
| timepoint_t | launch_timepoint_ = clock_t::now() |
| time point when we launched | |
Class responsible for timers.
Definition at line 19 of file simulation.h.
| using unravel::simulation::clock_t = std::chrono::steady_clock |
Definition at line 21 of file simulation.h.
| using unravel::simulation::delta_t = std::chrono::duration<float> |
Definition at line 24 of file simulation.h.
| using unravel::simulation::duration_t = clock_t::duration |
Definition at line 23 of file simulation.h.
| using unravel::simulation::timepoint_t = clock_t::time_point |
Definition at line 22 of file simulation.h.
| unravel::simulation::simulation | ( | ) |
Definition at line 9 of file simulation.cpp.
| auto unravel::simulation::get_delta_time | ( | ) | const -> delta_t |
Returns the delta time in seconds.
Definition at line 160 of file simulation.cpp.
| auto unravel::simulation::get_fps | ( | ) | const -> float |
Returns frames per second.
Definition at line 154 of file simulation.cpp.
| auto unravel::simulation::get_frame | ( | ) | const -> uint64_t |
Definition at line 124 of file simulation.cpp.
| auto unravel::simulation::get_last_sleep_duration | ( | ) | const -> duration_t |
Returns how long run_one_frame spent sleeping during the last call. Useful for stats overlays so they can distinguish actual CPU work from time spent in the software frame limiter.
Definition at line 181 of file simulation.cpp.
| auto unravel::simulation::get_max_fps | ( | ) | const -> uint32_t |
Returns the configured software FPS cap (0 means uncapped).
Definition at line 176 of file simulation.cpp.
| auto unravel::simulation::get_time_scale | ( | ) | const -> float |
Definition at line 171 of file simulation.cpp.
| auto unravel::simulation::get_time_since_launch | ( | ) | const -> duration_t |
Returns duration since launch.
Definition at line 149 of file simulation.cpp.
| void unravel::simulation::reset_delta_clock | ( | ) |
Drop smoothed history and restart the frame clock from now. Call when entering play simulation so a preceding hitch (domain reload, scene load) does not inflate subsequent deltas.
Definition at line 116 of file simulation.cpp.
| void unravel::simulation::run_one_frame | ( | bool | is_active | ) |
Perform on frame computations with specified fps.
Definition at line 17 of file simulation.cpp.
| void unravel::simulation::set_max_fps | ( | uint32_t | fps | ) |
Set maximum frames per second. The engine will sleep if fps is higher than this.
Definition at line 134 of file simulation.cpp.
| void unravel::simulation::set_max_inactive_fps | ( | uint32_t | fps | ) |
Set maximum frames per second when the application does not have input focus.
Definition at line 139 of file simulation.cpp.
| void unravel::simulation::set_min_fps | ( | uint32_t | fps | ) |
Set minimum frames per second. If fps goes lower than this, time will appear to slow.
Definition at line 129 of file simulation.cpp.
| void unravel::simulation::set_time_scale | ( | float | time_scale = 1.0f | ) |
Definition at line 166 of file simulation.cpp.
| void unravel::simulation::set_time_smoothing_step | ( | uint32_t | step | ) |
Set how many frames to average for timestep smoothing.
Definition at line 144 of file simulation.cpp.
|
protected |
current frame
Definition at line 148 of file simulation.h.
|
protected |
frame update timer
Definition at line 152 of file simulation.h.
|
protected |
time spent sleeping inside the last run_one_frame call
Definition at line 146 of file simulation.h.
|
protected |
time point when we launched
Definition at line 154 of file simulation.h.
|
protected |
Definition at line 138 of file simulation.h.
|
protected |
Definition at line 140 of file simulation.h.
|
protected |
minimum/maximum frames per second
Definition at line 136 of file simulation.h.
|
protected |
previous time steps for smoothing in seconds
Definition at line 142 of file simulation.h.
|
protected |
how many frames to average for the smoothed time step
Definition at line 150 of file simulation.h.
|
protected |
Definition at line 134 of file simulation.h.
|
protected |
next frame time step in seconds
Definition at line 144 of file simulation.h.