mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-03-14 09:30:50 -05:00
Use quintic instead of sixtic speed, for better responsiveness and match with orbit stop behaviour
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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__
|
||||
|
||||
Reference in New Issue
Block a user