From 33be039ef495dfbdc738fc82e4a05b56ab756e20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 3 Apr 2023 18:53:02 +0200 Subject: [PATCH] Trade: rename AnimationTrackTargetType to AnimationTrackTarget. The `Type` was suggesting it'd be some C++ type, definitely not values like Scaling3D or Translation2D, resulting in a significant "brain autocompletion error" every time I was using that type. Unfortunately on AnimationData the trackTargetType() couldn't similarly get renamed to trackTarget() as there's already trackTarget() that contains the node ID the target points to, so it's trackTargetName() instead. Renaming trackTarget() to trackTargetId() wasn't an option as that would be inconsistent with everything else (TextureTools::image(), MaterialAttribute::BaseColorTexture, SceneField::Mesh are all IDs but they don't have an `Id` suffix); renaming to AnimationTrackTargetName would keep it insanely long and wouldn't make it consistent either (MeshAttribute, SceneFIeld, MaterialAttribute are all referred to as "names" yet they don't have a `Name` suffix). --- doc/changelog.dox | 8 +- doc/snippets/MagnumTrade.cpp | 4 +- .../Implementation/sceneConverterUtilities.h | 2 +- .../Test/SceneConverterImplementationTest.cpp | 6 +- src/Magnum/Trade/AnimationData.cpp | 18 +-- src/Magnum/Trade/AnimationData.h | 105 ++++++++++-------- .../Trade/Test/AbstractImporterTest.cpp | 2 +- src/Magnum/Trade/Test/AnimationDataTest.cpp | 82 +++++++------- src/Magnum/Trade/Trade.h | 5 +- 9 files changed, 128 insertions(+), 104 deletions(-) diff --git a/doc/changelog.dox b/doc/changelog.dox index c7fcb4ade..a6c4c1efb 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -1143,6 +1143,10 @@ See also: changed to have input first and output second, for consistency with other interfaces, together with a switch to @ref Containers::StringView. The original signature is marked as deprecated. +- The @cpp Trade::AnimationTrackTargetType @ce enum and + @cpp Trade::AnimationData::trackTargetType() @ce is deprecated in favor of + a shorter and less confusing @ref Trade::AnimationTrackTarget and + @ref Trade::AnimationData::trackTargetName() - Due to introduction of @ref ImageFlags, @ref Trade::ImageData constructors that were taking @cpp const void* importerState @ce as the last parameter are now deprecated in favor of constructors that take @ref ImageFlags *and* @@ -1338,8 +1342,8 @@ See also: and @ref Shaders::DistanceFieldVectorGL is removed, as its benefits were rather questionable --- on the contrary, it made subclass implementation more verbose and less clear -- The @ref Trade::AnimationTrackTargetType enum was extended from 8 to 16 - bits to provide more room for custom targets, consistently with +- The @ref Trade::AnimationTrackTarget enum was extended from 8 to 16 bits to + provide more room for custom targets, consistently with @ref Trade::MeshAttribute. - Mutable access to @ref Trade::PhongMaterialData color and texture information, deprecated in 2020.06, is now removed, as it's impossible to diff --git a/doc/snippets/MagnumTrade.cpp b/doc/snippets/MagnumTrade.cpp index 4c0359003..dc05e9509 100644 --- a/doc/snippets/MagnumTrade.cpp +++ b/doc/snippets/MagnumTrade.cpp @@ -343,7 +343,7 @@ Containers::Optional data = importer->animation(id); Animation::Player player; Containers::Array positions; /* Translations for all objects */ for(UnsignedInt i = 0; i != data->trackCount(); ++i) { - if(data->trackTargetType(i) == Trade::AnimationTrackTargetType::Translation3D) { + if(data->trackTargetName(i) == Trade::AnimationTrackTarget::Translation3D) { CORRADE_INTERNAL_ASSERT(data->trackType(i) == Trade::AnimationTrackType::Vector3); player.add(data->track(i), positions[data->trackTarget(i)]); @@ -360,7 +360,7 @@ Containers::Array animationData = data->release(); /* Take ownership */ Trade::AnimationData data{nullptr, {}}; /* [AnimationData-usage-mutable] */ for(UnsignedInt i = 0; i != data.trackCount(); ++i) { - if(data.trackTargetType(i) != Trade::AnimationTrackTargetType::Translation3D) + if(data.trackTargetName(i) != Trade::AnimationTrackTarget::Translation3D) continue; /* Check prerequisites */ if(!(data.dataFlags() & Trade::DataFlag::Mutable) || diff --git a/src/Magnum/SceneTools/Implementation/sceneConverterUtilities.h b/src/Magnum/SceneTools/Implementation/sceneConverterUtilities.h index 762fef436..a62168b1e 100644 --- a/src/Magnum/SceneTools/Implementation/sceneConverterUtilities.h +++ b/src/Magnum/SceneTools/Implementation/sceneConverterUtilities.h @@ -680,7 +680,7 @@ bool printInfo(const Debug::Flags useColor, const bool useColor24, const Utility for(UnsignedInt i = 0; i != info.data.trackCount(); ++i) { d << Debug::newline << " Track" << i << Debug::nospace << ":" << Debug::packed << Debug::boldColor(Debug::Color::Default) - << info.data.trackTargetType(i) + << info.data.trackTargetName(i) << Debug::color(Debug::Color::Blue) << "@" << Debug::packed << Debug::color(Debug::Color::Cyan) << info.data.trackType(i) << Debug::resetColor; diff --git a/src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp b/src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp index 6387dbd16..836e3d736 100644 --- a/src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp +++ b/src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp @@ -323,8 +323,8 @@ void SceneConverterImplementationTest::infoAnimations() { return Trade::AnimationData{std::move(data), { /** @todo cleanup once AnimationTrackData has sane constructors */ - Trade::AnimationTrackData{Trade::AnimationTrackTargetType::Translation2D, 17, Animation::TrackView{time, translation, Animation::Interpolation::Linear, Animation::Extrapolation::DefaultConstructed, Animation::Extrapolation::Constant}}, - Trade::AnimationTrackData{Trade::AnimationTrackTargetType::Rotation2D, 17, Animation::TrackView{time, rotation, Animation::Interpolation::Constant, Animation::Extrapolation::Extrapolated}}, + Trade::AnimationTrackData{Trade::AnimationTrackTarget::Translation2D, 17, Animation::TrackView{time, translation, Animation::Interpolation::Linear, Animation::Extrapolation::DefaultConstructed, Animation::Extrapolation::Constant}}, + Trade::AnimationTrackData{Trade::AnimationTrackTarget::Rotation2D, 17, Animation::TrackView{time, rotation, Animation::Interpolation::Constant, Animation::Extrapolation::Extrapolated}}, }}; } @@ -334,7 +334,7 @@ void SceneConverterImplementationTest::infoAnimations() { return Trade::AnimationData{Trade::DataFlag::ExternallyOwned, animation2Data, { /** @todo cleanup once AnimationTrackData has sane constructors */ - Trade::AnimationTrackData{Trade::AnimationTrackTargetType::Scaling3D, 666, Animation::TrackView{animation2Data->time, animation2Data->scaling, Math::lerp, Animation::Extrapolation::DefaultConstructed, Animation::Extrapolation::Constant}}, + Trade::AnimationTrackData{Trade::AnimationTrackTarget::Scaling3D, 666, Animation::TrackView{animation2Data->time, animation2Data->scaling, Math::lerp, Animation::Extrapolation::DefaultConstructed, Animation::Extrapolation::Constant}}, }, {0.1f, 1.3f}}; } diff --git a/src/Magnum/Trade/AnimationData.cpp b/src/Magnum/Trade/AnimationData.cpp index 7a6073de8..b965d8258 100644 --- a/src/Magnum/Trade/AnimationData.cpp +++ b/src/Magnum/Trade/AnimationData.cpp @@ -89,10 +89,10 @@ AnimationTrackType AnimationData::trackResultType(UnsignedInt id) const { return _tracks[id]._resultType; } -AnimationTrackTargetType AnimationData::trackTargetType(UnsignedInt id) const { +AnimationTrackTarget AnimationData::trackTargetName(UnsignedInt id) const { CORRADE_ASSERT(id < _tracks.size(), - "Trade::AnimationData::trackTargetType(): index" << id << "out of range for" << _tracks.size() << "tracks", {}); - return _tracks[id]._targetType; + "Trade::AnimationData::trackTargetName(): index" << id << "out of range for" << _tracks.size() << "tracks", {}); + return _tracks[id]._targetName; } UnsignedLong AnimationData::trackTarget(UnsignedInt id) const { @@ -192,18 +192,18 @@ Debug& operator<<(Debug& debug, const AnimationTrackType value) { return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast(UnsignedByte(value)) << Debug::nospace << (packed ? "" : ")"); } -Debug& operator<<(Debug& debug, const AnimationTrackTargetType value) { +Debug& operator<<(Debug& debug, const AnimationTrackTarget value) { const bool packed = debug.immediateFlags() >= Debug::Flag::Packed; if(!packed) - debug << "Trade::AnimationTrackTargetType" << Debug::nospace; + debug << "Trade::AnimationTrackTarget" << Debug::nospace; - if(UnsignedShort(value) >= UnsignedShort(AnimationTrackTargetType::Custom)) + if(UnsignedShort(value) >= UnsignedShort(AnimationTrackTarget::Custom)) return debug << (packed ? "Custom(" : "::Custom(") << Debug::nospace << UnsignedShort(value) << Debug::nospace << ")"; switch(value) { /* LCOV_EXCL_START */ - #define _c(value) case AnimationTrackTargetType::value: return debug << (packed ? "" : "::") << Debug::nospace << #value; + #define _c(value) case AnimationTrackTarget::value: return debug << (packed ? "" : "::") << Debug::nospace << #value; _c(Translation2D) _c(Translation3D) _c(Rotation2D) @@ -213,8 +213,8 @@ Debug& operator<<(Debug& debug, const AnimationTrackTargetType value) { #undef _c /* LCOV_EXCL_STOP */ - /* To silence compiler warning about unhandled values */ - case AnimationTrackTargetType::Custom: CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ + /* To silence compiler warnings about unhandled values */ + case AnimationTrackTarget::Custom: CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ } return debug << (packed ? "" : "(") << Debug::nospace << reinterpret_cast(UnsignedShort(value)) << Debug::nospace << (packed ? "" : ")"); diff --git a/src/Magnum/Trade/AnimationData.h b/src/Magnum/Trade/AnimationData.h index 0248c1bcc..b3f72c8f9 100644 --- a/src/Magnum/Trade/AnimationData.h +++ b/src/Magnum/Trade/AnimationData.h @@ -26,7 +26,7 @@ */ /** @file - * @brief Class @ref Magnum::Trade::AnimationTrackData, @ref Magnum::Trade::AnimationData, enum @ref Magnum::Trade::AnimationTrackType, @ref Magnum::Trade::AnimationTrackTargetType, function @ref Magnum::Trade::animationInterpolatorFor() + * @brief Class @ref Magnum::Trade::AnimationTrackData, @ref Magnum::Trade::AnimationData, enum @ref Magnum::Trade::AnimationTrackType, @ref Magnum::Trade::AnimationTrackTarget, function @ref Magnum::Trade::animationInterpolatorFor() */ #include "Magnum/Magnum.h" @@ -99,8 +99,8 @@ enum class AnimationTrackType: UnsignedByte { /** * @ref Magnum::Vector2 "Vector2". Usually used for - * @ref AnimationTrackTargetType::Translation2D and - * @ref AnimationTrackTargetType::Scaling2D. + * @ref AnimationTrackTarget::Translation2D and + * @ref AnimationTrackTarget::Scaling2D. */ Vector2, @@ -109,8 +109,8 @@ enum class AnimationTrackType: UnsignedByte { /** * @ref Magnum::Vector3 "Vector3". Usually used for - * @ref AnimationTrackTargetType::Translation3D and - * @ref AnimationTrackTargetType::Scaling3D. + * @ref AnimationTrackTarget::Translation3D and + * @ref AnimationTrackTarget::Scaling3D. */ Vector3, @@ -122,13 +122,13 @@ enum class AnimationTrackType: UnsignedByte { /** * @ref Magnum::Complex "Complex". Usually used for - * @ref AnimationTrackTargetType::Rotation2D. + * @ref AnimationTrackTarget::Rotation2D. */ Complex, /** * @ref Magnum::Quaternion "Quaternion". Usually used for - * @ref AnimationTrackTargetType::Rotation3D. + * @ref AnimationTrackTarget::Rotation3D. */ Quaternion, @@ -137,27 +137,27 @@ enum class AnimationTrackType: UnsignedByte { /** * @ref Magnum::CubicHermite2D "CubicHermite2D". Usually used for - * spline-interpolated @ref AnimationTrackTargetType::Translation2D and - * @ref AnimationTrackTargetType::Scaling2D. + * spline-interpolated @ref AnimationTrackTarget::Translation2D and + * @ref AnimationTrackTarget::Scaling2D. */ CubicHermite2D, /** * @ref Magnum::CubicHermite3D "CubicHermite3D". Usually used for - * spline-interpolated @ref AnimationTrackTargetType::Translation3D and - * @ref AnimationTrackTargetType::Scaling3D. + * spline-interpolated @ref AnimationTrackTarget::Translation3D and + * @ref AnimationTrackTarget::Scaling3D. */ CubicHermite3D, /** * @ref Magnum::CubicHermiteComplex "CubicHermiteComplex". Usually used for - * spline-interpolated @ref AnimationTrackTargetType::Rotation2D. + * spline-interpolated @ref AnimationTrackTarget::Rotation2D. */ CubicHermiteComplex, /** * @ref Magnum::CubicHermiteQuaternion "CubicHermiteQuaternion". Usually - * used for spline-interpolated @ref AnimationTrackTargetType::Rotation3D. + * used for spline-interpolated @ref AnimationTrackTarget::Rotation3D. */ CubicHermiteQuaternion }; @@ -171,7 +171,7 @@ MAGNUM_TRADE_EXPORT Debug& operator<<(Debug& debug, AnimationTrackType value); @see @ref AnimationData @experimental */ -enum class AnimationTrackTargetType: UnsignedShort { +enum class AnimationTrackTarget: UnsignedShort { /* Zero used for an invalid value */ /** @@ -255,8 +255,16 @@ enum class AnimationTrackTargetType: UnsignedShort { Custom = 32768 }; -/** @debugoperatorenum{AnimationTrackTargetType} */ -MAGNUM_TRADE_EXPORT Debug& operator<<(Debug& debug, AnimationTrackTargetType value); +#ifdef MAGNUM_BUILD_DEPRECATED +/** +@brief @copybrief AnimationTrackTarget +@m_deprecated_since_latest Use @ref AnimationTrackTarget instead. +*/ +typedef CORRADE_DEPRECATED("use AnimationTrackTarget instead") AnimationTrackTarget AnimationTrackTargetType; +#endif + +/** @debugoperatorenum{AnimationTrackTarget} */ +MAGNUM_TRADE_EXPORT Debug& operator<<(Debug& debug, AnimationTrackTarget value); /** @brief Animation track data @@ -274,45 +282,45 @@ class AnimationTrackData { * initialization of the track array for @ref AnimationData, expected * to be replaced with concrete values later. */ - explicit AnimationTrackData() noexcept: _type{}, _resultType{}, _targetType{}, _target{}, _view{} {} + explicit AnimationTrackData() noexcept: _type{}, _resultType{}, _targetName{}, _target{}, _view{} {} /** * @brief Type-erased constructor * @param type Value type * @param resultType Result type - * @param targetType Track target type - * @param target Track target + * @param targetName Track target name + * @param target Track target ID * @param view Type-erased @ref Animation::TrackView instance */ /** @todo stop taking TrackViewStorage and instead directly take the key/value views, interpolator/interpolation and extrapolation -- it's just 6 overloads and makes usage much better */ - explicit AnimationTrackData(AnimationTrackType type, AnimationTrackType resultType, AnimationTrackTargetType targetType, UnsignedLong target, Animation::TrackViewStorage view) noexcept: _type{type}, _resultType{resultType}, _targetType{targetType}, _target{target}, _view{view} {} + explicit AnimationTrackData(AnimationTrackType type, AnimationTrackType resultType, AnimationTrackTarget targetName, UnsignedLong target, Animation::TrackViewStorage view) noexcept: _type{type}, _resultType{resultType}, _targetName{targetName}, _target{target}, _view{view} {} /** @overload * * Equivalent to the above with @p type used as both value type and * result type. */ - explicit AnimationTrackData(AnimationTrackType type, AnimationTrackTargetType targetType, UnsignedLong target, Animation::TrackViewStorage view) noexcept: _type{type}, _resultType{type}, _targetType{targetType}, _target{target}, _view{view} {} + explicit AnimationTrackData(AnimationTrackType type, AnimationTrackTarget targetName, UnsignedLong target, Animation::TrackViewStorage view) noexcept: _type{type}, _resultType{type}, _targetName{targetName}, _target{target}, _view{view} {} /** * @brief Constructor - * @param targetType Track target type - * @param target Track target + * @param targetName Track target name + * @param target Track target ID * @param view @ref Animation::TrackView instance * @m_since{2020,06} * * Detects @ref AnimationTrackType from @p view type and delegates to - * @ref AnimationTrackData(AnimationTrackType, AnimationTrackType, AnimationTrackTargetType, UnsignedLong, Animation::TrackViewStorage). + * @ref AnimationTrackData(AnimationTrackType, AnimationTrackType, AnimationTrackTarget, UnsignedLong, Animation::TrackViewStorage). */ - template explicit AnimationTrackData(AnimationTrackTargetType targetType, UnsignedLong target, Animation::TrackView view) noexcept; + template explicit AnimationTrackData(AnimationTrackTarget targetName, UnsignedLong target, Animation::TrackView view) noexcept; private: friend AnimationData; AnimationTrackType _type, _resultType; - AnimationTrackTargetType _targetType; + AnimationTrackTarget _targetName; /* 4-byte padding */ UnsignedLong _target; Animation::TrackViewStorage _view; @@ -517,9 +525,8 @@ class MAGNUM_TRADE_EXPORT AnimationData { * @brief Track value type * @param id Track index * - * Data types are usually closely related to @ref trackTargetType(), - * see @ref AnimationTrackTargetType documentation for more - * information. + * Data types are usually closely related to @ref trackTargetName(), + * see @ref AnimationTrackTarget documentation for more information. * @see @ref trackCount() */ AnimationTrackType trackType(UnsignedInt id) const; @@ -530,34 +537,44 @@ class MAGNUM_TRADE_EXPORT AnimationData { * * In case track values are packed, track result type is different from * @ref trackType(). Data types are usually closely related to - * @ref trackTargetType(), see @ref AnimationTrackTargetType - * documentation for more information. + * @ref trackTargetName(), see @ref AnimationTrackTarget documentation + * for more information. * @see @ref trackCount() */ AnimationTrackType trackResultType(UnsignedInt id) const; /** - * @brief Track target type + * @brief Track target name * @param id Track index * * Particular animation targets usually correspond to a common - * @ref trackType(), see @ref AnimationTrackTargetType documentation - * for more information. + * @ref trackType(), see @ref AnimationTrackTarget documentation for + * more information. * @see @ref trackCount() */ - AnimationTrackTargetType trackTargetType(UnsignedInt id) const; + AnimationTrackTarget trackTargetName(UnsignedInt id) const; + + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @brief @copybrief trackTargetName() + * @m_deprecated_since_latest Use @ref trackTargetName() instead. + */ + CORRADE_DEPRECATED("use trackTargetName() instead") AnimationTrackTarget trackTargetType(UnsignedInt id) const { + return trackTargetName(id); + } + #endif /** - * @brief Track target + * @brief Track target ID * @param id Track index * - * For @ref trackTargetType() with - * @ref AnimationTrackTargetType::Translation2D, - * @ref AnimationTrackTargetType::Translation3D, - * @ref AnimationTrackTargetType::Rotation2D, - * @ref AnimationTrackTargetType::Rotation3D, - * @ref AnimationTrackTargetType::Scaling2D, - * @ref AnimationTrackTargetType::Scaling3D specifies object which + * For @ref trackTargetName() with + * @ref AnimationTrackTarget::Translation2D, + * @ref AnimationTrackTarget::Translation3D, + * @ref AnimationTrackTarget::Rotation2D, + * @ref AnimationTrackTarget::Rotation3D, + * @ref AnimationTrackTarget::Scaling2D, + * @ref AnimationTrackTarget::Scaling3D specifies object which * property is modified. * @see @ref trackCount(), @ref AbstractImporter::scene() */ @@ -698,7 +715,7 @@ namespace Implementation { /* LCOV_EXCL_STOP */ } -template inline AnimationTrackData::AnimationTrackData(AnimationTrackTargetType targetType, UnsignedLong target, Animation::TrackView view) noexcept: AnimationTrackData{Implementation::animationTypeFor(), Implementation::animationTypeFor(), targetType, target, view} {} +template inline AnimationTrackData::AnimationTrackData(AnimationTrackTarget targetName, UnsignedLong target, Animation::TrackView view) noexcept: AnimationTrackData{Implementation::animationTypeFor(), Implementation::animationTypeFor(), targetName, target, view} {} template const Animation::TrackView& AnimationData::track(UnsignedInt id) const { const Animation::TrackViewStorage& storage = track(id); diff --git a/src/Magnum/Trade/Test/AbstractImporterTest.cpp b/src/Magnum/Trade/Test/AbstractImporterTest.cpp index e08414e73..1c5290c41 100644 --- a/src/Magnum/Trade/Test/AbstractImporterTest.cpp +++ b/src/Magnum/Trade/Test/AbstractImporterTest.cpp @@ -3843,7 +3843,7 @@ void AbstractImporterTest::animation() { the default deleter and not something disallowed */ if(id == 7) return AnimationData{nullptr, { AnimationTrackData{AnimationTrackType::Vector3, - AnimationTrackTargetType::Scaling3D, 0, {}} + AnimationTrackTarget::Scaling3D, 0, {}} }, &state}; return AnimationData{{}, {}}; } diff --git a/src/Magnum/Trade/Test/AnimationDataTest.cpp b/src/Magnum/Trade/Test/AnimationDataTest.cpp index 13f577979..5e72ba668 100644 --- a/src/Magnum/Trade/Test/AnimationDataTest.cpp +++ b/src/Magnum/Trade/Test/AnimationDataTest.cpp @@ -63,8 +63,8 @@ struct AnimationDataTest: TestSuite::Tester { void debugAnimationTrackType(); void debugAnimationTrackTypePacked(); - void debugAnimationTrackTargetType(); - void debugAnimationTrackTargetTypePacked(); + void debugAnimationTrackTarget(); + void debugAnimationTrackTargetPacked(); }; struct { @@ -106,8 +106,8 @@ AnimationDataTest::AnimationDataTest() { &AnimationDataTest::debugAnimationTrackType, &AnimationDataTest::debugAnimationTrackTypePacked, - &AnimationDataTest::debugAnimationTrackTargetType, - &AnimationDataTest::debugAnimationTrackTargetTypePacked}); + &AnimationDataTest::debugAnimationTrackTarget, + &AnimationDataTest::debugAnimationTrackTargetPacked}); } using namespace Math::Literals; @@ -115,7 +115,7 @@ using namespace Math::Literals; void AnimationDataTest::constructTrackData() { AnimationTrackData trackData{ AnimationTrackType::Vector3, - AnimationTrackTargetType::Translation3D, 42, + AnimationTrackTarget::Translation3D, 42, Animation::TrackView{ nullptr, Animation::Interpolation::Linear, @@ -123,7 +123,7 @@ void AnimationDataTest::constructTrackData() { AnimationData data{nullptr, Containers::Array{InPlaceInit, {trackData}}}; CORRADE_COMPARE(data.trackType(0), AnimationTrackType::Vector3); CORRADE_COMPARE(data.trackResultType(0), AnimationTrackType::Vector3); - CORRADE_COMPARE(data.trackTargetType(0), AnimationTrackTargetType::Translation3D); + CORRADE_COMPARE(data.trackTargetName(0), AnimationTrackTarget::Translation3D); CORRADE_COMPARE(data.trackTarget(0), 42); CORRADE_COMPARE(data.track(0).interpolation(), Animation::Interpolation::Linear); } @@ -132,7 +132,7 @@ void AnimationDataTest::constructTrackDataResultType() { AnimationTrackData trackData{ AnimationTrackType::CubicHermite3D, AnimationTrackType::Vector3, - AnimationTrackTargetType::Translation3D, 42, + AnimationTrackTarget::Translation3D, 42, Animation::TrackView{ nullptr, Animation::Interpolation::Linear, @@ -140,14 +140,14 @@ void AnimationDataTest::constructTrackDataResultType() { AnimationData data{nullptr, Containers::Array{InPlaceInit, {trackData}}}; CORRADE_COMPARE(data.trackType(0), AnimationTrackType::CubicHermite3D); CORRADE_COMPARE(data.trackResultType(0), AnimationTrackType::Vector3); - CORRADE_COMPARE(data.trackTargetType(0), AnimationTrackTargetType::Translation3D); + CORRADE_COMPARE(data.trackTargetName(0), AnimationTrackTarget::Translation3D); CORRADE_COMPARE(data.trackTarget(0), 42); CORRADE_COMPARE(data.track(0).interpolation(), Animation::Interpolation::Linear); } void AnimationDataTest::constructTrackDataTemplate() { AnimationTrackData trackData{ - AnimationTrackTargetType::Translation3D, 42, + AnimationTrackTarget::Translation3D, 42, Animation::TrackView{ nullptr, Animation::Interpolation::Linear, @@ -155,7 +155,7 @@ void AnimationDataTest::constructTrackDataTemplate() { AnimationData data{nullptr, Containers::Array{InPlaceInit, {trackData}}}; CORRADE_COMPARE(data.trackType(0), AnimationTrackType::CubicHermite3D); CORRADE_COMPARE(data.trackResultType(0), AnimationTrackType::Vector3); - CORRADE_COMPARE(data.trackTargetType(0), AnimationTrackTargetType::Translation3D); + CORRADE_COMPARE(data.trackTargetName(0), AnimationTrackTarget::Translation3D); CORRADE_COMPARE(data.trackTarget(0), 42); CORRADE_COMPARE(data.track(0).interpolation(), Animation::Interpolation::Linear); } @@ -181,13 +181,13 @@ void AnimationDataTest::construct() { const int state = 5; AnimationData data{std::move(buffer), { - AnimationTrackData{AnimationTrackTargetType::Translation3D, 42, + AnimationTrackData{AnimationTrackTarget::Translation3D, 42, Animation::TrackView{ {view, &view[0].time, view.size(), sizeof(Data)}, {view, &view[0].position, view.size(), sizeof(Data)}, Animation::Interpolation::Constant, animationInterpolatorFor(Animation::Interpolation::Constant)}}, - AnimationTrackData{AnimationTrackTargetType::Rotation3D, 1337, + AnimationTrackData{AnimationTrackTarget::Rotation3D, 1337, Animation::TrackView{ {view, &view[0].time, view.size(), sizeof(Data)}, {view, &view[0].rotation, view.size(), sizeof(Data)}, @@ -205,7 +205,7 @@ void AnimationDataTest::construct() { { CORRADE_COMPARE(data.trackType(0), AnimationTrackType::Vector3); CORRADE_COMPARE(data.trackResultType(0), AnimationTrackType::Vector3); - CORRADE_COMPARE(data.trackTargetType(0), AnimationTrackTargetType::Translation3D); + CORRADE_COMPARE(data.trackTargetName(0), AnimationTrackTarget::Translation3D); CORRADE_COMPARE(data.trackTarget(0), 42); Animation::TrackView track = data.track(0); @@ -222,7 +222,7 @@ void AnimationDataTest::construct() { } { CORRADE_COMPARE(data.trackType(1), AnimationTrackType::Quaternion); CORRADE_COMPARE(data.trackResultType(1), AnimationTrackType::Quaternion); - CORRADE_COMPARE(data.trackTargetType(1), AnimationTrackTargetType::Rotation3D); + CORRADE_COMPARE(data.trackTargetName(1), AnimationTrackTarget::Rotation3D); CORRADE_COMPARE(data.trackTarget(1), 1337); Animation::TrackView track = data.track(1); @@ -249,12 +249,12 @@ void AnimationDataTest::constructImplicitDuration() { const int state = 5; AnimationData data{std::move(buffer), { - AnimationTrackData{AnimationTrackTargetType(32769), 0, + AnimationTrackData{AnimationTrackTarget(32769), 0, Animation::TrackView{ {view, &view[0].time, 2, sizeof(Data)}, {view, &view[0].value, 2, sizeof(Data)}, Animation::Interpolation::Constant}}, - AnimationTrackData{AnimationTrackTargetType(32770), 1, + AnimationTrackData{AnimationTrackTarget(32770), 1, Animation::TrackView{ {view, &view[2].time, 2, sizeof(Data)}, {view, &view[2].value, 2, sizeof(Data)}, @@ -268,7 +268,7 @@ void AnimationDataTest::constructImplicitDuration() { { CORRADE_COMPARE(data.trackType(0), AnimationTrackType::Bool); CORRADE_COMPARE(data.trackResultType(0), AnimationTrackType::Bool); - CORRADE_COMPARE(data.trackTargetType(0), AnimationTrackTargetType(32769)); + CORRADE_COMPARE(data.trackTargetName(0), AnimationTrackTarget(32769)); CORRADE_COMPARE(data.trackTarget(0), 0); Animation::TrackView track = data.track(0); @@ -287,7 +287,7 @@ void AnimationDataTest::constructImplicitDuration() { } { CORRADE_COMPARE(data.trackType(1), AnimationTrackType::Bool); CORRADE_COMPARE(data.trackResultType(1), AnimationTrackType::Bool); - CORRADE_COMPARE(data.trackTargetType(1), AnimationTrackTargetType(32770)); + CORRADE_COMPARE(data.trackTargetName(1), AnimationTrackTarget(32770)); CORRADE_COMPARE(data.trackTarget(1), 1); Animation::TrackView track = data.track(1); @@ -317,7 +317,7 @@ void AnimationDataTest::constructNotOwned() { const int state = 5; AnimationData data{instanceData.dataFlags, keyframes, { - AnimationTrackData{AnimationTrackTargetType::Translation3D, 42, + AnimationTrackData{AnimationTrackTarget::Translation3D, 42, Animation::TrackView{ keyframes, Animation::Interpolation::Constant, @@ -335,7 +335,7 @@ void AnimationDataTest::constructNotOwned() { { CORRADE_COMPARE(data.trackType(0), AnimationTrackType::Vector3); CORRADE_COMPARE(data.trackResultType(0), AnimationTrackType::Vector3); - CORRADE_COMPARE(data.trackTargetType(0), AnimationTrackTargetType::Translation3D); + CORRADE_COMPARE(data.trackTargetName(0), AnimationTrackTarget::Translation3D); CORRADE_COMPARE(data.trackTarget(0), 42); Animation::TrackView track = data.track(0); @@ -365,7 +365,7 @@ void AnimationDataTest::constructImplicitDurationNotOwned() { const int state = 5; AnimationData data{instanceData.dataFlags, keyframes, { - AnimationTrackData{AnimationTrackTargetType(32769), 0, + AnimationTrackData{AnimationTrackTarget(32769), 0, Animation::TrackView{keyframes, Animation::Interpolation::Constant}}, }, &state}; @@ -380,7 +380,7 @@ void AnimationDataTest::constructImplicitDurationNotOwned() { { CORRADE_COMPARE(data.trackType(0), AnimationTrackType::Bool); CORRADE_COMPARE(data.trackResultType(0), AnimationTrackType::Bool); - CORRADE_COMPARE(data.trackTargetType(0), AnimationTrackTargetType(32769)); + CORRADE_COMPARE(data.trackTargetName(0), AnimationTrackTarget(32769)); CORRADE_COMPARE(data.trackTarget(0), 0); Animation::TrackView track = data.track(0); @@ -441,13 +441,13 @@ void AnimationDataTest::constructMove() { const int state = 5; AnimationData a{std::move(buffer), { - AnimationTrackData{AnimationTrackTargetType::Translation3D, 42, + AnimationTrackData{AnimationTrackTarget::Translation3D, 42, Animation::TrackView{ {view, &view[0].time, view.size(), sizeof(Data)}, {view, &view[0].position, view.size(), sizeof(Data)}, Animation::Interpolation::Constant, animationInterpolatorFor(Animation::Interpolation::Constant)}}, - AnimationTrackData{AnimationTrackTargetType::Rotation3D, 1337, + AnimationTrackData{AnimationTrackTarget::Rotation3D, 1337, Animation::TrackView{ {view, &view[0].time, view.size(), sizeof(Data)}, {view, &view[0].rotation, view.size(), sizeof(Data)}, @@ -465,7 +465,7 @@ void AnimationDataTest::constructMove() { { CORRADE_COMPARE(b.trackType(0), AnimationTrackType::Vector3); CORRADE_COMPARE(b.trackResultType(0), AnimationTrackType::Vector3); - CORRADE_COMPARE(b.trackTargetType(0), AnimationTrackTargetType::Translation3D); + CORRADE_COMPARE(b.trackTargetName(0), AnimationTrackTarget::Translation3D); CORRADE_COMPARE(b.trackTarget(0), 42); Animation::TrackView track = b.track(0); @@ -476,7 +476,7 @@ void AnimationDataTest::constructMove() { } { CORRADE_COMPARE(b.trackType(1), AnimationTrackType::Quaternion); CORRADE_COMPARE(b.trackResultType(1), AnimationTrackType::Quaternion); - CORRADE_COMPARE(b.trackTargetType(1), AnimationTrackTargetType::Rotation3D); + CORRADE_COMPARE(b.trackTargetName(1), AnimationTrackTarget::Rotation3D); CORRADE_COMPARE(b.trackTarget(1), 1337); Animation::TrackView track = b.track(1); @@ -498,7 +498,7 @@ void AnimationDataTest::constructMove() { { CORRADE_COMPARE(c.trackType(0), AnimationTrackType::Vector3); CORRADE_COMPARE(c.trackResultType(0), AnimationTrackType::Vector3); - CORRADE_COMPARE(c.trackTargetType(0), AnimationTrackTargetType::Translation3D); + CORRADE_COMPARE(c.trackTargetName(0), AnimationTrackTarget::Translation3D); CORRADE_COMPARE(c.trackTarget(0), 42); Animation::TrackView track = c.track(0); @@ -509,7 +509,7 @@ void AnimationDataTest::constructMove() { } { CORRADE_COMPARE(c.trackType(1), AnimationTrackType::Quaternion); CORRADE_COMPARE(c.trackResultType(1), AnimationTrackType::Quaternion); - CORRADE_COMPARE(c.trackTargetType(1), AnimationTrackTargetType::Rotation3D); + CORRADE_COMPARE(c.trackTargetName(1), AnimationTrackTarget::Rotation3D); CORRADE_COMPARE(c.trackTarget(1), 1337); Animation::TrackView track = c.track(1); @@ -532,7 +532,7 @@ void AnimationDataTest::mutableAccessNotAllowed() { }; AnimationData data{{}, keyframes, { - AnimationTrackData{AnimationTrackTargetType(32769), 0, + AnimationTrackData{AnimationTrackTarget(32769), 0, Animation::TrackView{keyframes, Animation::Interpolation::Constant}}, }}; CORRADE_COMPARE(data.dataFlags(), DataFlags{}); @@ -561,7 +561,7 @@ void AnimationDataTest::trackCustomResultType() { view[1] = {5.0f, {30, 60, 100}}; AnimationData data{std::move(buffer), { - AnimationTrackData{AnimationTrackTargetType::Scaling3D, 0, + AnimationTrackData{AnimationTrackTarget::Scaling3D, 0, Animation::TrackView{ {view, &view[0].time, view.size(), sizeof(Data)}, {view, &view[0].position, view.size(), sizeof(Data)}, @@ -581,11 +581,11 @@ void AnimationDataTest::trackWrongIndex() { AnimationData data{nullptr, { AnimationTrackData{AnimationTrackType::Vector3, - AnimationTrackTargetType::Scaling3D, 0, {}} + AnimationTrackTarget::Scaling3D, 0, {}} }}; data.trackType(1); data.trackResultType(1); - data.trackTargetType(1); + data.trackTargetName(1); data.trackTarget(1); data.track(1); data.mutableTrack(1); @@ -593,7 +593,7 @@ void AnimationDataTest::trackWrongIndex() { CORRADE_COMPARE(out.str(), "Trade::AnimationData::trackType(): index 1 out of range for 1 tracks\n" "Trade::AnimationData::trackResultType(): index 1 out of range for 1 tracks\n" - "Trade::AnimationData::trackTargetType(): index 1 out of range for 1 tracks\n" + "Trade::AnimationData::trackTargetName(): index 1 out of range for 1 tracks\n" "Trade::AnimationData::trackTarget(): index 1 out of range for 1 tracks\n" "Trade::AnimationData::track(): index 1 out of range for 1 tracks\n" "Trade::AnimationData::mutableTrack(): index 1 out of range for 1 tracks\n"); @@ -608,7 +608,7 @@ void AnimationDataTest::trackWrongType() { AnimationData data{nullptr, { AnimationTrackData{AnimationTrackType::Vector3i, AnimationTrackType::Vector3, - AnimationTrackTargetType::Scaling3D, 0, {}} + AnimationTrackTarget::Scaling3D, 0, {}} }}; data.track(0); @@ -625,7 +625,7 @@ void AnimationDataTest::trackWrongResultType() { AnimationData data{nullptr, { AnimationTrackData{AnimationTrackType::Vector3i, AnimationTrackType::Vector3, - AnimationTrackTargetType::Scaling3D, 0, {}} + AnimationTrackTarget::Scaling3D, 0, {}} }}; data.track(0); @@ -640,7 +640,7 @@ void AnimationDataTest::release() { }; AnimationData data{{}, keyframes, { - AnimationTrackData{AnimationTrackTargetType(32769), 0, + AnimationTrackData{AnimationTrackTarget(32769), 0, Animation::TrackView{keyframes, Animation::Interpolation::Constant}}, }}; CORRADE_COMPARE(data.trackCount(), 1); @@ -665,17 +665,17 @@ void AnimationDataTest::debugAnimationTrackTypePacked() { CORRADE_COMPARE(out.str(), "DualQuaternion 0xde Trade::AnimationTrackType::Float\n"); } -void AnimationDataTest::debugAnimationTrackTargetType() { +void AnimationDataTest::debugAnimationTrackTarget() { std::ostringstream out; - Debug{&out} << AnimationTrackTargetType::Rotation3D << AnimationTrackTargetType(32777) << AnimationTrackTargetType(0x4242); - CORRADE_COMPARE(out.str(), "Trade::AnimationTrackTargetType::Rotation3D Trade::AnimationTrackTargetType::Custom(32777) Trade::AnimationTrackTargetType(0x4242)\n"); + Debug{&out} << AnimationTrackTarget::Rotation3D << AnimationTrackTarget(32777) << AnimationTrackTarget(0x4242); + CORRADE_COMPARE(out.str(), "Trade::AnimationTrackTarget::Rotation3D Trade::AnimationTrackTarget::Custom(32777) Trade::AnimationTrackTarget(0x4242)\n"); } -void AnimationDataTest::debugAnimationTrackTargetTypePacked() { +void AnimationDataTest::debugAnimationTrackTargetPacked() { std::ostringstream out; /* Last is not packed, ones before should not make any flags persistent */ - Debug{&out} << Debug::packed << AnimationTrackTargetType::Rotation3D << Debug::packed << AnimationTrackTargetType(32888) << Debug::packed << AnimationTrackTargetType(0x4242) << AnimationTrackType::Float; + Debug{&out} << Debug::packed << AnimationTrackTarget::Rotation3D << Debug::packed << AnimationTrackTarget(32888) << Debug::packed << AnimationTrackTarget(0x4242) << AnimationTrackType::Float; CORRADE_COMPARE(out.str(), "Rotation3D Custom(32888) 0x4242 Trade::AnimationTrackType::Float\n"); } diff --git a/src/Magnum/Trade/Trade.h b/src/Magnum/Trade/Trade.h index b9abf643e..9dc14db6c 100644 --- a/src/Magnum/Trade/Trade.h +++ b/src/Magnum/Trade/Trade.h @@ -61,7 +61,10 @@ class MaterialData; typedef CORRADE_DEPRECATED("use MaterialData instead") MaterialData AbstractMaterialData; #endif -enum class AnimationTrackTargetType: UnsignedShort; +enum class AnimationTrackTarget: UnsignedShort; +#ifdef MAGNUM_BUILD_DEPRECATED +typedef CORRADE_DEPRECATED("use AnimationTrackTarget instead") AnimationTrackTarget AnimationTrackTargetType; +#endif enum class AnimationTrackType: UnsignedByte; class AnimationTrackData; class AnimationData;