Engine²
Open-source game engine written in C++.
Loading...
Searching...
No Matches
RelativeTimeUpdate.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <entt/entt.hpp>
4
5#include <chrono>
6
8
9namespace Engine::Scheduler {
16 private:
19 inline static constexpr float DEFAULT_TARGET_TICK_RATE = 1.0f / 50.0f;
24 inline static constexpr float REMAINDER_THRESHOLD = 0.0001f;
25
26 public:
36 RelativeTimeUpdate(Core &core, float tickRate = DEFAULT_TARGET_TICK_RATE);
37
39 void RunSystems() override;
40
45 float GetTargetTickRate() const;
46
51 void SetTargetTickRate(float tickRate);
52
56 float GetCurrentDeltaTime() const;
57
58 private:
68 float _tickRate;
69
74 float _deltaTime = 0.0f;
75
79 float _bufferedTime = 0.0f;
80};
81} // namespace Engine::Scheduler
The core is the place where all the data of the engine is stored. It contains the registry (entities)...
Definition Core.hpp:33
AScheduler(Core &core)
Constructor of the AScheduler class.
Definition AScheduler.cpp:8
static constexpr float DEFAULT_TARGET_TICK_RATE
The default target tick rate for the RelativeTimeUpdate scheduler. It is set to 1/50 seconds,...
Definition RelativeTimeUpdate.hpp:19
float _bufferedTime
Time accumulated from the previous ticks that is less than the threshold. This time will be added to ...
Definition RelativeTimeUpdate.hpp:79
float _tickRate
The target tick rate for the scheduler. It is the maximum time we want between each system run....
Definition RelativeTimeUpdate.hpp:68
float GetTargetTickRate() const
Get the target tick rate.
Definition RelativeTimeUpdate.cpp:11
float GetCurrentDeltaTime() const
Get the current delta time.
Definition RelativeTimeUpdate.cpp:15
float _deltaTime
The current delta time. It is the time between the last system run and the current system run....
Definition RelativeTimeUpdate.hpp:74
static constexpr float REMAINDER_THRESHOLD
The threshold for the remainder time. If the remainder time is less than this threshold,...
Definition RelativeTimeUpdate.hpp:24
void RunSystems() override
Run the systems according to the scheduler policy.
Definition RelativeTimeUpdate.cpp:17
RelativeTimeUpdate(Core &core, float tickRate=DEFAULT_TARGET_TICK_RATE)
Constructor of the RelativeTimeUpdate scheduler. It takes a reference to the core and an optional tic...
Definition RelativeTimeUpdate.cpp:6
void SetTargetTickRate(float tickRate)
Set the target tick rate.
Definition RelativeTimeUpdate.cpp:13
Definition AScheduler.cpp:7