From 905b87424273231461b570a03a8ec04180a2d7b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 5 Apr 2023 17:07:03 +0200 Subject: [PATCH] sceneconverter: show names of custom animation track targers in --info. --- .../Implementation/sceneConverterUtilities.h | 23 +++++++++++++++---- .../Test/SceneConverterImplementationTest.cpp | 13 +++++++++-- .../info-animations.txt | 2 ++ 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/Magnum/SceneTools/Implementation/sceneConverterUtilities.h b/src/Magnum/SceneTools/Implementation/sceneConverterUtilities.h index 10c891b5e..d5a87a8e6 100644 --- a/src/Magnum/SceneTools/Implementation/sceneConverterUtilities.h +++ b/src/Magnum/SceneTools/Implementation/sceneConverterUtilities.h @@ -69,6 +69,7 @@ template Containers::String calculateBounds(Containers::Array&& attr bool printInfo(const Debug::Flags useColor, const bool useColor24, const Utility::Arguments& args, Trade::AbstractImporter& importer, std::chrono::high_resolution_clock::duration& importTime) { struct AnimationTrackInfo { Trade::AnimationTrackTarget targetName; + Containers::String customTargetName; Trade::AnimationTrackType type, resultType; Animation::Interpolation interpolation; Animation::Extrapolation before, after; @@ -303,8 +304,11 @@ bool printInfo(const Debug::Flags useColor, const bool useColor24, const Utility info.duration = animation->duration(); for(UnsignedInt j = 0; j != animation->trackCount(); ++j) { + const Trade::AnimationTrackTarget name = animation->trackTargetName(j); arrayAppend(info.tracks, InPlaceInit, - animation->trackTargetName(j), + name, + Trade::isAnimationTrackTargetCustom(name) ? + importer.animationTrackTargetName(name) : "", animation->trackType(j), animation->trackResultType(j), animation->track(j).interpolation(), @@ -707,10 +711,19 @@ bool printInfo(const Debug::Flags useColor, const bool useColor24, const Utility const AnimationTrackInfo& track = info.tracks[i]; d << Debug::newline << " Track" << i << Debug::nospace << ":" - << Debug::packed << Debug::boldColor(Debug::Color::Default) - << track.targetName << Debug::color(Debug::Color::Blue) << "@" - << Debug::packed << Debug::color(Debug::Color::Cyan) - << track.type << Debug::resetColor; + << Debug::boldColor(Debug::Color::Default); + if(Trade::isAnimationTrackTargetCustom(track.targetName)) { + d << "Custom(" << Debug::nospace + << Trade::animationTrackTargetCustom(track.targetName) + << Debug::nospace << ":" << Debug::nospace + << Debug::color(Debug::Color::Yellow) + << track.customTargetName << Debug::nospace + << Debug::boldColor(Debug::Color::Default) << ")"; + } else d << Debug::packed << track.targetName; + + d << Debug::color(Debug::Color::Blue) << "@" << Debug::packed + << Debug::color(Debug::Color::Cyan) << track.type + << Debug::resetColor; if(track.type != track.resultType) d << Debug::color(Debug::Color::Blue) << "->" << Debug::packed << Debug::color(Debug::Color::Cyan) diff --git a/src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp b/src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp index 836e3d736..398100415 100644 --- a/src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp +++ b/src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp @@ -309,15 +309,17 @@ void SceneConverterImplementationTest::infoAnimations() { } Containers::Optional doAnimation(UnsignedInt id) override { /* First has two tracks with a shared time and implicit duration, - one with a different result type. */ + one with a different result type, one with a custom target. */ if(id == 0) { Containers::ArrayView time; Containers::ArrayView translation; Containers::ArrayView rotation; + Containers::ArrayView visibility; Containers::ArrayTuple data{ {ValueInit, 3, time}, {ValueInit, 3, translation}, - {ValueInit, 3, rotation} + {ValueInit, 3, rotation}, + {ValueInit, 3, visibility}, }; Utility::copy({0.5f, 1.0f, 1.25f}, time); return Trade::AnimationData{std::move(data), { @@ -325,6 +327,7 @@ void SceneConverterImplementationTest::infoAnimations() { constructors */ 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}}, + Trade::AnimationTrackData{Trade::animationTrackTargetCustom(333), 666, Animation::TrackView{time, visibility, Animation::Interpolation::Constant, Animation::Extrapolation::Constant}}, }}; } @@ -341,6 +344,12 @@ void SceneConverterImplementationTest::infoAnimations() { CORRADE_INTERNAL_ASSERT_UNREACHABLE(); } + Containers::String doAnimationTrackTargetName(UnsignedShort name) override { + if(name == 333) + return "visibility"; + return {}; + } + struct { Float time[5]; Vector3 scaling[5]; diff --git a/src/Magnum/SceneTools/Test/SceneConverterImplementationTestFiles/info-animations.txt b/src/Magnum/SceneTools/Test/SceneConverterImplementationTestFiles/info-animations.txt index df71d5da7..4fa4b2603 100644 --- a/src/Magnum/SceneTools/Test/SceneConverterImplementationTestFiles/info-animations.txt +++ b/src/Magnum/SceneTools/Test/SceneConverterImplementationTestFiles/info-animations.txt @@ -4,6 +4,8 @@ Animation 0: Interpolation: Linear, DefaultConstructed, Constant Track 1: Rotation2D @ CubicHermite2D -> Vector2, 3 keyframes Interpolation: Constant, Extrapolated, Extrapolated + Track 2: Custom(333:visibility) @ Bool, 3 keyframes + Interpolation: Constant, Constant, Constant Animation 1: Custom track duration and interpolator function Duration: {0.1, 1.3} (0.1 kB, ExternallyOwned) Track 0: Scaling3D @ Vector3, 5 keyframes