diff --git a/include/vsg/app/Viewer.h b/include/vsg/app/Viewer.h index f92f44de3..60771008c 100644 --- a/include/vsg/app/Viewer.h +++ b/include/vsg/app/Viewer.h @@ -96,6 +96,14 @@ namespace vsg /// hint for setting the FrameStamp::simulationTime to time since start_point() static constexpr double UseTimeSinceStartPoint = std::numeric_limits::max(); + /// get next time point in Viewer::advanceToNextFrame() + /// The standard implemnentation advances to the actual time by using vsg::clock::now() + virtual clock::time_point advanceToNextTimePoint(); + + /// hook for Viewer::advanceToNextFrame() for advancing to next tasks, layers etc. + /// The default implementation advances to the next tasks + virtual void advanceToNextFrameHook(); + /// Convenience method for advancing to the next frame. /// Check active status, return false if viewer no longer active. /// If still active, poll for pending events and place them in the Events list and advance to the next frame, generate updated FrameStamp to signify the advancement to a new frame and return true. diff --git a/src/vsg/app/Viewer.cpp b/src/vsg/app/Viewer.cpp index dd0594ff6..c36119fb6 100644 --- a/src/vsg/app/Viewer.cpp +++ b/src/vsg/app/Viewer.cpp @@ -150,6 +150,19 @@ bool Viewer::pollEvents(bool discardPreviousEvents) return result; } +clock::time_point Viewer::advanceToNextTimePoint() +{ + return vsg::clock::now(); +} + +void Viewer::advanceToNextFrameHook() +{ + for (auto& task : recordAndSubmitTasks) + { + task->advance(); + } +} + bool Viewer::advanceToNextFrame(double simulationTime) { static constexpr SourceLocation s_frame_source_location{"Viewer advanceToNextFrame", VsgFunctionName, __FILE__, __LINE__, COLOR_VIEWER, 1}; @@ -168,7 +181,7 @@ bool Viewer::advanceToNextFrame(double simulationTime) if (!acquireNextFrame()) return false; // create FrameStamp for frame - auto time = vsg::clock::now(); + auto time = advanceToNextTimePoint(); if (!_frameStamp) { _start_point = time; @@ -192,10 +205,7 @@ bool Viewer::advanceToNextFrame(double simulationTime) // signal to instrumentation the start of frame if (instrumentation) instrumentation->enterFrame(&s_frame_source_location, frameReference, *_frameStamp); - for (auto& task : recordAndSubmitTasks) - { - task->advance(); - } + advanceToNextFrameHook(); // create an event for the new frame. _events.emplace_back(new FrameEvent(_frameStamp));