diff --git a/include/openspace/interaction/sessionrecording.h b/include/openspace/interaction/sessionrecording.h index 6e7167e8b3..bc3adea797 100644 --- a/include/openspace/interaction/sessionrecording.h +++ b/include/openspace/interaction/sessionrecording.h @@ -145,6 +145,19 @@ public: */ std::chrono::steady_clock::time_point currentPlaybackInterpolationTime() const; + /** + * Returns the simulated application time. This simulated application time is only + * used when playback is set to be in the mode where a screenshot is captured with + * every rendered frame (enableTakeScreenShotDuringPlayback() is used to enable this + * mode). At the start of playback, this timer is set to the value of the current + * applicationTime function provided by the window delegate (used during normal + * mode or playback). However, during playback it is incremented by the fixed + * framerate of the playback rather than the actual clock value. + * + * \returns application time in seconds, for use in playback-with-frames mode + */ + double currentApplicationInterpolationTime() const; + /** * Starts a recording session, which will save data to the provided filename * according to the data format specified, and will continue until recording is @@ -719,6 +732,7 @@ protected: double _saveRenderingCurrentRecordedTime; std::chrono::steady_clock::duration _saveRenderingDeltaTime_interpolation_usec; std::chrono::steady_clock::time_point _saveRenderingCurrentRecordedTime_interpolation; + double _saveRenderingCurrentApplicationTime_interpolation; long long _saveRenderingClockInterpolation_countsPerSec; bool _saveRendering_isFirstFrame = true; diff --git a/include/openspace/scene/scene.h b/include/openspace/scene/scene.h index fc22f6d1e2..f1a03be8e5 100644 --- a/include/openspace/scene/scene.h +++ b/include/openspace/scene/scene.h @@ -238,7 +238,7 @@ private: * Update dependencies. */ void updateNodeRegistry(); - + std::chrono::steady_clock::time_point currentTimeForInterpolation(); void sortTopologically(); std::unique_ptr _camera; diff --git a/include/openspace/util/timeline.h b/include/openspace/util/timeline.h index 60e71f25cc..86363f6d5b 100644 --- a/include/openspace/util/timeline.h +++ b/include/openspace/util/timeline.h @@ -32,16 +32,16 @@ namespace openspace { /** -* Base class for keyframes -*/ + * Base class for keyframes + */ struct KeyframeBase { size_t id; double timestamp; }; /** -* Templated class for keyframes containing data -*/ + * Templated class for keyframes containing data + */ template struct Keyframe : public KeyframeBase { Keyframe(size_t i, double t, T d); @@ -54,8 +54,8 @@ struct Keyframe : public KeyframeBase { }; /** -* Templated class for timelines -*/ + * Templated class for timelines + */ template class Timeline { public: @@ -81,20 +81,30 @@ private: }; /** -* Return true if the timestamp of a is smaller the timestamp of b. -*/ + * Return true if the timestamp of a is smaller the timestamp of b. + */ bool compareKeyframeTimes(const KeyframeBase& a, const KeyframeBase& b); /** -* Return true if a is smaller than the timestamp of b. -*/ + * Return true if a is smaller than the timestamp of b. + */ bool compareTimeWithKeyframeTime(double a, const KeyframeBase& b); /** -* Return true if the timestamp of a is smaller than b. -*/ + * Return true if the timestamp of a is smaller than b. + */ bool compareKeyframeTimeWithTime(const KeyframeBase& a, double b); +/** + * Return true if the timestamp of a is smaller than or equal to b. + * This is used only in the mode of saving render frames during session recording + * playback. This was necessary to correct a small timing issue caused by fixing + * the application time according to the playback framerate. In normal operation, + * the application time at the instant the keyframes are evaluated is always a + * little bit newer than the first keyframe in the timeline. + */ +bool compareKeyframeTimeWithTime_playbackWithFrames(const KeyframeBase& a, double b); + } // namespace openspace #include "timeline.inl" diff --git a/include/openspace/util/timemanager.h b/include/openspace/util/timemanager.h index d7500939c6..5914841073 100644 --- a/include/openspace/util/timemanager.h +++ b/include/openspace/util/timemanager.h @@ -121,12 +121,14 @@ public: private: void progressTime(double dt); - void applyKeyframeData(const TimeKeyframeData& keyframe); + void applyKeyframeData(const TimeKeyframeData& keyframe, double dt); TimeKeyframeData interpolate(const Keyframe& past, const Keyframe& future, double time); void addDeltaTimesKeybindings(); void clearDeltaTimesKeybindings(); + double currentApplicationTimeForInterpolation() const; + double previousApplicationTimeForInterpolation() const; Timeline _timeline; SyncData