From c3d093bee9c9d35f6ff912975bfb0d65ef6134b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 31 Aug 2018 20:47:26 +0200 Subject: [PATCH] Trade: support for spline interpolation in AnimationData. --- src/Magnum/Trade/AnimationData.cpp | 9 ++++ src/Magnum/Trade/AnimationData.h | 83 +++++++++++++++++++++++++----- 2 files changed, 79 insertions(+), 13 deletions(-) diff --git a/src/Magnum/Trade/AnimationData.cpp b/src/Magnum/Trade/AnimationData.cpp index c2f8f3278..fd0b1ed11 100644 --- a/src/Magnum/Trade/AnimationData.cpp +++ b/src/Magnum/Trade/AnimationData.cpp @@ -100,6 +100,10 @@ template MAGNUM_TRADE_EXPORT auto animationInterpolatorFor template MAGNUM_TRADE_EXPORT auto animationInterpolatorFor(Animation::Interpolation) -> Complex(*)(const Complex&, const Complex&, Float); template MAGNUM_TRADE_EXPORT auto animationInterpolatorFor(Animation::Interpolation) -> Quaternion(*)(const Quaternion&, const Quaternion&, Float); template MAGNUM_TRADE_EXPORT auto animationInterpolatorFor(Animation::Interpolation) -> DualQuaternion(*)(const DualQuaternion&, const DualQuaternion&, Float); +template MAGNUM_TRADE_EXPORT auto animationInterpolatorFor>(Animation::Interpolation) -> Math::Vector2(*)(const CubicHermite2D&, const CubicHermite2D&, Float); +template MAGNUM_TRADE_EXPORT auto animationInterpolatorFor>(Animation::Interpolation) -> Math::Vector3(*)(const CubicHermite3D&, const CubicHermite3D&, Float); +template MAGNUM_TRADE_EXPORT auto animationInterpolatorFor(Animation::Interpolation) -> Complex(*)(const CubicHermiteComplex&, const CubicHermiteComplex&, Float); +template MAGNUM_TRADE_EXPORT auto animationInterpolatorFor(Animation::Interpolation) -> Quaternion(*)(const CubicHermiteQuaternion&, const CubicHermiteQuaternion&, Float); Debug& operator<<(Debug& debug, const AnimationTrackType value) { switch(value) { @@ -124,6 +128,11 @@ Debug& operator<<(Debug& debug, const AnimationTrackType value) { _c(Complex) _c(Quaternion) _c(DualQuaternion) + _c(CubicHermite1D) + _c(CubicHermite2D) + _c(CubicHermite3D) + _c(CubicHermiteComplex) + _c(CubicHermiteQuaternion) #undef _c /* LCOV_EXCL_STOP */ } diff --git a/src/Magnum/Trade/AnimationData.h b/src/Magnum/Trade/AnimationData.h index 5d3781957..98ff4cf13 100644 --- a/src/Magnum/Trade/AnimationData.h +++ b/src/Magnum/Trade/AnimationData.h @@ -87,7 +87,34 @@ enum class AnimationTrackType: UnsignedByte { */ Quaternion, - DualQuaternion /**< @ref Magnum::DualQuaternion "DualQuaternion" */ + DualQuaternion, /**< @ref Magnum::DualQuaternion "DualQuaternion" */ + CubicHermite1D, /**< @ref Magnum::CubicHermite1D "CubicHermite1D" */ + + /** + * @ref Magnum::CubicHermite2D "CubicHermite2D". Usually used for + * spline-interpolated @ref AnimationTrackTarget::Translation2D and + * @ref AnimationTrackTarget::Scaling2D. + */ + CubicHermite2D, + + /** + * @ref Magnum::CubicHermite3D "CubicHermite3D". Usually used for + * spline-interpolated @ref AnimationTrackTarget::Translation3D and + * @ref AnimationTrackTarget::Scaling3D. + */ + CubicHermite3D, + + /** + * @ref Magnum::CubicHermiteComplex "CubicHermiteComplex". Usually used for + * spline-interpolated @ref AnimationTrackTarget::Rotation2D. + */ + CubicHermiteComplex, + + /** + * @ref Magnum::CubicHermiteQuaternion "CubicHermiteQuaternion". Usually + * used for spline-interpolated @ref AnimationTrackTarget::Rotation3D. + */ + CubicHermiteQuaternion }; /** @debugoperatorenum{AnimationTrackType} */ @@ -102,49 +129,73 @@ MAGNUM_TRADE_EXPORT Debug& operator<<(Debug& debug, AnimationTrackType value); enum class AnimationTrackTarget: UnsignedByte { /** * Modifies 2D object translation. Type is usually - * @ref Magnum::Vector2 "Vector2". + * @ref Magnum::Vector2 "Vector2" or + * @ref Magnum::CubicHermite2D "CubicHermite2D" for spline-interpolated + * data. * - * @see @ref AnimationTrackType::Vector2, @ref ObjectData2D::translation() + * @see @ref AnimationTrackType::Vector2, + * @ref AnimationTrackType::CubicHermite2D, + * @ref ObjectData2D::translation() */ Translation2D, /** * Modifies 3D object translation. Type is usually - * @ref Magnum::Vector3 "Vector3". + * @ref Magnum::Vector3 "Vector3" or + * @ref Magnum::CubicHermite3D "CubicHermite3D" for spline-interpolated + * data. * - * @see @ref AnimationTrackType::Vector3, @ref ObjectData3D::translation() + * @see @ref AnimationTrackType::Vector3, + * @ref AnimationTrackType::CubicHermite3D, + * @ref ObjectData3D::translation() */ Translation3D, /** * Modifies 2D object rotation. Type is usually - * @ref Magnum::Complex "Complex". + * @ref Magnum::Complex "Complex" or + * @ref Magnum::CubicHermiteComplex "CubicHermiteComplex" for + * spline-interpolated data. * - * @see @ref AnimationTrackType::Complex, @ref ObjectData2D::rotation() + * @see @ref AnimationTrackType::Complex, + * @ref AnimationTrackType::CubicHermiteComplex, + * @ref ObjectData2D::rotation() */ Rotation2D, /** * Modifies 3D object rotation. Type is usually - * @ref Magnum::Quaternion "Quaternion". + * @ref Magnum::Quaternion "Quaternion" or + * @ref Magnum::CubicHermiteQuaternion "CubicHermiteQuaternion" for + * spline-interpolated data. * - * @see @ref AnimationTrackType::Quaternion, @ref ObjectData3D::rotation() + * @see @ref AnimationTrackType::Quaternion, + * @ref AnimationTrackType::CubicHermiteQuaternion, + * @ref ObjectData3D::rotation() */ Rotation3D, /** * Modifies 2D object scaling. Type is usually - * @ref Magnum::Vector2 "Vector2". + * @ref Magnum::Vector2 "Vector2" or + * @ref Magnum::CubicHermite2D "CubicHermite2D" for spline-interpolated + * data. * - * @see @ref AnimationTrackType::Vector2, @ref ObjectData2D::scaling() + * @see @ref AnimationTrackType::Vector2, + * @ref AnimationTrackType::CubicHermite2D, + * @ref ObjectData2D::scaling() */ Scaling2D, /** * Modifies 3D object scaling. Type is usually - * @ref Magnum::Vector3 "Vector3". + * @ref Magnum::Vector3 "Vector3" or + * @ref Magnum::CubicHermite3D "CubicHermite3D" for spline-interpolated + * data. * - * @see @ref AnimationTrackType::Vector3, @ref ObjectData3D::scaling() + * @see @ref AnimationTrackType::Vector3, + * @ref AnimationTrackType::CubicHermite3D, + * @ref ObjectData3D::scaling() */ Scaling3D, @@ -450,6 +501,12 @@ namespace Implementation { template<> constexpr AnimationTrackType animationTypeFor() { return AnimationTrackType::Complex; } template<> constexpr AnimationTrackType animationTypeFor() { return AnimationTrackType::Quaternion; } template<> constexpr AnimationTrackType animationTypeFor() { return AnimationTrackType::DualQuaternion; } + + template<> constexpr AnimationTrackType animationTypeFor() { return AnimationTrackType::CubicHermite1D; } + template<> constexpr AnimationTrackType animationTypeFor() { return AnimationTrackType::CubicHermite2D; } + template<> constexpr AnimationTrackType animationTypeFor() { return AnimationTrackType::CubicHermite3D; } + template<> constexpr AnimationTrackType animationTypeFor() { return AnimationTrackType::CubicHermiteComplex; } + template<> constexpr AnimationTrackType animationTypeFor() { return AnimationTrackType::CubicHermiteQuaternion; } /* LCOV_EXCL_STOP */ } #endif