template<class K, class V, class R = ResultOf<V>>
Magnum::Animation::TrackView class

Animation track view.

Template parameters
K Key type
V Value type
R Result type

Unlike Track this is a non-owning view onto keyframe + value pairs. The K and V can be either both mutable or both const. See the Track documentation for more information.

Base classes

template<class K>
class TrackViewStorage<K>
Type-erased track view storage.

Public types

using ValueType = V
Value type.
using KeyValueType = std::conditional<std::is_const<K>::value, const std::pair<typename std::remove_const<K>::type, typename std::remove_const<V>::type>, std::pair<K, V>>::type
Key-value type.
using ResultType = R
Animation result type.
using Interpolator = ResultType(*)(const ValueType&, const ValueType&, Float)
Interpolation function.

Constructors, destructors, conversion operators

TrackView() noexcept
Construct an empty track.
TrackView(const Containers::StridedArrayView1D<K>& keys, const Containers::StridedArrayView1D<V>& values, Interpolator interpolator, Extrapolation before, Extrapolation after) noexcept
Construct with custom interpolator.
TrackView(const Containers::StridedArrayView1D<K>& keys, const Containers::StridedArrayView1D<V>& values, Interpolator interpolator, Extrapolation extrapolation = Extrapolation::Constant) noexcept
TrackView(Containers::ArrayView<KeyValueType> data, Interpolator interpolator, Extrapolation before, Extrapolation after) noexcept
Construct with custom interpolator from an interleaved array.
TrackView(Containers::ArrayView<KeyValueType> data, Interpolator interpolator, Extrapolation extrapolation = Extrapolation::Constant) explicit noexcept
TrackView(const Containers::StridedArrayView1D<K>& keys, const Containers::StridedArrayView1D<V>& values, Interpolation interpolation, Interpolator interpolator, Extrapolation before, Extrapolation after) noexcept
Construct with both generic and custom interpolator.
TrackView(const Containers::StridedArrayView1D<K>& keys, const Containers::StridedArrayView1D<V>& values, Interpolation interpolation, Interpolator interpolator, Extrapolation extrapolation = Extrapolation::Constant) noexcept
TrackView(Containers::ArrayView<KeyValueType> data, Interpolation interpolation, Interpolator interpolator, Extrapolation before, Extrapolation after) noexcept
Construct with both generic and custom interpolator from an interleaved array.
TrackView(Containers::ArrayView<KeyValueType> data, Interpolation interpolation, Interpolator interpolator, Extrapolation extrapolation = Extrapolation::Constant) noexcept
TrackView(const Containers::StridedArrayView1D<K>& keys, const Containers::StridedArrayView1D<V>& values, Interpolation interpolation, Extrapolation before, Extrapolation after) noexcept
Construct with generic interpolation behavior.
TrackView(const Containers::StridedArrayView1D<K>& keys, const Containers::StridedArrayView1D<V>& values, Interpolation interpolation, Extrapolation extrapolation = Extrapolation::Constant) noexcept
TrackView(Containers::ArrayView<KeyValueType> data, Interpolation interpolation, Extrapolation before, Extrapolation after) noexcept
Construct with generic interpolation behavior from an interleaved array.
TrackView(Containers::ArrayView<KeyValueType> data, Interpolation interpolation, Extrapolation extrapolation = Extrapolation::Constant) noexcept
template<class K2, class V2, class = typename std::enable_if<std::is_same<const K2, K>::value&& std::is_same<const V2, V>::value>::type>
TrackView(const TrackView<K2, V2, R>& other) noexcept
Convert a mutable view to a const one.

Public functions

auto interpolator() const -> Interpolator
Interpolation function.
auto values() const -> Containers::StridedArrayView1D<V>
Value data.
auto operator[](std::size_t i) const -> std::pair<typename std::remove_const<K>::type, typename std::remove_const<V>::type>
Keyframe access.
auto at(K frame) const -> R
Animated value at a given time.
auto at(K frame, std::size_t& hint) const -> R
Animated value at a given time.
auto at(Interpolator interpolator, K frame) const -> R
Animated value at a given time.
auto at(Interpolator interpolator, K frame, std::size_t& hint) const -> R
Animated value at a given time.
auto atStrict(K frame, std::size_t& hint) const -> R
Animated value at a given time.
auto atStrict(Interpolator interpolator, K frame, std::size_t& hint) const -> R
Animated value at a given time.

Typedef documentation

template<class K, class V, class R>
typedef std::conditional<std::is_const<K>::value, const std::pair<typename std::remove_const<K>::type, typename std::remove_const<V>::type>, std::pair<K, V>>::type Magnum::Animation::TrackView<K, V, R>::KeyValueType

Key-value type.

