diff --git a/framework/common_components/src/mm/components/time_delta.hpp b/framework/common_components/src/mm/components/time_delta.hpp new file mode 100644 index 0000000..5bac2aa --- /dev/null +++ b/framework/common_components/src/mm/components/time_delta.hpp @@ -0,0 +1,17 @@ +#pragma once + +namespace MM::Components { + + // this is a context-variable / "component-singleton". + // it is used to retirve timing information about the tick. + // it is "read-only" for the systems and filled in by the service + // holding the scene. + struct TimeDelta { + float tickDelta = 1.f/60.f; + + // this is optionally filled in + // it turned out, that sound playback needs the factor + float deltaFactor = 1.f; + }; +} + diff --git a/framework/simple_scene/CMakeLists.txt b/framework/simple_scene/CMakeLists.txt index 0144553..af2963c 100644 --- a/framework/simple_scene/CMakeLists.txt +++ b/framework/simple_scene/CMakeLists.txt @@ -10,6 +10,7 @@ target_include_directories(simple_scene PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src" target_link_libraries(simple_scene engine + common_components ) if (BUILD_TESTING) diff --git a/framework/simple_scene/src/mm/services/simple_scene.cpp b/framework/simple_scene/src/mm/services/simple_scene.cpp index 7def818..3d4429d 100644 --- a/framework/simple_scene/src/mm/services/simple_scene.cpp +++ b/framework/simple_scene/src/mm/services/simple_scene.cpp @@ -1,7 +1,6 @@ #include "./simple_scene.hpp" -#include "spdlog/fmt/bundled/core.h" -//#include "../systems_container.hpp" +#include #include @@ -61,6 +60,10 @@ void SimpleSceneService::sceneFixedUpdate(Engine&) { size_t continuous_counter = 0; + auto& time_ctx = _scene->ctx_or_set(f_delta, delta_factor); + time_ctx.tickDelta = f_delta * delta_factor; + time_ctx.deltaFactor = delta_factor; + // TODO: this is just cancer while (_accumulator >= static_cast(dt)){ _accumulator -= static_cast(dt);