diff --git a/doc/snippets/MagnumAnimation.cpp b/doc/snippets/MagnumAnimation.cpp index 6f8c95e2b..f4204660c 100644 --- a/doc/snippets/MagnumAnimation.cpp +++ b/doc/snippets/MagnumAnimation.cpp @@ -342,12 +342,12 @@ const Keyframe data[]{ }; Animation::TrackView positions{ - {&data[0].time, Containers::arraySize(data), sizeof(Keyframe)}, - {&data[0].position, Containers::arraySize(data), sizeof(Keyframe)}, + {data, &data[0].time, Containers::arraySize(data), sizeof(Keyframe)}, + {data, &data[0].position, Containers::arraySize(data), sizeof(Keyframe)}, Math::lerp}; Animation::TrackView rotations{ - {&data[0].time, Containers::arraySize(data), sizeof(Keyframe)}, - {&data[0].rotation, Containers::arraySize(data), sizeof(Keyframe)}, + {data, &data[0].time, Containers::arraySize(data), sizeof(Keyframe)}, + {data, &data[0].rotation, Containers::arraySize(data), sizeof(Keyframe)}, Math::lerp}; Float time = 2.2f; diff --git a/src/Magnum/Animation/Interpolation.h b/src/Magnum/Animation/Interpolation.h index f9c5f3915..ecc4025d2 100644 --- a/src/Magnum/Animation/Interpolation.h +++ b/src/Magnum/Animation/Interpolation.h @@ -198,7 +198,7 @@ documentation for more information. @ref Math::slerp(), @ref Math::sclerp() @experimental */ -template> R interpolate(const Containers::StridedArrayView& keys, const Containers::StridedArrayView& values, Extrapolation before, Extrapolation after, R(*interpolator)(const V&, const V&, Float), K frame, std::size_t& hint); +template> R interpolate(const Containers::StridedArrayView1D& keys, const Containers::StridedArrayView1D& values, Extrapolation before, Extrapolation after, R(*interpolator)(const V&, const V&, Float), K frame, std::size_t& hint); /** @brief Interpolate animation value with strict constraints @@ -221,7 +221,7 @@ Used internally from @ref Track::atStrict() / @ref TrackView::atStrict(), see @ref Math::sclerp() @experimental */ -template> R interpolateStrict(const Containers::StridedArrayView& keys, const Containers::StridedArrayView& values, R(*interpolator)(const V&, const V&, Float), K frame, std::size_t& hint); +template> R interpolateStrict(const Containers::StridedArrayView1D& keys, const Containers::StridedArrayView1D& values, R(*interpolator)(const V&, const V&, Float), K frame, std::size_t& hint); /** @brief Combine easing function and an interpolator @@ -368,7 +368,7 @@ template auto interpolatorFor(Interpolation interpolation) -> return Implementation::TypeTraits::interpolator(interpolation); } -template R interpolate(const Containers::StridedArrayView& keys, const Containers::StridedArrayView& values, const Extrapolation before, const Extrapolation after, R(*const interpolator)(const V&, const V&, Float), K frame, std::size_t& hint) { +template R interpolate(const Containers::StridedArrayView1D& keys, const Containers::StridedArrayView1D& values, const Extrapolation before, const Extrapolation after, R(*const interpolator)(const V&, const V&, Float), K frame, std::size_t& hint) { CORRADE_ASSERT(keys.size() == values.size(), "Animation::interpolate(): keys and values don't have the same size", {}); /* No data, return default-constructed value */ @@ -404,7 +404,7 @@ template R interpolate(const Containers::StridedArray Math::lerpInverted(Float(keys[hint]), Float(keys[hint + 1]), Float(frame))); } -template R interpolateStrict(const Containers::StridedArrayView& keys, const Containers::StridedArrayView& values, R(*const interpolator)(const V&, const V&, Float), const K frame, std::size_t& hint) { +template R interpolateStrict(const Containers::StridedArrayView1D& keys, const Containers::StridedArrayView1D& values, R(*const interpolator)(const V&, const V&, Float), const K frame, std::size_t& hint) { CORRADE_ASSERT(keys.size() >= 2, "Animation::interpolateStrict(): at least two keyframes required", {}); CORRADE_ASSERT(keys.size() == values.size(), "Animation::interpolateStrict(): keys and values don't have the same size", {}); diff --git a/src/Magnum/Animation/Test/Benchmark.cpp b/src/Magnum/Animation/Test/Benchmark.cpp index d10871227..0983e0240 100644 --- a/src/Magnum/Animation/Test/Benchmark.cpp +++ b/src/Magnum/Animation/Test/Benchmark.cpp @@ -53,8 +53,8 @@ struct Benchmark: TestSuite::Tester { Containers::Array _keys; Containers::Array _values; Containers::Array> _interleaved; - Containers::StridedArrayView _keysInterleaved; - Containers::StridedArrayView _valuesInterleaved; + Containers::StridedArrayView1D _keysInterleaved; + Containers::StridedArrayView1D _valuesInterleaved; TrackView _track; TrackView _trackInterleaved; }; @@ -88,8 +88,8 @@ Benchmark::Benchmark() { for(std::size_t i = 0; i != DataSize; ++i) _keys[i] = _interleaved[i].first = Float(i)*3.1254f; - _keysInterleaved = {&_interleaved[0].first, _interleaved.size(), sizeof(std::pair)}; - _valuesInterleaved = {&_interleaved[0].second, _interleaved.size(), sizeof(std::pair)}; + _keysInterleaved = {_interleaved, &_interleaved[0].first, _interleaved.size(), sizeof(std::pair)}; + _valuesInterleaved = {_interleaved, &_interleaved[0].second, _interleaved.size(), sizeof(std::pair)}; _track = TrackView{ Containers::arrayView(_keys), Containers::arrayView(_values), Math::select}; diff --git a/src/Magnum/Animation/Test/TrackViewTest.cpp b/src/Magnum/Animation/Test/TrackViewTest.cpp index e8c7e8a85..728c3a67f 100644 --- a/src/Magnum/Animation/Test/TrackViewTest.cpp +++ b/src/Magnum/Animation/Test/TrackViewTest.cpp @@ -417,7 +417,7 @@ Float lerpHalf(const Half& a, const Half& b, Float t) { void TrackViewTest::atDifferentResultType() { const TrackView a{ - {&Keyframes[0].first, Containers::arraySize(Keyframes), sizeof(Keyframes[0])}, + {Keyframes, &Keyframes[0].first, Containers::arraySize(Keyframes), sizeof(Keyframes[0])}, HalfValues, lerpHalf}; std::size_t hint{}; @@ -428,7 +428,7 @@ void TrackViewTest::atDifferentResultType() { void TrackViewTest::atDifferentResultTypeStrict() { const TrackView a{ - {&Keyframes[0].first, Containers::arraySize(Keyframes), sizeof(Keyframes[0])}, + {Keyframes, &Keyframes[0].first, Containers::arraySize(Keyframes), sizeof(Keyframes[0])}, HalfValues, lerpHalf}; std::size_t hint{}; diff --git a/src/Magnum/Animation/Track.h b/src/Magnum/Animation/Track.h index 877b6468f..89dcc95f6 100644 --- a/src/Magnum/Animation/Track.h +++ b/src/Magnum/Animation/Track.h @@ -303,8 +303,8 @@ template keys() const { - return _data ? Containers::StridedArrayView{&_data[0].first, _data.size(), sizeof(std::pair)} : nullptr; + Containers::StridedArrayView1D keys() const { + return _data ? Containers::StridedArrayView1D{_data, &_data[0].first, _data.size(), sizeof(std::pair)} : nullptr; } /** @@ -312,8 +312,8 @@ template values() const { - return _data ? Containers::StridedArrayView{&_data[0].second, _data.size(), sizeof(std::pair)} : nullptr; + Containers::StridedArrayView1D values() const { + return _data ? Containers::StridedArrayView1D{_data, &_data[0].second, _data.size(), sizeof(std::pair)} : nullptr; } /** @@ -466,17 +466,17 @@ template class TrackViewStorage { * * @see @ref TrackView::values(), @ref TrackView::operator[]() */ - Containers::StridedArrayView keys() const { + Containers::StridedArrayView1D keys() const { return _keys; } private: template friend class TrackView; - template explicit TrackViewStorage(const Containers::StridedArrayView& keys, const Containers::StridedArrayView& values, Interpolation interpolation, R(*interpolator)(const V&, const V&, Float), Extrapolation before, Extrapolation after) noexcept: _keys{keys}, _values{reinterpret_cast&>(values)}, _interpolator{reinterpret_cast(interpolator)}, _interpolation{interpolation}, _before{before}, _after{after} {} + template explicit TrackViewStorage(const Containers::StridedArrayView1D& keys, const Containers::StridedArrayView1D& values, Interpolation interpolation, R(*interpolator)(const V&, const V&, Float), Extrapolation before, Extrapolation after) noexcept: _keys{keys}, _values{reinterpret_cast&>(values)}, _interpolator{reinterpret_cast(interpolator)}, _interpolation{interpolation}, _before{before}, _after{after} {} - Containers::StridedArrayView _keys; - Containers::StridedArrayView _values; + Containers::StridedArrayView1D _keys; + Containers::StridedArrayView1D _values; void(*_interpolator)(void); Interpolation _interpolation; Extrapolation _before, _after; @@ -527,17 +527,17 @@ template&, const Containers::StridedArrayView&, Interpolation, Interpolator, Extrapolation, Extrapolation) or - * @ref TrackView(const Containers::StridedArrayView&, const Containers::StridedArrayView&, Interpolation, Extrapolation, Extrapolation) + * See @ref TrackView(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&, Interpolation, Interpolator, Extrapolation, Extrapolation) or + * @ref TrackView(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&, Interpolation, Extrapolation, Extrapolation) * for an alternative. */ - /*implicit*/ TrackView(const Containers::StridedArrayView& keys, const Containers::StridedArrayView& values, Interpolator interpolator, Extrapolation before, Extrapolation after) noexcept: TrackViewStorage{keys, values, Interpolation::Custom, interpolator, before, after} {} + /*implicit*/ TrackView(const Containers::StridedArrayView1D& keys, const Containers::StridedArrayView1D& values, Interpolator interpolator, Extrapolation before, Extrapolation after) noexcept: TrackViewStorage{keys, values, Interpolation::Custom, interpolator, before, after} {} /** @overload - * Equivalent to calling @ref TrackView(const Containers::StridedArrayView&, const Containers::StridedArrayView&, Interpolator, Extrapolation, Extrapolation) + * Equivalent to calling @ref TrackView(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&, Interpolator, Extrapolation, Extrapolation) * with both @p before and @p after set to @p extrapolation. */ - /*implicit*/ TrackView(const Containers::StridedArrayView& keys, const Containers::StridedArrayView& values, Interpolator interpolator, Extrapolation extrapolation = Extrapolation::Constant) noexcept: TrackView{keys, values, interpolator, extrapolation, extrapolation} {} + /*implicit*/ TrackView(const Containers::StridedArrayView1D& keys, const Containers::StridedArrayView1D& values, Interpolator interpolator, Extrapolation extrapolation = Extrapolation::Constant) noexcept: TrackView{keys, values, interpolator, extrapolation, extrapolation} {} /** * @brief Construct with custom interpolator from an interleaved array @@ -547,9 +547,9 @@ template&, const Containers::StridedArrayView&, Interpolator, Extrapolation, Extrapolation). + * @ref TrackView(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&, Interpolator, Extrapolation, Extrapolation). */ - /*implicit*/ TrackView(Containers::ArrayView> data, Interpolator interpolator, Extrapolation before, Extrapolation after) noexcept: TrackView{Containers::StridedArrayView{data ? &data[0].first : nullptr, data.size(), sizeof(std::pair)}, Containers::StridedArrayView{data ? &data[0].second : nullptr, data.size(), sizeof(std::pair)}, interpolator, before, after} {} + /*implicit*/ TrackView(Containers::ArrayView> data, Interpolator interpolator, Extrapolation before, Extrapolation after) noexcept: TrackView{Containers::StridedArrayView1D{data, data ? &data[0].first : nullptr, data.size(), sizeof(std::pair)}, Containers::StridedArrayView1D{data, data ? &data[0].second : nullptr, data.size(), sizeof(std::pair)}, interpolator, before, after} {} /** @overload * Equivalent to calling @ref TrackView(Containers::ArrayView>, Interpolator, Extrapolation, Extrapolation) @@ -572,13 +572,13 @@ template& keys, const Containers::StridedArrayView& values, Interpolation interpolation, Interpolator interpolator, Extrapolation before, Extrapolation after) noexcept: TrackViewStorage{keys, values, interpolation, interpolator, before, after} {} + /*implicit*/ TrackView(const Containers::StridedArrayView1D& keys, const Containers::StridedArrayView1D& values, Interpolation interpolation, Interpolator interpolator, Extrapolation before, Extrapolation after) noexcept: TrackViewStorage{keys, values, interpolation, interpolator, before, after} {} /** @overload - * Equivalent to calling @ref TrackView(const Containers::StridedArrayView&, const Containers::StridedArrayView&, Interpolation, Interpolator, Extrapolation, Extrapolation) + * Equivalent to calling @ref TrackView(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&, Interpolation, Interpolator, Extrapolation, Extrapolation) * with both @p before and @p after set to @p extrapolation. */ - /*implicit*/ TrackView(const Containers::StridedArrayView& keys, const Containers::StridedArrayView& values, Interpolation interpolation, Interpolator interpolator, Extrapolation extrapolation = Extrapolation::Constant) noexcept: TrackView{keys, values, interpolation, interpolator, extrapolation, extrapolation} {} + /*implicit*/ TrackView(const Containers::StridedArrayView1D& keys, const Containers::StridedArrayView1D& values, Interpolation interpolation, Interpolator interpolator, Extrapolation extrapolation = Extrapolation::Constant) noexcept: TrackView{keys, values, interpolation, interpolator, extrapolation, extrapolation} {} /** * @brief Construct with both generic and custom interpolator from an interleaved array @@ -589,9 +589,9 @@ template&, const Containers::StridedArrayView&, Interpolator, Extrapolation, Extrapolation). + * @ref TrackView(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&, Interpolator, Extrapolation, Extrapolation). */ - /*implicit*/ TrackView(Containers::ArrayView> data, Interpolation interpolation, Interpolator interpolator, Extrapolation before, Extrapolation after) noexcept: TrackViewStorage{Containers::StridedArrayView{data ? &data[0].first : nullptr, data.size(), sizeof(std::pair)}, Containers::StridedArrayView{data ? &data[0].second : nullptr, data.size(), sizeof(std::pair)}, interpolation, interpolator, before, after} {} + /*implicit*/ TrackView(Containers::ArrayView> data, Interpolation interpolation, Interpolator interpolator, Extrapolation before, Extrapolation after) noexcept: TrackViewStorage{Containers::StridedArrayView1D{data, data ? &data[0].first : nullptr, data.size(), sizeof(std::pair)}, Containers::StridedArrayView1D{data, data ? &data[0].second : nullptr, data.size(), sizeof(std::pair)}, interpolation, interpolator, before, after} {} /** @overload * Equivalent to calling @ref TrackView(Containers::ArrayView>, Interpolation, Interpolator, Extrapolation, Extrapolation) @@ -613,13 +613,13 @@ template& keys, const Containers::StridedArrayView& values, Interpolation interpolation, Extrapolation before, Extrapolation after) noexcept: TrackViewStorage{keys, values, interpolation, interpolatorFor(interpolation), before, after} {} + /*implicit*/ TrackView(const Containers::StridedArrayView1D& keys, const Containers::StridedArrayView1D& values, Interpolation interpolation, Extrapolation before, Extrapolation after) noexcept: TrackViewStorage{keys, values, interpolation, interpolatorFor(interpolation), before, after} {} /** @overload - * Equivalent to calling @ref TrackView(const Containers::StridedArrayView&, const Containers::StridedArrayView&, Interpolation, Extrapolation, Extrapolation) + * Equivalent to calling @ref TrackView(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&, Interpolation, Extrapolation, Extrapolation) * with both @p before and @p after set to @p extrapolation. */ - /*implicit*/ TrackView(const Containers::StridedArrayView& keys, const Containers::StridedArrayView& values, Interpolation interpolation, Extrapolation extrapolation = Extrapolation::Constant) noexcept: TrackView{keys, values, interpolation, extrapolation, extrapolation} {} + /*implicit*/ TrackView(const Containers::StridedArrayView1D& keys, const Containers::StridedArrayView1D& values, Interpolation interpolation, Extrapolation extrapolation = Extrapolation::Constant) noexcept: TrackView{keys, values, interpolation, extrapolation, extrapolation} {} /** * @brief Construct with generic interpolation behavior from an interleaved array @@ -629,9 +629,9 @@ template&, const Containers::StridedArrayView&, Interpolator, Extrapolation, Extrapolation). + * @ref TrackView(const Containers::StridedArrayView1D&, const Containers::StridedArrayView1D&, Interpolator, Extrapolation, Extrapolation). */ - /*implicit*/ TrackView(Containers::ArrayView> data, Interpolation interpolation, Extrapolation before, Extrapolation after) noexcept: TrackView{Containers::StridedArrayView{data ? &data[0].first : nullptr, data.size(), sizeof(std::pair)}, Containers::StridedArrayView{data ? &data[0].second : nullptr, data.size(), sizeof(std::pair)}, interpolation, before, after} {} + /*implicit*/ TrackView(Containers::ArrayView> data, Interpolation interpolation, Extrapolation before, Extrapolation after) noexcept: TrackView{Containers::StridedArrayView1D{data, data ? &data[0].first : nullptr, data.size(), sizeof(std::pair)}, Containers::StridedArrayView1D{data, data ? &data[0].second : nullptr, data.size(), sizeof(std::pair)}, interpolation, before, after} {} /** @overload * Equivalent to calling @ref TrackView(Containers::ArrayView>, Interpolation, Extrapolation, Extrapolation) @@ -653,8 +653,8 @@ template values() const { - return reinterpret_cast&>(TrackViewStorage::_values); + Containers::StridedArrayView1D values() const { + return reinterpret_cast&>(TrackViewStorage::_values); } /** diff --git a/src/Magnum/Trade/Test/AnimationDataTest.cpp b/src/Magnum/Trade/Test/AnimationDataTest.cpp index 892d8fdbc..7016868da 100644 --- a/src/Magnum/Trade/Test/AnimationDataTest.cpp +++ b/src/Magnum/Trade/Test/AnimationDataTest.cpp @@ -93,15 +93,15 @@ void AnimationDataTest::construct() { {AnimationTrackType::Vector3, AnimationTrackTargetType::Translation3D, 42, Animation::TrackView{ - {&view[0].time, view.size(), sizeof(Data)}, - {&view[0].position, view.size(), sizeof(Data)}, + {view, &view[0].time, view.size(), sizeof(Data)}, + {view, &view[0].position, view.size(), sizeof(Data)}, Animation::Interpolation::Constant, animationInterpolatorFor(Animation::Interpolation::Constant)}}, {AnimationTrackType::Quaternion, AnimationTrackTargetType::Rotation3D, 1337, Animation::TrackView{ - {&view[0].time, view.size(), sizeof(Data)}, - {&view[0].rotation, view.size(), sizeof(Data)}, + {view, &view[0].time, view.size(), sizeof(Data)}, + {view, &view[0].rotation, view.size(), sizeof(Data)}, Animation::Interpolation::Linear, animationInterpolatorFor(Animation::Interpolation::Linear)}} }}, {-1.0f, 7.0f}, &state}; @@ -155,14 +155,14 @@ void AnimationDataTest::constructImplicitDuration() { {AnimationTrackType::Bool, AnimationTrackTargetType(129), 0, Animation::TrackView{ - {&view[0].time, 2, sizeof(Data)}, - {&view[0].value, 2, sizeof(Data)}, + {view, &view[0].time, 2, sizeof(Data)}, + {view, &view[0].value, 2, sizeof(Data)}, Animation::Interpolation::Constant}}, {AnimationTrackType::Bool, AnimationTrackTargetType(130), 1, Animation::TrackView{ - {&view[2].time, 2, sizeof(Data)}, - {&view[2].value, 2, sizeof(Data)}, + {view, &view[2].time, 2, sizeof(Data)}, + {view, &view[2].value, 2, sizeof(Data)}, Animation::Interpolation::Linear}} }}, &state}; @@ -224,15 +224,15 @@ void AnimationDataTest::constructMove() { {AnimationTrackType::Vector3, AnimationTrackTargetType::Translation3D, 42, Animation::TrackView{ - {&view[0].time, view.size(), sizeof(Data)}, - {&view[0].position, view.size(), sizeof(Data)}, + {view, &view[0].time, view.size(), sizeof(Data)}, + {view, &view[0].position, view.size(), sizeof(Data)}, Animation::Interpolation::Constant, animationInterpolatorFor(Animation::Interpolation::Constant)}}, {AnimationTrackType::Quaternion, AnimationTrackTargetType::Rotation3D, 1337, Animation::TrackView{ - {&view[0].time, view.size(), sizeof(Data)}, - {&view[0].rotation, view.size(), sizeof(Data)}, + {view, &view[0].time, view.size(), sizeof(Data)}, + {view, &view[0].rotation, view.size(), sizeof(Data)}, Animation::Interpolation::Linear, animationInterpolatorFor(Animation::Interpolation::Linear)}} }}, {-1.0f, 7.0f}, &state}; @@ -324,8 +324,8 @@ void AnimationDataTest::trackCustomResultType() { AnimationTrackType::Vector3, AnimationTrackTargetType::Scaling3D, 0, Animation::TrackView{ - {&view[0].time, view.size(), sizeof(Data)}, - {&view[0].position, view.size(), sizeof(Data)}, + {view, &view[0].time, view.size(), sizeof(Data)}, + {view, &view[0].position, view.size(), sizeof(Data)}, [](const Vector3i& a, const Vector3i& b, Float t) -> Vector3 { return Math::lerp(Vector3{a}*0.01f, Vector3{b}*0.01f, t); }}}}