1
0
Fork 0
mirror of https://github.com/gwm17/Specter.git synced 2024-11-22 18:28:52 -05:00

Fix timestep for Graph updating to separate from rendering time. Needs further testing to confirm

This commit is contained in:
Gordon McCann 2023-06-20 12:02:24 -04:00
parent c12bcd9f0e
commit 0884268c5e
2 changed files with 13 additions and 1 deletions

View File

@ -254,6 +254,12 @@ namespace Specter {
void SpectrumManager::UpdateGraphs(const Timestep& step) void SpectrumManager::UpdateGraphs(const Timestep& step)
{ {
std::scoped_lock<std::mutex> guard(m_managerMutex); std::scoped_lock<std::mutex> guard(m_managerMutex);
m_graphTimeEllapsed += step;
//Don't update unless enough time has passed
if (m_graphTimeEllapsed < s_graphUpdateTime)
return;
uint64_t scalerVal; uint64_t scalerVal;
for (auto& graph : m_graphMap) for (auto& graph : m_graphMap)
{ {
@ -261,9 +267,11 @@ namespace Specter {
if (scalerIter != m_scalerMap.end()) if (scalerIter != m_scalerMap.end())
{ {
scalerVal = scalerIter->second->value; 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() void SpectrumManager::ClearGraphs()

View File

@ -122,6 +122,10 @@ namespace Specter {
GraphArgs m_nullGraphResult; //For handling bad query GraphArgs m_nullGraphResult; //For handling bad query
std::mutex m_managerMutex; //synchronization 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
}; };
} }