From 0884268c5eea09c12ca86cbb619d49628850c26d Mon Sep 17 00:00:00 2001 From: Gordon McCann Date: Tue, 20 Jun 2023 12:02:24 -0400 Subject: [PATCH] Fix timestep for Graph updating to separate from rendering time. Needs further testing to confirm --- Specter/src/Specter/Core/SpectrumManager.cpp | 10 +++++++++- Specter/src/Specter/Core/SpectrumManager.h | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Specter/src/Specter/Core/SpectrumManager.cpp b/Specter/src/Specter/Core/SpectrumManager.cpp index 60a08d8..c2152c1 100644 --- a/Specter/src/Specter/Core/SpectrumManager.cpp +++ b/Specter/src/Specter/Core/SpectrumManager.cpp @@ -254,6 +254,12 @@ namespace Specter { void SpectrumManager::UpdateGraphs(const Timestep& step) { std::scoped_lock guard(m_managerMutex); + + m_graphTimeEllapsed += step; + //Don't update unless enough time has passed + if (m_graphTimeEllapsed < s_graphUpdateTime) + return; + uint64_t scalerVal; for (auto& graph : m_graphMap) { @@ -261,9 +267,11 @@ namespace Specter { if (scalerIter != m_scalerMap.end()) { scalerVal = scalerIter->second->value; - graph.second->UpdatePoints(step, scalerVal); + graph.second->UpdatePoints(m_graphTimeEllapsed, scalerVal); } } + + m_graphTimeEllapsed = 0.0; //Reset ellapsed time since last update } void SpectrumManager::ClearGraphs() diff --git a/Specter/src/Specter/Core/SpectrumManager.h b/Specter/src/Specter/Core/SpectrumManager.h index 22cda09..8a3be83 100644 --- a/Specter/src/Specter/Core/SpectrumManager.h +++ b/Specter/src/Specter/Core/SpectrumManager.h @@ -122,6 +122,10 @@ namespace Specter { GraphArgs m_nullGraphResult; //For handling bad query std::mutex m_managerMutex; //synchronization + + //Some scaler time stuff + double m_graphTimeEllapsed = 0.0; + static constexpr double s_graphUpdateTime = 60.0; //Fixed timestep for scaler graphs (seconds), TODO: make this user inputed }; }