From 778b4e61b38e0bdd0477e0cd7799bb3ceed5b4d3 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Fri, 11 Dec 2020 12:30:05 +0100 Subject: [PATCH] Revert "Better handle interpolation when setting interpolation time to 0" This reverts commit 8cf5f9639271d01b275e537e6d26d1ace3cdcd05. --- include/openspace/interaction/interpolator.h | 1 - include/openspace/interaction/interpolator.inl | 18 +++--------------- src/interaction/orbitalnavigator.cpp | 7 +------ 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/include/openspace/interaction/interpolator.h b/include/openspace/interaction/interpolator.h index 9b52cef505..d872e1706d 100644 --- a/include/openspace/interaction/interpolator.h +++ b/include/openspace/interaction/interpolator.h @@ -51,7 +51,6 @@ public: private: std::function _transferFunction; - bool _isInterpolating = false; float _t = 1.f; float _interpolationTime = 1.f; float _scaledDeltaTime = 0.f; diff --git a/include/openspace/interaction/interpolator.inl b/include/openspace/interaction/interpolator.inl index 3b2588fac3..d28f07f573 100644 --- a/include/openspace/interaction/interpolator.inl +++ b/include/openspace/interaction/interpolator.inl @@ -34,28 +34,16 @@ Interpolator::Interpolator() template void Interpolator::start() { _t = 0.f; - _isInterpolating = true; } template void Interpolator::end() { _t = 1.f; - _isInterpolating = false; } template void Interpolator::setDeltaTime(float deltaTime) { - if (_interpolationTime > 0.f) { - _scaledDeltaTime = deltaTime / _interpolationTime; - } - else { - if (deltaTime > 0.f) { - _scaledDeltaTime = 1.f; - } - else { - _scaledDeltaTime = -1.f; - } - } + _scaledDeltaTime = deltaTime / _interpolationTime; } template @@ -71,7 +59,7 @@ void Interpolator::setInterpolationTime(float interpolationTime) { template void Interpolator::step() { _t += _scaledDeltaTime; - _t = glm::clamp(_t, 0.f, 1.f); + _t = glm::clamp(_t, 0.0f, 1.0f); } template @@ -86,7 +74,7 @@ T Interpolator::value() const { template bool Interpolator::isInterpolating() const { - return _isInterpolating; + return (_t < 1.f) && (_t >= 0.f); } } // namespace openspace::interaction diff --git a/src/interaction/orbitalnavigator.cpp b/src/interaction/orbitalnavigator.cpp index a1c34a91d1..6e7e9f7baa 100644 --- a/src/interaction/orbitalnavigator.cpp +++ b/src/interaction/orbitalnavigator.cpp @@ -1275,12 +1275,7 @@ glm::dvec3 OrbitalNavigator::moveCameraAlongVector(const glm::dvec3& camPos, velocity = 1.0 - destination / distFromCameraToFocus; } else { // When flying away from anchor - if (destination == 0.0) { - velocity = -1.0; - } - else { - velocity = distFromCameraToFocus / destination - 1.0; - } + velocity = distFromCameraToFocus / destination - 1.0; } velocity *= _velocitySensitivity * deltaTime;