From 4a4f5a074878ec9dd17cc21d69442f0a04536cae Mon Sep 17 00:00:00 2001 From: OmniaX-Dev Date: Tue, 16 Jun 2026 07:22:54 +0200 Subject: [PATCH] Added uncapped mode to ostd::StepTimer --- other/build.nr | 2 +- src/ostd/utils/Time.cpp | 8 ++++++++ src/ostd/utils/Time.hpp | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/other/build.nr b/other/build.nr index 90403d9..ce21c02 100644 --- a/other/build.nr +++ b/other/build.nr @@ -1 +1 @@ -2095 +2096 diff --git a/src/ostd/utils/Time.cpp b/src/ostd/utils/Time.cpp index c806104..3b10b0a 100644 --- a/src/ostd/utils/Time.cpp +++ b/src/ostd/utils/Time.cpp @@ -599,12 +599,15 @@ namespace ostd StepTimer& StepTimer::create(f64 updatesPerSecond, StepTimer::Callback callback, bool stopped) { + if (updatesPerSecond == 0.0) + updatesPerSecond = -1.0; m_targetDt = 1.0 / updatesPerSecond; m_callback = std::move(callback); m_prevTime = Clock::now(); m_accumulator = 0.0; m_stopped = stopped; m_valid = true; + m_uncapped = (updatesPerSecond <= 0.0); return *this; } @@ -618,6 +621,11 @@ namespace ostd m_stopCallback(); return; } + if (m_uncapped) // set when updatesPerSecond <= 0, say + { + m_callback(1.0); //TODO: Calculate dt for uncapped, and replace the hardcoded 1.0 + return; + } TimePoint currentTime = Clock::now(); Duration frameDuration = currentTime - m_prevTime; diff --git a/src/ostd/utils/Time.hpp b/src/ostd/utils/Time.hpp index 52b56dd..77ec896 100644 --- a/src/ostd/utils/Time.hpp +++ b/src/ostd/utils/Time.hpp @@ -139,6 +139,7 @@ namespace ostd inline void invalidate(void) { m_valid = false; } inline bool isValid(void) const { return m_valid; } inline bool isStopped(void) const { return m_stopped; } + inline bool isUncapped(void) const { return m_uncapped; } private: TimePoint m_prevTime; @@ -149,6 +150,7 @@ namespace ostd f64 m_accumulator { 0.0 }; bool m_valid { false }; bool m_stopped { false }; + bool m_uncapped { false }; }; struct GameClock