Make speed scale affect speed during path traversal

This commit is contained in:
Emma Broman
2021-06-24 15:04:25 +02:00
parent fb690e87ee
commit 6119b9b2a2
3 changed files with 9 additions and 8 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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