diff --git a/modules/autonavigation/autonavigationhandler.cpp b/modules/autonavigation/autonavigationhandler.cpp index 5b776a9914..3b78b21eb4 100644 --- a/modules/autonavigation/autonavigationhandler.cpp +++ b/modules/autonavigation/autonavigationhandler.cpp @@ -55,7 +55,11 @@ Camera* AutoNavigationHandler::camera() const { } const double AutoNavigationHandler::pathDuration() const { - return _pathDuration; + double sum = 0.0; + for (auto ps : _pathSegments) { + sum += ps.duration; + } + return sum; } PathSegment& AutoNavigationHandler::currentPathSegment() { @@ -97,7 +101,7 @@ void AutoNavigationHandler::updateCamera(double deltaTime) { _currentTime += deltaTime; // reached the end of the path => stop playing - if (_currentTime > _pathDuration) { + if (_currentTime > pathDuration()) { _isPlaying = false; // TODO: implement suitable stop behaviour } @@ -124,17 +128,11 @@ void AutoNavigationHandler::createPath(PathSpecification& spec) { void AutoNavigationHandler::clearPath() { _pathSegments.clear(); - _pathDuration = 0.0; _currentTime = 0.0; } void AutoNavigationHandler::startPath() { ghoul_assert(!_pathSegments.empty(), "Cannot start an empty path"); - - _pathDuration = 0.0; - for (auto ps : _pathSegments) { - _pathDuration += ps.duration; - } _currentTime = 0.0; _isPlaying = true; } diff --git a/modules/autonavigation/autonavigationhandler.h b/modules/autonavigation/autonavigationhandler.h index 3d4260e063..45addaf075 100644 --- a/modules/autonavigation/autonavigationhandler.h +++ b/modules/autonavigation/autonavigationhandler.h @@ -81,7 +81,6 @@ private: std::vector _pathSegments; - double _pathDuration; double _currentTime; bool _isPlaying = false; };