diff --git a/doc/changelog.dox b/doc/changelog.dox index da1329e6f..65119f4ec 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -64,6 +64,11 @@ See also: be used by various importers to provide access to mesh data that is not necessarily GPU-friendly. +@subsubsection changelog-latest-new-animation Animation library + +- Added a @ref Animation::TrackViewStorage::values() getter for type-erased + access to track values + @subsubsection changelog-latest-new-audio Audio library - Added a @ref Audio::Buffer::frequency() getter diff --git a/src/Magnum/Animation/Test/TrackViewTest.cpp b/src/Magnum/Animation/Test/TrackViewTest.cpp index 2a3dd175e..6664acc0d 100644 --- a/src/Magnum/Animation/Test/TrackViewTest.cpp +++ b/src/Magnum/Animation/Test/TrackViewTest.cpp @@ -569,6 +569,10 @@ void TrackViewTest::constructCopyStorage() { Extrapolation::Extrapolated, Extrapolation::DefaultConstructed}; const TrackViewStorage b = a; + CORRADE_COMPARE(b.keys().size(), 2); + CORRADE_COMPARE(b.values().size(), 2); + CORRADE_COMPARE(Containers::arrayCast(b.keys())[1], 5.0f); + CORRADE_COMPARE(Containers::arrayCast(b.values())[1], (Vector3{0.3f, 0.6f, 1.0f})); auto& bv = *static_cast*>(&b); diff --git a/src/Magnum/Animation/Track.h b/src/Magnum/Animation/Track.h index 8e04bc9d8..d67083fb5 100644 --- a/src/Magnum/Animation/Track.h +++ b/src/Magnum/Animation/Track.h @@ -485,12 +485,25 @@ template class TrackViewStorage { /** * @brief Key data * - * @see @ref TrackView::values(), @ref TrackView::operator[]() + * @see @ref values(), @ref TrackView::operator[]() */ Containers::StridedArrayView1D keys() const { return _keys; } + /** + * @brief Type-erased value data + * @m_since_latest + * + * Use @ref TrackView and @ref TrackView::values() to get a typed view, + * alternatively you can cast to a concrete type using + * @ref Corrade::Containers::arrayCast(). + * @see @ref keys(), @ref TrackView::operator[]() + */ + Containers::StridedArrayView1D::value, const char, char>::type> values() const { + return _values; + } + private: template friend class TrackView;