mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-24 13:28:55 -05:00
Remove custom easing functions. Use ghoul's instead
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user