change time factor behaviour to allow editing

This commit is contained in:
Green Sky 2021-02-03 16:35:37 +01:00
parent 8e757af8d1
commit 7912b58108
4 changed files with 7 additions and 9 deletions

View File

@ -95,9 +95,8 @@ void OrganizerSceneService::sceneFixedUpdate(Engine&) {
size_t continuous_counter = 0;
auto& time_ctx = _scene->ctx_or_set<MM::Components::TimeDelta>(f_delta, delta_factor);
time_ctx.tickDelta = f_delta * delta_factor;
time_ctx.deltaFactor = delta_factor;
auto& time_ctx = _scene->ctx_or_set<MM::Components::TimeDelta>(f_delta, initial_delta_factor);
time_ctx.tickDelta = f_delta * time_ctx.deltaFactor;
// TODO: this while is just cancer
while (_accumulator >= static_cast<decltype(_accumulator)>(dt)){

View File

@ -21,7 +21,7 @@ namespace MM::Services {
public:
const float f_delta;
float delta_factor = 1.f;
float initial_delta_factor = 1.f;
public: // service
explicit OrganizerSceneService(const float update_delta = 1.f/60.f) : f_delta(update_delta) {}

View File

@ -60,9 +60,8 @@ void SimpleSceneService::sceneFixedUpdate(Engine&) {
size_t continuous_counter = 0;
auto& time_ctx = _scene->ctx_or_set<MM::Components::TimeDelta>(f_delta, delta_factor);
time_ctx.tickDelta = f_delta * delta_factor;
time_ctx.deltaFactor = delta_factor;
auto& time_ctx = _scene->ctx_or_set<MM::Components::TimeDelta>(f_delta, initial_delta_factor);
time_ctx.tickDelta = f_delta * time_ctx.deltaFactor;
// TODO: this is just cancer
while (_accumulator >= static_cast<decltype(_accumulator)>(dt)){
@ -70,7 +69,7 @@ void SimpleSceneService::sceneFixedUpdate(Engine&) {
continuous_counter++;
::MM::EachSystemInScene(*_scene, [&](::MM::Scene& s, ::MM::System& fn) {
fn(s, f_delta * delta_factor);
fn(s, time_ctx.tickDelta);
});
TracyPlot("MM::Services::SimpleSceneService::_scene.alive", (int64_t)_scene->alive());

View File

@ -19,7 +19,7 @@ namespace MM::Services {
public:
const float f_delta;
float delta_factor = 1.f;
float initial_delta_factor = 1.f;
public:
explicit SimpleSceneService(const float update_delta = 1.f/60.f) : f_delta(update_delta) {}