mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-03-14 09:30:50 -05:00
Minor cleanup
Compute paht duration on the fly rather than storing a variable
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,6 @@ private:
|
||||
|
||||
std::vector<PathSegment> _pathSegments;
|
||||
|
||||
double _pathDuration;
|
||||
double _currentTime;
|
||||
bool _isPlaying = false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user