Commit 045d054e authored by Sreekanth Arikatla's avatar Sreekanth Arikatla

Merge branch 'displayPhysicsFPS' into 'master'

ENH: Display fps on the screen along with the render fps

See merge request !305
parents fa7d2f16 51c5d7bd
Pipeline #138886 failed with stage
in 0 seconds
...@@ -166,6 +166,12 @@ public: ...@@ -166,6 +166,12 @@ public:
/// ///
void reset(); void reset();
///
/// \brief Set/Get the FPS
///
void setFPS(const size_t fps) { m_fps = fps; }
size_t getFPS() { return m_fps; }
protected: protected:
std::string m_name; ///> Name of the scene std::string m_name; ///> Name of the scene
...@@ -178,6 +184,8 @@ protected: ...@@ -178,6 +184,8 @@ protected:
std::vector<std::shared_ptr<SolverBase>> m_solvers; ///> List of non-linear solvers std::vector<std::shared_ptr<SolverBase>> m_solvers; ///> List of non-linear solvers
std::vector<std::shared_ptr<SceneObjectControllerBase>> m_objectControllers; ///> List of controllers std::vector<std::shared_ptr<SceneObjectControllerBase>> m_objectControllers; ///> List of controllers
size_t m_fps = 0;
bool m_isInitialized = false; bool m_isInitialized = false;
}; };
} // imstk } // imstk
......
...@@ -83,18 +83,29 @@ VTKInteractorStyle::OnTimer() ...@@ -83,18 +83,29 @@ VTKInteractorStyle::OnTimer()
// Update framerate value display // Update framerate value display
auto now = std::chrono::high_resolution_clock::now(); auto now = std::chrono::high_resolution_clock::now();
double fps = 1e6/(double)std::chrono::duration_cast<std::chrono::microseconds>(now - m_pre).count(); double fps = 1e6 / (double)std::chrono::duration_cast<std::chrono::microseconds>(now - m_pre).count();
fps = 0.1 * fps + 0.9 * m_lastFps; fps = 0.1 * fps + 0.9 * m_lastFps;
m_lastFps = fps; m_lastFps = fps;
int t = std::chrono::duration_cast<std::chrono::milliseconds>(now - m_lastFpsUpdate).count(); int t = std::chrono::duration_cast<std::chrono::milliseconds>(now - m_lastFpsUpdate).count();
if (t > 100) //wait 100ms before updating displayed value if (t > 250) //wait 250ms before updating displayed value
{ {
std::string fpsStr = std::to_string((int)fps) + " fps"; std::string fpsVisualStr = "V: " + std::to_string((int)fps);
m_fpsActor->SetInput(fpsStr.c_str());
std::string fpsPhysicalStr;
if (m_simManager->getStatus() != SimulationStatus::PAUSED)
{
fpsPhysicalStr = "P: " + std::to_string((int)m_simManager->getActiveScene()->getFPS());
}
else
{
fpsPhysicalStr = "P: PAUSED";
}
m_fpsActor->SetInput((fpsVisualStr + std::string(" | ") + fpsPhysicalStr).c_str());
m_lastFpsUpdate = now; m_lastFpsUpdate = now;
} }
m_pre = now; m_pre = now;
// Render // Render
this->Interactor->Render(); this->Interactor->Render();
m_post = std::chrono::high_resolution_clock::now(); m_post = std::chrono::high_resolution_clock::now();
......
...@@ -180,6 +180,8 @@ SceneManager::runModule() ...@@ -180,6 +180,8 @@ SceneManager::runModule()
} }
} }
} }
m_scene->setFPS((size_t)(1./wwt.getTimeElapsed(StopWatch::TimeUnitType::seconds)));
} }
void void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment