Unravel Engine C++ Reference
Loading...
Searching...
No Matches
unravel::simulation Struct 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.
 
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
 

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_tprevious_timesteps_
 previous time steps for smoothing in seconds
 
duration_t timestep_ = duration_t::zero()
 next frame time step in seconds
 
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
 

Detailed Description

Class responsible for timers.

Definition at line 19 of file simulation.h.

Member Typedef Documentation

◆ clock_t

using unravel::simulation::clock_t = std::chrono::steady_clock

Definition at line 21 of file simulation.h.

◆ delta_t

using unravel::simulation::delta_t = std::chrono::duration<float>

Definition at line 24 of file simulation.h.

◆ duration_t

using unravel::simulation::duration_t = clock_t::duration

Definition at line 23 of file simulation.h.

◆ timepoint_t

using unravel::simulation::timepoint_t = clock_t::time_point

Definition at line 22 of file simulation.h.

Constructor & Destructor Documentation

◆ simulation()

unravel::simulation::simulation ( )

Definition at line 10 of file simulation.cpp.

Member Function Documentation

◆ get_delta_time()

auto unravel::simulation::get_delta_time ( ) const -> delta_t

Returns the delta time in seconds.

Definition at line 139 of file simulation.cpp.

◆ get_fps()

auto unravel::simulation::get_fps ( ) const -> float

Returns frames per second.

Definition at line 133 of file simulation.cpp.

◆ get_frame()

auto unravel::simulation::get_frame ( ) const -> uint64_t

Definition at line 103 of file simulation.cpp.

◆ get_time_scale()

auto unravel::simulation::get_time_scale ( ) const -> float

Definition at line 150 of file simulation.cpp.

◆ get_time_since_launch()

auto unravel::simulation::get_time_since_launch ( ) const -> duration_t

Returns duration since launch.

Definition at line 128 of file simulation.cpp.

◆ run_one_frame()

void unravel::simulation::run_one_frame ( bool is_active)

Perform on frame computations with specified fps.

Definition at line 18 of file simulation.cpp.

◆ set_max_fps()

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 113 of file simulation.cpp.

◆ set_max_inactive_fps()

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 118 of file simulation.cpp.

◆ set_min_fps()

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 108 of file simulation.cpp.

◆ set_time_scale()

void unravel::simulation::set_time_scale ( float time_scale = 1.0f)

Definition at line 145 of file simulation.cpp.

◆ set_time_smoothing_step()

void unravel::simulation::set_time_smoothing_step ( uint32_t step)

Set how many frames to average for timestep smoothing.

Definition at line 123 of file simulation.cpp.

Member Data Documentation

◆ frame_

uint64_t unravel::simulation::frame_ = 0
protected

current frame

Definition at line 123 of file simulation.h.

◆ last_frame_timepoint_

timepoint_t unravel::simulation::last_frame_timepoint_ = clock_t::now()
protected

frame update timer

Definition at line 127 of file simulation.h.

◆ launch_timepoint_

timepoint_t unravel::simulation::launch_timepoint_ = clock_t::now()
protected

time point when we launched

Definition at line 129 of file simulation.h.

◆ max_fps_

uint32_t unravel::simulation::max_fps_ = 0
protected

Definition at line 115 of file simulation.h.

◆ max_inactive_fps_

uint32_t unravel::simulation::max_inactive_fps_ = 20
protected

Definition at line 117 of file simulation.h.

◆ min_fps_

uint32_t unravel::simulation::min_fps_ = 0
protected

minimum/maximum frames per second

Definition at line 113 of file simulation.h.

◆ previous_timesteps_

std::vector<duration_t> unravel::simulation::previous_timesteps_
protected

previous time steps for smoothing in seconds

Definition at line 119 of file simulation.h.

◆ smoothing_step_

uint32_t unravel::simulation::smoothing_step_ = 11
protected

how many frames to average for the smoothed time step

Definition at line 125 of file simulation.h.

◆ time_scale_

float unravel::simulation::time_scale_ {1.0f}
protected

Definition at line 111 of file simulation.h.

◆ timestep_

duration_t unravel::simulation::timestep_ = duration_t::zero()
protected

next frame time step in seconds

Definition at line 121 of file simulation.h.


The documentation for this struct was generated from the following files: