Update the VideoPlayer correctly when writing out frames in SessionRecording

This commit is contained in:
Alexander Bock
2024-01-18 16:14:23 +01:00
parent 0e78e65175
commit ef52155e83
+24
View File
@@ -29,6 +29,7 @@
#include <openspace/engine/syncengine.h>
#include <openspace/engine/moduleengine.h>
#include <openspace/engine/windowdelegate.h>
#include <openspace/interaction/sessionrecording.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/util/time.h>
#include <openspace/util/timemanager.h>
@@ -36,6 +37,7 @@
#include <ghoul/opengl/framebufferobject.h>
#include <ghoul/opengl/openglstatecache.h>
namespace {
constexpr std::string_view _loggerCat = "VideoPlayer";
@@ -497,6 +499,28 @@ void VideoPlayer::update() {
if (_isDestroying) {
return;
}
if (global::sessionRecording->isSavingFramesDuringPlayback()) {
double dt = global::sessionRecording->fixedDeltaTimeDuringFrameOutput();
if (_playbackMode == PlaybackMode::MapToSimulationTime) {
_currentVideoTime = correctVideoPlaybackTime();
}
else {
_currentVideoTime = _currentVideoTime + dt;
}
MpvKey key = MpvKey::Time;
mpv_set_property(_mpvHandle, keys[key], formats[key], &_currentVideoTime);
uint64_t result = mpv_render_context_update(_mpvRenderContext);
while ((result & MPV_RENDER_UPDATE_FRAME) == 0) {
renderFrame();
result = mpv_render_context_update(_mpvRenderContext);
}
return;
}
if (_playbackMode == PlaybackMode::MapToSimulationTime) {
seekToTime(correctVideoPlaybackTime());
}