FixedTimeUpdate is a scheduler that runs systems at a fixed rate It is made to only be run a certain amount of times per second, skipping updates when the framerate is high and running multiple updates when the framerate is low. The time that passes is accumulated if the time between updates is greater than the tick rate or if there is a remainder from the last update(s).
More...
#include <FixedTimeUpdate.hpp>
|
| float | _tickRate |
| | The tick rate correspond to the number of update the scheduler should do in a second.
|
| float | _bufferedTime = 0.0f |
| | Buffered time since the last update, this allow to not lose time.
|
|
| static constexpr float | DEFAULT_TICK_RATE = 1.0f / 50.0f |
| | The default tick rate for the FixedTimeUpdate scheduler. It is set to 1/50 seconds, which means that the scheduler will run at 50 updates per second by default.
|
FixedTimeUpdate is a scheduler that runs systems at a fixed rate It is made to only be run a certain amount of times per second, skipping updates when the framerate is high and running multiple updates when the framerate is low. The time that passes is accumulated if the time between updates is greater than the tick rate or if there is a remainder from the last update(s).
- See also
- Engine::Scheduler::AScheduler
◆ FixedTimeUpdate()
Constructor of the FixedTimeUpdate scheduler. It takes a reference to the core and an optional tick rate. If the tick rate is not provided, it will be set to the default tick rate (DEFAULT_TICK_RATE).
- Parameters
-
| core | Reference to the core. |
| tickRate | The tick rate for the scheduler. It is the time in seconds between each update. It is recommended to set this value to a value that is a divisor of the frame time to avoid issues with the accumulation of time. For example, if the frame time is 16ms (60 FPS), it is recommended to set the tick rate to 1/60 seconds or 1/120 seconds. |
- See also
- Engine::Core
-
Engine::Scheduler::FixedTimeUpdate::DEFAULT_TICK_RATE
- Todo
- Put the implementation inside cpp file
◆ GetTickRate()
| float Engine::Scheduler::FixedTimeUpdate::GetTickRate |
( |
| ) |
const |
|
inline |
◆ RunSystems()
| void Engine::Scheduler::FixedTimeUpdate::RunSystems |
( |
void | | ) |
|
|
overridevirtual |
Interface for the schedulers. A scheduler is responsible for running systems according to a specific policy. Schedulers also manage how logic (system) should be handled.
- Todo
- Remove this interface and merge it with the AScheduler class.
Implements Engine::Scheduler::IScheduler.
◆ SetTickRate()
| void Engine::Scheduler::FixedTimeUpdate::SetTickRate |
( |
float | tickRate | ) |
|
|
inline |
Set the fixed tick rate.
- Parameters
-
| tickRate | The fixed tick rate |
- Note
- This can cause issues if the value is changed during an update. It is recommended to change this value before the update loop starts.
- See also
- Engine::Scheduler::FixedTimeUpdate::_tickRate
- Todo
- Put the implementation inside a cpp file (remove inline)
◆ _bufferedTime
| float Engine::Scheduler::FixedTimeUpdate::_bufferedTime = 0.0f |
|
private |
Buffered time since the last update, this allow to not lose time.
◆ _tickRate
| float Engine::Scheduler::FixedTimeUpdate::_tickRate |
|
private |
The tick rate correspond to the number of update the scheduler should do in a second.
◆ DEFAULT_TICK_RATE
| float Engine::Scheduler::FixedTimeUpdate::DEFAULT_TICK_RATE = 1.0f / 50.0f |
|
inlinestaticconstexprprivate |
The default tick rate for the FixedTimeUpdate scheduler. It is set to 1/50 seconds, which means that the scheduler will run at 50 updates per second by default.
The documentation for this class was generated from the following files: