Remove custom easing functions. Use ghoul's instead

This commit is contained in:
Emma Broman
2020-02-04 18:07:47 -05:00
parent 40d634d249
commit d60ff85b5a
2 changed files with 4 additions and 52 deletions
@@ -36,55 +36,6 @@ namespace openspace::autonavigation::helpers {
} // helpers
namespace openspace::autonavigation::easingfunctions {
double linear(double t) { return t; };
double step(double t) { return (t > 0.5); };
double circularEaseOut(double p){
return sqrt((2 - p) * p);
}
double cubicEaseIn(double t) { return (t*t*t); };
double cubicEaseOut(double t) {
double p = 1 - t;
return (p*p*p);
}
double cubicEaseInOut(double t) {
if (t < 0.5) {
return 4 * t * t * t;
}
else {
double f = ((2 * t) - 2);
return 0.5 * f * f * f + 1;
}
}
double quadraticEaseInOut(double t) {
if (t < 0.5) {
return 2 * t * t;
}
else {
return (-2 * t * t) + (4 * t) - 1;
}
}
double exponentialEaseInOut(double t) {
if (t == 0.0 || t == 1.0) return t;
if (t < 0.5) {
return 0.5 * glm::pow(2, (20 * t) - 10);
}
else {
return -0.5 * glm::pow(2, (-20 * t) + 10) + 1;
}
}
} // easingfunctions
namespace openspace::autonavigation::interpolation {
// TODO: make all these into template functions
+4 -3
View File
@@ -32,6 +32,7 @@
#include <openspace/scene/scenegraphnode.h>
#include <openspace/util/camera.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/misc/easing.h>
namespace {
constexpr const char* _loggerCat = "PathSegment";
@@ -70,7 +71,7 @@ const double PathSegment::duration() const { return _duration; }
const double PathSegment::startTime() const { return _startTime; }
const glm::dvec3 PathSegment::getPositionAt(double t) const {
t = easingfunctions::cubicEaseInOut(t);
t = ghoul::cubicEaseInOut(t);
return _curve->valueAt(t);
}
@@ -78,10 +79,10 @@ const glm::dquat PathSegment::getRotationAt(double t) const {
// TODO: improve how rotation is computed
double tSlerp = helpers::shiftAndScale(t, 0.1, 0.9);
tSlerp = easingfunctions::cubicEaseInOut(tSlerp);
tSlerp = ghoul::cubicEaseInOut(tSlerp);
double tLookAt = helpers::shiftAndScale(t, 0.2, 0.8);
tLookAt = easingfunctions::cubicEaseInOut(tLookAt);
tLookAt = ghoul::cubicEaseInOut(tLookAt);
switch (_curveType) {
case CurveType::Linear2: