Add a function to skip immediately to the end of a playing camera path

This commit is contained in:
Emma Broman
2022-10-06 22:13:06 +02:00
parent ec3a765d1a
commit 5a970ee6e0
3 changed files with 41 additions and 15 deletions
@@ -72,6 +72,7 @@ public:
void abortPath();
void pausePath();
void continuePath();
void skipToEnd();
Path::Type defaultPathType() const;
double minValidBoundingSphere() const;
@@ -99,6 +100,8 @@ private:
bool _isPlaying = false;
bool _startSimulationTimeOnFinish = false;
bool _setCameraToEndNextFrame = false;
properties::OptionProperty _defaultPathType;
properties::BoolProperty _includeRoll;
properties::FloatProperty _speedScale;
+33 -15
View File
@@ -214,6 +214,18 @@ void PathNavigator::updateCamera(double deltaTime) {
return;
}
if (_setCameraToEndNextFrame) {
LDEBUG("Skipped to end of camera path");
camera()->setPose(_currentPath->endPoint().pose());
global::navigationHandler->orbitalNavigator().setFocusNode(
_currentPath->endPoint().nodeIdentifier(),
false
);
handlePathEnd();
_setCameraToEndNextFrame = false;
return;
}
// Prevent long delta times due to e.g. computations from other actions to cause
// really big jumps in the motion along the path
// OBS! Causes problems if the general FPS is lower than 10, but then the user should
@@ -241,19 +253,6 @@ void PathNavigator::updateCamera(double deltaTime) {
if (_currentPath->hasReachedEnd()) {
LINFO("Reached target");
handlePathEnd();
if (_applyIdleBehaviorOnFinish) {
constexpr const char ApplyIdleBehaviorScript[] =
"openspace.setPropertyValueSingle("
"'NavigationHandler.OrbitalNavigator.IdleBehavior.ApplyIdleBehavior',"
"true"
");";
global::scriptEngine->queueScript(
ApplyIdleBehaviorScript,
openspace::scripting::ScriptEngine::RemoteScripting::Yes
);
}
return;
}
}
@@ -368,6 +367,14 @@ void PathNavigator::continuePath() {
_isPlaying = true;
}
void PathNavigator::skipToEnd() {
if (!openspace::global::navigationHandler->pathNavigator().isPlayingPath()) {
LWARNING("No camera path is currently active");
}
_setCameraToEndNextFrame = true;
}
Path::Type PathNavigator::defaultPathType() const {
return static_cast<Path::Type>(_defaultPathType.value());
}
@@ -430,15 +437,25 @@ const std::vector<SceneGraphNode*>& PathNavigator::relevantNodes() {
void PathNavigator::handlePathEnd() {
_isPlaying = false;
global::openSpaceEngine->resetMode();
if (_startSimulationTimeOnFinish) {
openspace::global::scriptEngine->queueScript(
"openspace.time.setPause(false)",
scripting::ScriptEngine::RemoteScripting::Yes
);
_startSimulationTimeOnFinish = false;
}
if (_applyIdleBehaviorOnFinish) {
global::scriptEngine->queueScript(
"openspace.setPropertyValueSingle("
"'NavigationHandler.OrbitalNavigator.IdleBehavior.ApplyIdleBehavior',"
"true"
");",
openspace::scripting::ScriptEngine::RemoteScripting::Yes
);
}
_startSimulationTimeOnFinish = false;
global::openSpaceEngine->resetMode();
}
void PathNavigator::findRelevantNodes() {
@@ -504,6 +521,7 @@ scripting::LuaLibrary PathNavigator::luaLibrary() {
codegen::lua::ContinuePath,
codegen::lua::PausePath,
codegen::lua::StopPath,
codegen::lua::SkipToEnd,
codegen::lua::FlyTo,
codegen::lua::FlyToHeight,
codegen::lua::FlyToNavigationState,
+5
View File
@@ -46,6 +46,11 @@ namespace {
openspace::global::navigationHandler->pathNavigator().abortPath();
}
// Immediately skips to the end of the current camera path, if one is being played.
[[codegen::luawrap]] void skipToEnd() {
openspace::global::navigationHandler->pathNavigator().skipToEnd();
}
/**
* Move the camera to the node with the specified identifier. The optional double
* specifies the duration of the motion, in seconds. If the optional bool is set to true