/* This file is part of Magnum. Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "AnimationData.h" #include #include "Magnum/Math/Vector4.h" #include "Magnum/Math/Quaternion.h" namespace Magnum { namespace Trade { AnimationData::AnimationData(Containers::Array&& data, Containers::Array&& tracks, const Range1D& duration, const void* importerState) noexcept: _duration{duration}, _data{std::move(data)}, _tracks{std::move(tracks)}, _importerState{importerState} {} AnimationData::AnimationData(Containers::Array&& data, Containers::Array&& tracks, const void* importerState) noexcept: _data{std::move(data)}, _tracks{std::move(tracks)}, _importerState{importerState} { if(!_tracks.empty()) { /* Reset duration to duration of the first track so it properly support cases where tracks don't start at 0 */ _duration = _tracks.front()._view.duration(); for(std::size_t i = 1; i != _tracks.size(); ++i) _duration = Math::join(_duration, _tracks[i]._view.duration()); } } AnimationData::~AnimationData() = default; AnimationData::AnimationData(AnimationData&&) noexcept = default; AnimationData& AnimationData::operator=(AnimationData&&) noexcept = default; AnimationTrackType AnimationData::trackType(UnsignedInt id) const { CORRADE_ASSERT(id < _tracks.size(), "Trade::AnimationData::trackType(): index out of range", {}); return _tracks[id]._type; } AnimationTrackType AnimationData::trackResultType(UnsignedInt id) const { CORRADE_ASSERT(id < _tracks.size(), "Trade::AnimationData::trackResultType(): index out of range", {}); return _tracks[id]._resultType; } AnimationTrackTargetType AnimationData::trackTargetType(UnsignedInt id) const { CORRADE_ASSERT(id < _tracks.size(), "Trade::AnimationData::trackTargetType(): index out of range", {}); return _tracks[id]._targetType; } UnsignedInt AnimationData::trackTarget(UnsignedInt id) const { CORRADE_ASSERT(id < _tracks.size(), "Trade::AnimationData::trackTarget(): index out of range", {}); return _tracks[id]._target; } const Animation::TrackViewStorage& AnimationData::track(UnsignedInt id) const { CORRADE_ASSERT(id < _tracks.size(), "Trade::AnimationData::track(): index out of range", _tracks[id]._view); return _tracks[id]._view; } template auto animationInterpolatorFor(Animation::Interpolation interpolation) -> R(*)(const V&, const V&, Float) { return Animation::interpolatorFor(interpolation); } #ifndef DOXYGEN_GENERATING_OUTPUT template MAGNUM_TRADE_EXPORT auto animationInterpolatorFor(Animation::Interpolation) -> bool(*)(const bool&, const bool&, Float); template MAGNUM_TRADE_EXPORT auto animationInterpolatorFor(Animation::Interpolation) -> Float(*)(const Float&, const Float&, Float); template MAGNUM_TRADE_EXPORT auto animationInterpolatorFor(Animation::Interpolation) -> UnsignedInt(*)(const UnsignedInt&, const UnsignedInt&, Float); template MAGNUM_TRADE_EXPORT auto animationInterpolatorFor(Animation::Interpolation) -> Int(*)(const Int&, const Int&, Float); template MAGNUM_TRADE_EXPORT auto animationInterpolatorFor, Math::BoolVector<2>>(Animation::Interpolation) -> Math::BoolVector<2>(*)(const Math::BoolVector<2>&, const Math::BoolVector<2>&, Float); template MAGNUM_TRADE_EXPORT auto animationInterpolatorFor, Math::BoolVector<3>>(Animation::Interpolation) -> Math::BoolVector<3>(*)(const Math::BoolVector<3>&, const Math::BoolVector<3>&, Float); template MAGNUM_TRADE_EXPORT auto animationInterpolatorFor, Math::BoolVector<4>>(Animation::Interpolation) -> Math::BoolVector<4>(*)(const Math::BoolVector<4>&, const Math::BoolVector<4>&, Float); template MAGNUM_TRADE_EXPORT auto animationInterpolatorFor(Animation::Interpolation) -> Vector2(*)(const Vector2&, const Vector2&, Float); template MAGNUM_TRADE_EXPORT auto animationInterpolatorFor(Animation::Interpolation) -> Vector2i(*)(const Vector2i&, const Vector2i&, Float); template MAGNUM_TRADE_EXPORT auto animationInterpolatorFor(Animation::Interpolation) -> Vector2ui(*)(const Vector2ui&, const Vector2ui&, Float); template MAGNUM_TRADE_EXPORT auto animationInterpolatorFor(Animation::Interpolation) -> Vector3(*)(const Vector3&, const Vector3&, Float); template MAGNUM_TRADE_EXPORT auto animationInterpolatorFor(Animation::Interpolation) -> Vector3i(*)(const Vector3i&, const Vector3i&, Float); template MAGNUM_TRADE_EXPORT auto animationInterpolatorFor(Animation::Interpolation) -> Vector3ui(*)(const Vector3ui&, const Vector3ui&, Float); template MAGNUM_TRADE_EXPORT auto animationInterpolatorFor(Animation::Interpolation) -> Vector4(*)(const Vector4&, const Vector4&, Float); template MAGNUM_TRADE_EXPORT auto animationInterpolatorFor(Animation::Interpolation) -> Vector4d(*)(const Vector4d&, const Vector4d&, Float); template MAGNUM_TRADE_EXPORT auto animationInterpolatorFor(Animation::Interpolation) -> Vector4i(*)(const Vector4i&, const Vector4i&, Float); template MAGNUM_TRADE_EXPORT auto animationInterpolatorFor(Animation::Interpolation) -> Vector4ui(*)(const Vector4ui&, const Vector4ui&, Float); 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) { /* LCOV_EXCL_START */ #define _c(value) case AnimationTrackType::value: return debug << "Trade::AnimationTrackType::" #value; _c(Bool) _c(Float) _c(UnsignedInt) _c(Int) _c(BoolVector2) _c(BoolVector3) _c(BoolVector4) _c(Vector2) _c(Vector2ui) _c(Vector2i) _c(Vector3) _c(Vector3ui) _c(Vector3i) _c(Vector4) _c(Vector4ui) _c(Vector4i) _c(Complex) _c(Quaternion) _c(DualQuaternion) _c(CubicHermite1D) _c(CubicHermite2D) _c(CubicHermite3D) _c(CubicHermiteComplex) _c(CubicHermiteQuaternion) #undef _c /* LCOV_EXCL_STOP */ } return debug << "Trade::AnimationTrackType(" << Debug::nospace << reinterpret_cast(UnsignedByte(value)) << Debug::nospace << ")"; } Debug& operator<<(Debug& debug, const AnimationTrackTargetType value) { if(UnsignedByte(value) >= UnsignedByte(AnimationTrackTargetType::Custom)) return debug << "Trade::AnimationTrackTargetType::Custom(" << Debug::nospace << UnsignedByte(value) << Debug::nospace << ")"; switch(value) { /* LCOV_EXCL_START */ #define _c(value) case AnimationTrackTargetType::value: return debug << "Trade::AnimationTrackTargetType::" #value; _c(Translation2D) _c(Translation3D) _c(Rotation2D) _c(Rotation3D) _c(Scaling2D) _c(Scaling3D) #undef _c /* LCOV_EXCL_STOP */ /* To silence compiler warning about unhandled values */ case AnimationTrackTargetType::Custom: CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ } return debug << "Trade::AnimationTrackTargetType(" << Debug::nospace << reinterpret_cast(UnsignedByte(value)) << Debug::nospace << ")"; } #endif }}