Used mainly when converting from Track. Equal to std::pair<K, V> if K and V are not const, and to const std::pair<K_, V_> (where K_ / V_ are with const removed) when they are const.

Function documentation

template<class K, class V, class R>
Magnum::Animation::TrackView<K, V, R>::TrackView() noexcept

Construct an empty track.

The keys(), values() and interpolator() functions return nullptr, at() always returns a default-constructed value.

template<class K, class V, class R>
Magnum::Animation::TrackView<K, V, R>::TrackView(const Containers::StridedArrayView1D<K>& keys, const Containers::StridedArrayView1D<V>& values, Interpolator interpolator, Extrapolation before, Extrapolation after) noexcept

Construct with custom interpolator.

Parameters
keys Frame keys
values Frame values
interpolator Interpolation function
before Extrapolation behavior before
after Extrapolation behavior after

The keyframe data are assumed to be stored in sorted order. It's not an error to have two successive keyframes with the same frame value. The interpolation() field is set to Interpolation::Custom. See TrackView(const Containers::StridedArrayView1D<K>&, const Containers::StridedArrayView1D<V>&, Interpolation, Interpolator, Extrapolation, Extrapolation) or TrackView(const Containers::StridedArrayView1D<K>&, const Containers::StridedArrayView1D<V>&, Interpolation, Extrapolation, Extrapolation) for an alternative.

template<class K, class V, class R>
Magnum::Animation::TrackView<K, V, R>::TrackView(const Containers::StridedArrayView1D<K>& keys, const Containers::StridedArrayView1D<V>& values, Interpolator interpolator, Extrapolation extrapolation = Extrapolation::Constant) noexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Equivalent to calling TrackView(const Containers::StridedArrayView1D<K>&, const Containers::StridedArrayView1D<V>&, Interpolator, Extrapolation, Extrapolation) with both before and after set to extrapolation.

template<class K, class V, class R>
Magnum::Animation::TrackView<K, V, R>::TrackView(Containers::ArrayView<KeyValueType> data, Interpolator interpolator, Extrapolation before, Extrapolation after) noexcept

Construct with custom interpolator from an interleaved array.

Parameters
data Keyframe data
interpolator Interpolation function
before Extrapolation behavior before
after Extrapolation behavior after

Converts data to a pair of strided array views and calls TrackView(const Containers::StridedArrayView1D<K>&, const Containers::StridedArrayView1D<V>&, Interpolator, Extrapolation, Extrapolation).

template<class K, class V, class R>
Magnum::Animation::TrackView<K, V, R>::TrackView(Containers::ArrayView<KeyValueType> data, Interpolator interpolator, Extrapolation extrapolation = Extrapolation::Constant) explicit noexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Equivalent to calling TrackView(Containers::ArrayView<KeyValueType>, Interpolator, Extrapolation, Extrapolation) with both before and after set to extrapolation.

template<class K, class V, class R>
Magnum::Animation::TrackView<K, V, R>::TrackView(const Containers::StridedArrayView1D<K>& keys, const Containers::StridedArrayView1D<V>& values, Interpolation interpolation, Interpolator interpolator, Extrapolation before, Extrapolation after) noexcept

Construct with both generic and custom interpolator.

Parameters
keys Frame keys
values Frame values
interpolation Interpolation behavior
interpolator Interpolator function
before Extrapolation behavior before
after Extrapolation behavior after

The keyframe data are assumed to be stored in sorted order. It's not an error to have two successive keyframes with the same frame value. interpolation acts as a behavior hint to users that might want to supply their own interpolator function to at() or atStrict().

template<class K, class V, class R>
Magnum::Animation::TrackView<K, V, R>::TrackView(const Containers::StridedArrayView1D<K>& keys, const Containers::StridedArrayView1D<V>& values, Interpolation interpolation, Interpolator interpolator, Extrapolation extrapolation = Extrapolation::Constant) noexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Equivalent to calling TrackView(const Containers::StridedArrayView1D<K>&, const Containers::StridedArrayView1D<V>&, Interpolation, Interpolator, Extrapolation, Extrapolation) with both before and after set to extrapolation.

template<class K, class V, class R>
Magnum::Animation::TrackView<K, V, R>::TrackView(Containers::ArrayView<KeyValueType> data, Interpolation interpolation, Interpolator interpolator, Extrapolation before, Extrapolation after) noexcept

Construct with both generic and custom interpolator from an interleaved array.

Parameters
data Keyframe data
interpolation Interpolation behavior
interpolator Interpolator function
before Extrapolation behavior before
after Extrapolation behavior after

Converts data to a pair of strided array views and calls TrackView(const Containers::StridedArrayView1D<K>&, const Containers::StridedArrayView1D<V>&, Interpolator, Extrapolation, Extrapolation).

