mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-19 10:21:30 -06:00
Introduce engine modes to handle Camera path and session recording transitions
* Clarifies which system is control over time and camera at what time * Fixes #1845 * Prevent invalid switching between session recoring and camera path playback * Some cleanup, mosly of SessionRecording and NavigationHandler. Also, remove ExternInteraction and some other unused/nonexisting functions
This commit is contained in:
@@ -77,6 +77,7 @@
|
||||
#include <ghoul/font/fontrenderer.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/logging/visualstudiooutputlog.h>
|
||||
#include <ghoul/misc/exception.h>
|
||||
#include <ghoul/misc/profiling.h>
|
||||
#include <ghoul/misc/stacktrace.h>
|
||||
#include <ghoul/misc/stringconversion.h>
|
||||
@@ -105,6 +106,16 @@ namespace {
|
||||
|
||||
constexpr const char* _loggerCat = "OpenSpaceEngine";
|
||||
|
||||
constexpr std::string_view stringify(openspace::OpenSpaceEngine::Mode m) {
|
||||
using Mode = openspace::OpenSpaceEngine::Mode;
|
||||
switch (m) {
|
||||
case Mode::UserControl: return "UserControl";
|
||||
case Mode::CameraPath: return "CameraPath";
|
||||
case Mode::SessionRecordingPlayback: return "SessionRecording";
|
||||
default: throw ghoul::MissingCaseException();
|
||||
}
|
||||
}
|
||||
|
||||
openspace::properties::Property::PropertyInfo PrintEventsInfo = {
|
||||
"PrintEvents",
|
||||
"Print Events",
|
||||
@@ -784,7 +795,7 @@ void OpenSpaceEngine::loadAssets() {
|
||||
static_cast<float>(sync->nSynchronizedBytes()) /
|
||||
static_cast<float>(sync->nTotalBytes());
|
||||
}(sync);
|
||||
|
||||
|
||||
_loadingScreen->updateItem(
|
||||
sync->identifier(),
|
||||
sync->name(),
|
||||
@@ -813,7 +824,7 @@ void OpenSpaceEngine::loadAssets() {
|
||||
allAssets.end(),
|
||||
[](const Asset* asset) { return asset->isInitialized() || asset->isFailed(); }
|
||||
);
|
||||
|
||||
|
||||
if (finishedLoading) {
|
||||
break;
|
||||
}
|
||||
@@ -1604,6 +1615,39 @@ void OpenSpaceEngine::toggleShutdownMode() {
|
||||
}
|
||||
}
|
||||
|
||||
OpenSpaceEngine::Mode OpenSpaceEngine::currentMode() const {
|
||||
return _currentMode;
|
||||
}
|
||||
|
||||
bool OpenSpaceEngine::setMode(Mode newMode) {
|
||||
if (_currentMode == Mode::CameraPath && newMode == Mode::CameraPath) {
|
||||
// Special case: It is okay to trigger another camera path while one is
|
||||
// already playing. So just return that we were successful
|
||||
return true;
|
||||
}
|
||||
else if (newMode == _currentMode) {
|
||||
LERROR("Cannot switch to the currectly active mode");
|
||||
return false;
|
||||
}
|
||||
else if (_currentMode != Mode::UserControl && newMode != Mode::UserControl) {
|
||||
LERROR(fmt::format(
|
||||
"Cannot switch to mode '{}' when in '{}' mode",
|
||||
stringify(newMode), stringify(_currentMode)
|
||||
));
|
||||
return false;
|
||||
}
|
||||
|
||||
LDEBUG(fmt::format("Mode: {}", stringify(newMode)));
|
||||
|
||||
_currentMode = newMode;
|
||||
return true;
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::resetMode() {
|
||||
_currentMode = Mode::UserControl;
|
||||
LDEBUG(fmt::format("Reset engine mode to {}", stringify(_currentMode)));
|
||||
}
|
||||
|
||||
void setCameraFromProfile(const Profile& p) {
|
||||
if (!p.camera.has_value()) {
|
||||
throw ghoul::RuntimeError("No 'camera' entry exists in the startup profile");
|
||||
|
||||
Reference in New Issue
Block a user