mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-05 19:19:39 -06:00
Make speed scale affect speed during path traversal
This commit is contained in:
@@ -55,7 +55,7 @@ public:
|
||||
|
||||
std::vector<glm::dvec3> controlPoints() const;
|
||||
|
||||
CameraPose traversePath(double dt);
|
||||
CameraPose traversePath(double dt, float speedScale = 1.f);
|
||||
std::string currentAnchor() const;
|
||||
bool hasReachedEnd() const;
|
||||
|
||||
|
||||
@@ -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<glm::dvec3> 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<double>(speedScale);
|
||||
const double displacement = dt * speed;
|
||||
|
||||
_progressedTime += dt;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user