Don't return negative speed values for t > 1.0

This commit is contained in:
Emma Broman
2020-04-15 16:02:12 +02:00
parent ae5be74423
commit 49ae23aa94
+2 -2
View File
@@ -163,7 +163,7 @@ PathSegment::SpeedFunction::SpeedFunction(double duration) {
}
double PathSegment::SpeedFunction::value(double t) const {
ghoul_assert(t >= 0 && t <= 1, "Variable t out of range [0,1]");
ghoul_assert(t >= 0.0 && t <= 1.0, "Variable t out of range [0,1]");
const double tPeak = 0.5;
double speed = 1.0;
@@ -174,7 +174,7 @@ double PathSegment::SpeedFunction::value(double t) const {
speed = ghoul::cubicEaseInOut(tScaled);
}
// deaccelerate
else {
else if (t < 1.0) {
double tScaled = (t - tPeak) / (1.0 - tPeak);
speed = 1.0 - ghoul::cubicEaseInOut(tScaled);
}