diff --git a/include/openspace/navigation/path.h b/include/openspace/navigation/path.h index e19eaddbec..a1367ff6b5 100644 --- a/include/openspace/navigation/path.h +++ b/include/openspace/navigation/path.h @@ -55,7 +55,7 @@ public: std::vector controlPoints() const; - CameraPose traversePath(double dt); + CameraPose traversePath(double dt, float speedScale = 1.f); std::string currentAnchor() const; bool hasReachedEnd() const; diff --git a/src/navigation/path.cpp b/src/navigation/path.cpp index deaf9c3ad0..55e6e83e62 100644 --- a/src/navigation/path.cpp +++ b/src/navigation/path.cpp @@ -104,9 +104,7 @@ Path::Path(Waypoint start, Waypoint end, CurveType type, } const auto defaultDuration = [](double pathlength) { - const double speedScale = - global::navigationHandler->pathNavigator().speedScale(); - return std::log(pathlength) / speedScale; + return std::log(pathlength); }; _duration = duration.value_or(defaultDuration(pathLength())); @@ -139,8 +137,9 @@ std::vector Path::controlPoints() const { return _curve->points(); } -CameraPose Path::traversePath(double dt) { - const double speed = _speedFactorFromDuration * speedAlongPath(_traveledDistance); +CameraPose Path::traversePath(double dt, float speedScale) { + double speed = _speedFactorFromDuration * speedAlongPath(_traveledDistance); + speed *= static_cast(speedScale); const double displacement = dt * speed; _progressedTime += dt; diff --git a/src/navigation/pathnavigator.cpp b/src/navigation/pathnavigator.cpp index 8ea004a875..526df5efcb 100644 --- a/src/navigation/pathnavigator.cpp +++ b/src/navigation/pathnavigator.cpp @@ -73,7 +73,9 @@ namespace { constexpr openspace::properties::Property::PropertyInfo SpeedScaleInfo = { "SpeedScale", "Speed Scale", - "Scale factor that affects the default speed for a camera path." + "Scale factor that the speed will be mulitplied with during path traversal. " + "Can be used to speed up or slow down the camera motion, depending on if the " + "value is larger than or smaller than one." }; constexpr openspace::properties::Property::PropertyInfo OrbitSpeedFactorInfo = { @@ -208,7 +210,7 @@ void PathNavigator::updateCamera(double deltaTime) { LINFO("Cannot start simulation time during camera motion"); } - CameraPose newPose = _currentPath->traversePath(deltaTime); + CameraPose newPose = _currentPath->traversePath(deltaTime, _speedScale); const std::string newAnchor = _currentPath->currentAnchor(); // Set anchor node in orbitalNavigator, to render visible nodes and add activate