template<class K, class V, class R>
Magnum::Animation::TrackView<K, V, R>::TrackView(Containers::ArrayView<KeyValueType> data, Interpolation interpolation, Interpolator interpolator, Extrapolation extrapolation = Extrapolation::Constant) noexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Equivalent to calling TrackView(Containers::ArrayView<KeyValueType>, Interpolation, Interpolator, Extrapolation, Extrapolation) with both before and after set to extrapolation.

template<class K, class V, class R>
Magnum::Animation::TrackView<K, V, R>::TrackView(const Containers::StridedArrayView1D<K>& keys, const Containers::StridedArrayView1D<V>& values, Interpolation interpolation, Extrapolation before, Extrapolation after) noexcept

Construct with generic interpolation behavior.

Parameters
keys Frame keys
values Frame values
interpolation Interpolation behavior
before Extrapolation behavior before
after Extrapolation behavior after

The keyframe data are assumed to be stored in sorted order. It's not an error to have two successive keyframes with the same frame value. The interpolator() function is autodetected from interpolation using interpolatorFor(). See its documentation for more information.

template<class K, class V, class R>
Magnum::Animation::TrackView<K, V, R>::TrackView(const Containers::StridedArrayView1D<K>& keys, const Containers::StridedArrayView1D<V>& values, Interpolation interpolation, Extrapolation extrapolation = Extrapolation::Constant) noexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Equivalent to calling TrackView(const Containers::StridedArrayView1D<K>&, const Containers::StridedArrayView1D<V>&, Interpolation, Extrapolation, Extrapolation) with both before and after set to extrapolation.

template<class K, class V, class R>
Magnum::Animation::TrackView<K, V, R>::TrackView(Containers::ArrayView<KeyValueType> data, Interpolation interpolation, Extrapolation before, Extrapolation after) noexcept

Construct with generic interpolation behavior from an interleaved array.

Parameters
data Keyframe data
interpolation Interpolation behavior
before Extrapolation behavior before
after Extrapolation behavior after

Converts data to a pair of strided array views and calls TrackView(const Containers::StridedArrayView1D<K>&, const Containers::StridedArrayView1D<V>&, Interpolator, Extrapolation, Extrapolation).

template<class K, class V, class R>
Magnum::Animation::TrackView<K, V, R>::TrackView(Containers::ArrayView<KeyValueType> data, Interpolation interpolation, Extrapolation extrapolation = Extrapolation::Constant) noexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Equivalent to calling TrackView(Containers::ArrayView<KeyValueType>, Interpolation, Extrapolation, Extrapolation) with both before and after set to extrapolation.

template<class K, class V, class R>
Interpolator Magnum::Animation::TrackView<K, V, R>::interpolator() const

Interpolation function.

template<class K, class V, class R>
Containers::StridedArrayView1D<V> Magnum::Animation::TrackView<K, V, R>::values() const

Value data.

template<class K, class V, class R>
std::pair<typename std::remove_const<K>::type, typename std::remove_const<V>::type> Magnum::Animation::TrackView<K, V, R>::operator[](std::size_t i) const

Keyframe access.

template<class K, class V, class R>
R Magnum::Animation::TrackView<K, V, R>::at(K frame) const

Animated value at a given time.

Calls interpolate(), see its documentation for more information. Note that this function performs a linear search every time, use at(K, std::size_t&) const to supply a search hint.

template<class K, class V, class R>
R Magnum::Animation::TrackView<K, V, R>::at(K frame, std::size_t& hint) const

Animated value at a given time.

Calls interpolate(), see its documentation for more information.

template<class K, class V, class R>
R Magnum::Animation::TrackView<K, V, R>::at(Interpolator interpolator, K frame) const

Animated value at a given time.

Unlike at(K) const calls interpolate() with interpolator, overriding the interpolator function set in constructor. See its documentation for more information.

template<class K, class V, class R>
R Magnum::Animation::TrackView<K, V, R>::at(Interpolator interpolator, K frame, std::size_t& hint) const

Animated value at a given time.

Unlike at(K, std::size_t&) const calls interpolate() with interpolator, overriding the interpolator function set in constructor. See its documentation for more information.

template<class K, class V, class R>
R Magnum::Animation::TrackView<K, V, R>::atStrict(K frame, std::size_t& hint) const

Animated value at a given time.

A faster version of at(K, std::size_t&) const with some restrictions. Calls interpolateStrict(), see its documentation for more information.

template<class K, class V, class R>
R Magnum::Animation::TrackView<K, V, R>::atStrict(Interpolator interpolator, K frame, std::size_t& hint) const

Animated value at a given time.

Unlike atStrict(K, std::size_t&) const calls interpolate() with interpolator, overriding the interpolator function set in constructor. See its documentation for more information.