From 22c66fa9f7a460f077fede22f285c84276ce3883 Mon Sep 17 00:00:00 2001 From: Juan Jose Casafranca Date: Sat, 9 Feb 2019 18:12:00 +0100 Subject: Use slerp for animating rotation channels Change-Id: Ic6aa6fd1c1a1e7757dba9466b59d20834b56e246 Reviewed-by: Paul Lemire --- .../animation/animationutils/animationutils.qrc | 1 + tests/auto/animation/animationutils/clip2.json | 4 +- tests/auto/animation/animationutils/clip6.json | 82 ++++++++++++++++++++++ .../animationutils/tst_animationutils.cpp | 11 +++ 4 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 tests/auto/animation/animationutils/clip6.json (limited to 'tests') diff --git a/tests/auto/animation/animationutils/animationutils.qrc b/tests/auto/animation/animationutils/animationutils.qrc index 0b499ed76..af041e8a3 100644 --- a/tests/auto/animation/animationutils/animationutils.qrc +++ b/tests/auto/animation/animationutils/animationutils.qrc @@ -5,5 +5,6 @@ clip3.json clip4.json clip5.json + clip6.json diff --git a/tests/auto/animation/animationutils/clip2.json b/tests/auto/animation/animationutils/clip2.json index 3faff409c..4c70f8493 100644 --- a/tests/auto/animation/animationutils/clip2.json +++ b/tests/auto/animation/animationutils/clip2.json @@ -242,9 +242,9 @@ ] } ], - "channelName": "Rotation" + "channelName": "rotation" } ] } ] -} \ No newline at end of file +} diff --git a/tests/auto/animation/animationutils/clip6.json b/tests/auto/animation/animationutils/clip6.json new file mode 100644 index 000000000..ba521df55 --- /dev/null +++ b/tests/auto/animation/animationutils/clip6.json @@ -0,0 +1,82 @@ +{ + "animations": [ + { + "animationName": "Rotation", + "channels": [ + { + "channelComponents": [ + { + "channelComponentName": "W", + "keyFrames": [ + { + "coords": [ + 0.0, + 1.0 + ] + }, + { + "coords": [ + 10.0, + 0.707 + ] + } + ] + }, + { + "channelComponentName": "X", + "keyFrames": [ + { + "coords": [ + 0.0, + 0.0 + ] + }, + { + "coords": [ + 10.0, + 0.707 + ] + } + ] + }, + { + "channelComponentName": "Y", + "keyFrames": [ + { + "coords": [ + 0.0, + 0.0 + ] + }, + { + "coords": [ + 10.0, + 0.0 + ] + } + ] + }, + { + "channelComponentName": "Z", + "keyFrames": [ + { + "coords": [ + 0.0, + 0.0 + ] + }, + { + "coords": [ + 10.0, + 0.0 + ] + } + ] + } + ], + "channelName": "Rotation" + } + ] + } + ] +} diff --git a/tests/auto/animation/animationutils/tst_animationutils.cpp b/tests/auto/animation/animationutils/tst_animationutils.cpp index 75ae65ea7..ee393b366 100644 --- a/tests/auto/animation/animationutils/tst_animationutils.cpp +++ b/tests/auto/animation/animationutils/tst_animationutils.cpp @@ -1248,6 +1248,17 @@ private Q_SLOTS: << handler << clip << localTime << expectedResults; expectedResults.clear(); } + { + // a clip with slerp interpolation + handler = new Handler(); + clip = createAnimationClipLoader(handler, QUrl("qrc:/clip6.json")); + localTime = clip->duration() / 2.0f; + expectedResults = QVector() << 0.923822f << 0.382626f << 0.0f << 0.0f; + + QTest::newRow("clip6.json, slerp, t = duration/2") + << handler << clip << localTime << expectedResults; + expectedResults.clear(); + } } void checkEvaluateClipAtLocalTime() -- cgit v1.2.3