From 9f8da6d47a911ad4d878b64b28372f2722f474a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 3 Sep 2018 15:41:18 +0200 Subject: [PATCH] Animation: prefer "shortest path" interpolators in interpolatorFor(). The function has an explicit name but making it the default makes for a less surprising behavior. --- src/Magnum/Animation/Interpolation.cpp | 4 +-- src/Magnum/Animation/Interpolation.h | 40 ++++++++++++++------------ 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/Magnum/Animation/Interpolation.cpp b/src/Magnum/Animation/Interpolation.cpp index 1e38c107f..0845816eb 100644 --- a/src/Magnum/Animation/Interpolation.cpp +++ b/src/Magnum/Animation/Interpolation.cpp @@ -78,7 +78,7 @@ template auto TypeTraits, Math::Complex>::interpola template auto TypeTraits, Math::Quaternion>::interpolator(Interpolation interpolation) -> Interpolator { switch(interpolation) { case Interpolation::Constant: return Math::select; - case Interpolation::Linear: return Math::slerp; + case Interpolation::Linear: return Math::slerpShortestPath; case Interpolation::Spline: case Interpolation::Custom: ; /* nope */ @@ -90,7 +90,7 @@ template auto TypeTraits, Math::Quaternion>::int template auto TypeTraits, Math::DualQuaternion>::interpolator(Interpolation interpolation) -> Interpolator { switch(interpolation) { case Interpolation::Constant: return Math::select; - case Interpolation::Linear: return Math::sclerp; + case Interpolation::Linear: return Math::sclerpShortestPath; case Interpolation::Spline: case Interpolation::Custom: ; /* nope */ diff --git a/src/Magnum/Animation/Interpolation.h b/src/Magnum/Animation/Interpolation.h index 2e71d96f7..3261bf3bf 100644 --- a/src/Magnum/Animation/Interpolation.h +++ b/src/Magnum/Animation/Interpolation.h @@ -97,29 +97,31 @@ template using ResultOf = typename Implementation::ResultTraits::Typ Expects that @p interpolation is not @ref Interpolation::Custom. Favors output correctness over performance, supply custom interpolator functions for -faster but less precise results. +faster but potentially less correct results. @m_class{m-fullwidth} -Interpolation type | Value type | Result type | Interpolator +Interpolation | Value type | Result type | Interpolator ------------------- | ----------------- | ------------- | ------------ -@ref Interpolation::Constant | any `V` | `V` | @ref Math::select() -@ref Interpolation::Constant | @ref Math::CubicHermite "Math::CubicHermite" | `T` | @ref Math::select(const CubicHermite&, const CubicHermite&, U) "Math::select()" -@ref Interpolation::Linear | @cpp bool @ce | @cpp bool @ce | @ref Math::select() -@ref Interpolation::Linear | @ref Math::BoolVector | @ref Math::BoolVector | @ref Math::select() -@ref Interpolation::Linear | any scalar `V` | `V` | @ref Math::lerp() -@ref Interpolation::Linear | any vector `V` | `V` | @ref Math::lerp() -@ref Interpolation::Linear | @ref Math::Complex | @ref Math::Complex | @ref Math::slerp(const Complex&, const Complex&, T) "Math::slerp()" -@ref Interpolation::Linear | @ref Math::Quaternion | @ref Math::Quaternion | @ref Math::slerp(const Quaternion&, const Quaternion&, T) "Math::slerp()" -@ref Interpolation::Linear | @ref Math::DualQuaternion | @ref Math::DualQuaternion | @ref Math::sclerp(const DualQuaternion&, const DualQuaternion&, T) "Math::sclerp()" -@ref Interpolation::Linear | @ref Math::CubicHermite "Math::CubicHermite" | `T` | @ref Math::lerp(const CubicHermite&, const CubicHermite&, U) "Math::lerp()" -@ref Interpolation::Linear | @ref Math::CubicHermiteComplex | @ref Math::Complex | @ref Math::lerp(const CubicHermiteComplex&, const CubicHermiteComplex&, T) "Math::lerp()" -@ref Interpolation::Linear | @ref Math::CubicHermiteQuaternion | @ref Math::Quaternion | @ref Math::lerp(const CubicHermiteQuaternion&, const CubicHermiteQuaternion&, T) "Math::lerp()" -@ref Interpolation::Spline | @ref Math::CubicHermite "Math::CubicHermite" | `T` | @ref Math::splerp(const CubicHermite&, const CubicHermite&, U) "Math::splerp()" -@ref Interpolation::Spline | @ref Math::CubicHermiteComplex | @ref Math::Complex | @ref Math::splerp(const CubicHermiteComplex&, const CubicHermiteComplex&, T) "Math::splerp()" -@ref Interpolation::Spline | @ref Math::CubicHermiteQuaternion | @ref Math::Quaternion | @ref Math::splerp(const CubicHermiteQuaternion&, const CubicHermiteQuaternion&, T) "Math::splerp()" - -@see @ref interpolate(), @ref interpolateStrict() +@ref Interpolation::Constant "Constant" | any `V` | `V` | @ref Math::select() +@ref Interpolation::Constant "Constant" | @ref Math::CubicHermite "Math::CubicHermite" | `T` | @ref Math::select(const CubicHermite&, const CubicHermite&, U) "Math::select()" +@ref Interpolation::Linear "Linear" | @cpp bool @ce | @cpp bool @ce | @ref Math::select() +@ref Interpolation::Linear "Linear" | @ref Math::BoolVector | @ref Math::BoolVector | @ref Math::select() +@ref Interpolation::Linear "Linear" | any scalar `V` | `V` | @ref Math::lerp() +@ref Interpolation::Linear "Linear" | any vector `V` | `V` | @ref Math::lerp() +@ref Interpolation::Linear "Linear" | @ref Math::Complex | @ref Math::Complex | @ref Math::slerp(const Complex&, const Complex&, T) "Math::slerp()" +@ref Interpolation::Linear "Linear" | @ref Math::Quaternion | @ref Math::Quaternion | @ref Math::slerpShortestPath(const Quaternion&, const Quaternion&, T) "Math::slerpShortestPath()" +@ref Interpolation::Linear "Linear" | @ref Math::DualQuaternion | @ref Math::DualQuaternion | @ref Math::sclerpShortestPath(const DualQuaternion&, const DualQuaternion&, T) "Math::sclerpShortestPath()" +@ref Interpolation::Linear "Linear" | @ref Math::CubicHermite "Math::CubicHermite" | `T` | @ref Math::lerp(const CubicHermite&, const CubicHermite&, U) "Math::lerp()" +@ref Interpolation::Linear "Linear" | @ref Math::CubicHermiteComplex | @ref Math::Complex | @ref Math::lerp(const CubicHermiteComplex&, const CubicHermiteComplex&, T) "Math::lerp()" +@ref Interpolation::Linear "Linear" | @ref Math::CubicHermiteQuaternion | @ref Math::Quaternion | @ref Math::lerp(const CubicHermiteQuaternion&, const CubicHermiteQuaternion&, T) "Math::lerp()" +@ref Interpolation::Spline "Spline" | @ref Math::CubicHermite "Math::CubicHermite" | `T` | @ref Math::splerp(const CubicHermite&, const CubicHermite&, U) "Math::splerp()" +@ref Interpolation::Spline "Spline" | @ref Math::CubicHermiteComplex | @ref Math::Complex | @ref Math::splerp(const CubicHermiteComplex&, const CubicHermiteComplex&, T) "Math::splerp()" +@ref Interpolation::Spline "Spline" | @ref Math::CubicHermiteQuaternion | @ref Math::Quaternion | @ref Math::splerp(const CubicHermiteQuaternion&, const CubicHermiteQuaternion&, T) "Math::splerp()" + +@see @ref interpolate(), @ref interpolateStrict(), + @ref Animation-Track-interpolators "Track types and interpolators", + @ref Trade::animationInterpolatorFor() @experimental */ template> auto interpolatorFor(Interpolation interpolation) -> R(*)(const V&, const V&, Float);