Use quintic instead of sixtic speed, for better responsiveness and match with orbit stop behaviour

This commit is contained in:
Emma Broman
2020-08-17 11:28:11 +02:00
parent f2d3be8257
commit 723530d525
3 changed files with 36 additions and 4 deletions

View File

@@ -142,7 +142,7 @@ void PathSegment::initCurve() {
_start.rotation(),
_end.rotation()
);
_speedFunction = std::make_unique<SexticDampenedSpeed>();
_speedFunction = std::make_unique<QuinticDampenedSpeed>();
break;
case CurveType::Bezier3:
@@ -154,7 +154,7 @@ void PathSegment::initCurve() {
_end.node()->worldPosition(),
_curve.get()
);
_speedFunction = std::make_unique<SexticDampenedSpeed>();
_speedFunction = std::make_unique<QuinticDampenedSpeed>();
break;
case CurveType::Linear:
@@ -163,7 +163,7 @@ void PathSegment::initCurve() {
_start.rotation(),
_end.rotation()
);
_speedFunction = std::make_unique<SexticDampenedSpeed>();
_speedFunction = std::make_unique<QuinticDampenedSpeed>();
break;
case CurveType::ZoomOutOverview:
@@ -175,7 +175,7 @@ void PathSegment::initCurve() {
_end.node()->worldPosition(),
_curve.get()
);
_speedFunction = std::make_unique<SexticDampenedSpeed>();
_speedFunction = std::make_unique<QuinticDampenedSpeed>();
break;
default:

View File

@@ -85,4 +85,30 @@ double SexticDampenedSpeed::value(double t) const {
return speed;
}
QuinticDampenedSpeed::QuinticDampenedSpeed() {
initIntegratedSum();
}
double QuinticDampenedSpeed::value(double t) const {
ghoul_assert(t >= 0.0 && t <= 1.0, "Variable t out of range [0,1]");
const double tPeak = 0.5;
double speed = 0.0;
// accelerate
if (t <= tPeak) {
double tScaled = t / tPeak;
speed = ghoul::cubicEaseInOut(ghoul::quadraticEaseInOut(tScaled));
}
// deaccelerate
else if (t <= 1.0) {
double tScaled = (t - tPeak) / (1.0 - tPeak);
speed = 1.0 - ghoul::cubicEaseInOut(ghoul::quadraticEaseInOut(tScaled));
}
// avoid zero speed
speed += 0.00001; // TODO: Minimal speed should depend on size of visible object/node
return speed;
}
} // namespace openspace::autonavigation

View File

@@ -52,6 +52,12 @@ public:
double value(double t) const override;
};
class QuinticDampenedSpeed : public SpeedFunction {
public:
QuinticDampenedSpeed();
double value(double t) const override;
};
} // namespace openspace::autonavigation
#endif // __OPENSPACE_MODULE_AUTONAVIGATION___SPEEDFUNCTION___H__