From 6a129b2cd281947cfc8c0f7168c9f7d3c949d33e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 5 Apr 2023 18:47:05 +0200 Subject: [PATCH] Animation: add TrackViewStorage::interpolator(). It was the last remaining field that wasn't queryable from this type-erased base. --- doc/changelog.dox | 3 +++ src/Magnum/Animation/Test/TrackViewTest.cpp | 1 + src/Magnum/Animation/Track.h | 12 ++++++++++++ 3 files changed, 16 insertions(+) diff --git a/doc/changelog.dox b/doc/changelog.dox index 42b37a40d..13941357a 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -438,6 +438,9 @@ See also: @ref Animation::BasicEasing "easing functions" implemented with double precision, in addition to single-precision @ref Animation::Easing, and similar in spirit to the @ref Constants and @ref Constantsd typedefs. +- Added @ref Animation::TrackViewStorage::interpolator() for getting a + type-erased interpolator pointer without having to cast to a concrete + @ref Animation::TrackView type @subsubsection changelog-latest-changes-debugtools DebugTools library diff --git a/src/Magnum/Animation/Test/TrackViewTest.cpp b/src/Magnum/Animation/Test/TrackViewTest.cpp index 0e5206385..dad64bae8 100644 --- a/src/Magnum/Animation/Test/TrackViewTest.cpp +++ b/src/Magnum/Animation/Test/TrackViewTest.cpp @@ -569,6 +569,7 @@ void TrackViewTest::constructCopyStorage() { Extrapolation::Extrapolated, Extrapolation::DefaultConstructed}; const TrackViewStorage b = a; + CORRADE_COMPARE(b.interpolator(), reinterpret_cast(customLerp)); CORRADE_COMPARE(b.keys().size(), 2); CORRADE_COMPARE(b.values().size(), 2); CORRADE_COMPARE(Containers::arrayCast(b.keys())[1], 5.0f); diff --git a/src/Magnum/Animation/Track.h b/src/Magnum/Animation/Track.h index 4096e49ce..a9f9f679c 100644 --- a/src/Magnum/Animation/Track.h +++ b/src/Magnum/Animation/Track.h @@ -482,6 +482,18 @@ template class TrackViewStorage { return _keys.size(); } + /** + * @brief Type-erased interpolation function + * @m_since_latest + * + * Has to be cast to a type corresponding to the value type before use. + * Use @ref TrackView and @ref TrackView::interpolator() to get the + * interpolator function in a concrete type. + */ + void(*interpolator() const)() { + return _interpolator; + } + /** * @brief Key data *