diff --git a/library/src/interactor_impl.cxx b/library/src/interactor_impl.cxx index 315b24bcdb..0a4451e8c6 100644 --- a/library/src/interactor_impl.cxx +++ b/library/src/interactor_impl.cxx @@ -11,6 +11,7 @@ #include "vtkF3DInteractorStyle.h" #include "vtkF3DRenderer.h" #include "vtkF3DUIObserver.h" +#include "vtkF3DUIActor.h" #include #include @@ -1136,6 +1137,11 @@ void interactor_impl::start(double loopTime, std::function userCallBack) this->Internals->EventLoopUserCallBack = std::move(userCallBack); } + vtkRenderWindow* renWin = this->Internals->Window.GetRenderWindow(); + vtkF3DRenderer* ren = + vtkF3DRenderer::SafeDownCast(renWin->GetRenderers()->GetFirstRenderer()); + ren->SetUIDeltaTime(loopTime); + this->Internals->AnimationManager->SetInteractorEventLoopTime(loopTime); this->Internals->EventLoopTimerId = this->createTimerCallBack(loopTime, [this]() { this->EventLoop(); }); this->Internals->VTKInteractor->Start(); diff --git a/vtkext/private/module/vtkF3DImguiActor.cxx b/vtkext/private/module/vtkF3DImguiActor.cxx index 3ebe96de3e..d79e640296 100644 --- a/vtkext/private/module/vtkF3DImguiActor.cxx +++ b/vtkext/private/module/vtkF3DImguiActor.cxx @@ -471,3 +471,10 @@ void vtkF3DImguiActor::EndFrame(vtkOpenGLRenderWindow* renWin) ImGui::Render(); this->Pimpl->RenderDrawData(renWin, ImGui::GetDrawData()); } + +//---------------------------------------------------------------------------- +void vtkF3DImguiActor::SetDeltaTime(double time) +{ + ImGuiIO& io = ImGui::GetIO(); + io.DeltaTime = time / 1000; +} diff --git a/vtkext/private/module/vtkF3DImguiActor.h b/vtkext/private/module/vtkF3DImguiActor.h index efefc5fceb..d38ddd46ed 100644 --- a/vtkext/private/module/vtkF3DImguiActor.h +++ b/vtkext/private/module/vtkF3DImguiActor.h @@ -31,6 +31,11 @@ class vtkF3DImguiActor : public vtkF3DUIActor */ void ReleaseGraphicsResources(vtkWindow* w) override; + /** + * Set imgui::DeltaTime, with time in ms + */ + void SetDeltaTime(double time) override; + protected: vtkF3DImguiActor(); ~vtkF3DImguiActor() override; diff --git a/vtkext/private/module/vtkF3DRenderer.cxx b/vtkext/private/module/vtkF3DRenderer.cxx index 41f0780827..d0f08618bf 100644 --- a/vtkext/private/module/vtkF3DRenderer.cxx +++ b/vtkext/private/module/vtkF3DRenderer.cxx @@ -2621,3 +2621,9 @@ void vtkF3DRenderer::SetCheatSheetConfigured(bool flag) { this->CheatSheetConfigured = flag; } + +//---------------------------------------------------------------------------- +void vtkF3DRenderer::SetUIDeltaTime(double time) +{ + this->UIActor->SetDeltaTime(time); +} diff --git a/vtkext/private/module/vtkF3DRenderer.h b/vtkext/private/module/vtkF3DRenderer.h index 4a32f79e1a..19f5806fb3 100644 --- a/vtkext/private/module/vtkF3DRenderer.h +++ b/vtkext/private/module/vtkF3DRenderer.h @@ -371,6 +371,11 @@ class vtkF3DRenderer : public vtkOpenGLRenderer */ void SetCheatSheetConfigured(bool flag); + /** + * Set the UI delta time (time between frame being rendered) in ms + */ + void SetUIDeltaTime(double time); + private: vtkF3DRenderer(); ~vtkF3DRenderer() override; diff --git a/vtkext/private/module/vtkF3DUIActor.h b/vtkext/private/module/vtkF3DUIActor.h index eb05731fcc..d090863e3d 100644 --- a/vtkext/private/module/vtkF3DUIActor.h +++ b/vtkext/private/module/vtkF3DUIActor.h @@ -91,6 +91,11 @@ class vtkF3DUIActor : public vtkProp */ int RenderOverlay(vtkViewport* vp) override; + /** + * Set the delta time (time between UI frames) in ms + */ + virtual void SetDeltaTime(double time) {} + protected: vtkF3DUIActor(); ~vtkF3DUIActor() override;