Skip to content

Commit 757630b

Browse files
Mod the time when queried for paths in loop mode
1 parent 01f88fe commit 757630b

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/ammonite/camera/path.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,14 @@ namespace ammonite {
582582

583583
const Path& cameraPath = pathTrackerMap[pathId];
584584
const PathNode& maxNode = cameraPath.pathNodes[(cameraPath.pathNodes.size() - 1)];
585-
return std::min(cameraPath.currentTime, maxNode.time);
585+
586+
//Loop the time value for the loop mod
587+
double cameraPathTime = cameraPath.currentTime;
588+
if (cameraPath.pathMode == AMMONITE_PATH_LOOP) {
589+
cameraPathTime = std::fmod(cameraPathTime, maxNode.time);
590+
}
591+
592+
return std::min(cameraPathTime, maxNode.time);
586593
}
587594

588595
//Return the current progress, relative to 1.0 as the end
@@ -595,7 +602,14 @@ namespace ammonite {
595602

596603
const Path& cameraPath = pathTrackerMap[pathId];
597604
const PathNode& maxNode = cameraPath.pathNodes[(cameraPath.pathNodes.size() - 1)];
598-
const double progress = cameraPath.currentTime / maxNode.time;
605+
606+
//Loop the time value for the loop mod
607+
double cameraPathTime = cameraPath.currentTime;
608+
if (cameraPath.pathMode == AMMONITE_PATH_LOOP) {
609+
cameraPathTime = std::fmod(cameraPathTime, maxNode.time);
610+
}
611+
612+
const double progress = cameraPathTime / maxNode.time;
599613
return std::min(progress, 1.0);
600614
}
601615

0 commit comments

Comments
 (0)