Address stability problems for camera paths and make them more useful in general

* Change spline curve parameter interval from [0,1] to [0,nSegments], for slightly increased precision
* Use linear paths whenever precision isn't enough/paths are too long (and traverse linear paths differently, to make them less depending on the distance)
* Remove OrbitalNavigator.LinearFlight and instead add "Zoom to" helper functions (closes #1837 )
* Add check to prevent triggering awkward short paths, for example when flying to the current target or to the same geo position twice
* Refactor speed code and handle speed when path is shorter than start+closeup distance
* Add easing to speed dampening
* Add topic for engine mode (to be used for UI later)
* Cleaner log when creating paths (some previous info messages are now debug messages)

Related PR: OpenSpace/OpenSpace-WebGuiFrontend#70
This commit is contained in:
Emma Broman
2022-02-25 08:49:19 +01:00
committed by GitHub
parent 02677b5180
commit d0fcec569c
18 changed files with 773 additions and 240 deletions
+36
View File
@@ -1180,6 +1180,17 @@ void OpenSpaceEngine::preSynchronization() {
setCameraFromProfile(*global::profile);
setAdditionalScriptsFromProfile(*global::profile);
}
// Handle callback(s) for change in engine mode
if (_modeLastFrame != _currentMode) {
using K = CallbackHandle;
using V = ModeChangeCallback;
for (const std::pair<K, V>& it : _modeChangeCallbacks) {
it.second();
}
}
_modeLastFrame = _currentMode;
LTRACE("OpenSpaceEngine::preSynchronization(end)");
}
@@ -1617,6 +1628,31 @@ void OpenSpaceEngine::resetMode() {
LDEBUG(fmt::format("Reset engine mode to {}", stringify(_currentMode)));
}
OpenSpaceEngine::CallbackHandle OpenSpaceEngine::addModeChangeCallback(
ModeChangeCallback cb)
{
CallbackHandle handle = _nextCallbackHandle++;
_modeChangeCallbacks.emplace_back(handle, std::move(cb));
return handle;
}
void OpenSpaceEngine::removeModeChangeCallback(CallbackHandle handle) {
const auto it = std::find_if(
_modeChangeCallbacks.begin(),
_modeChangeCallbacks.end(),
[handle](const std::pair<CallbackHandle, ModeChangeCallback>& cb) {
return cb.first == handle;
}
);
ghoul_assert(
it != _modeChangeCallbacks.end(),
"handle must be a valid callback handle"
);
_modeChangeCallbacks.erase(it);
}
void setCameraFromProfile(const Profile& p) {
if (!p.camera.has_value()) {
throw ghoul::RuntimeError("No 'camera' entry exists in the startup profile");