diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2017-03-21 14:30:08 +0000 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2017-03-25 14:23:37 +0000 |
commit | 37fd551490035a2004e4151857b2f7fd35078b97 (patch) | |
tree | 1a094751701e57a38440a484ac64780f3ee20ad0 /tests/auto/animation/animationutils/tst_animationutils.cpp | |
parent | 6af77603f97cf4f4dc68b3f18e89e930d547afdc (diff) |
Add function to generate component indices for blend tree format
This generates the format indices required by the
formatClipResults() function which performs the gather to reorder
the raw results from an animation clip to the format used by
the blend tree/animator.
Change-Id: I5cd8fbe366792ae9d8317f098699c413450b9b87
Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'tests/auto/animation/animationutils/tst_animationutils.cpp')
-rw-r--r-- | tests/auto/animation/animationutils/tst_animationutils.cpp | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/tests/auto/animation/animationutils/tst_animationutils.cpp b/tests/auto/animation/animationutils/tst_animationutils.cpp index 0d758d3d3..e1f8adb0c 100644 --- a/tests/auto/animation/animationutils/tst_animationutils.cpp +++ b/tests/auto/animation/animationutils/tst_animationutils.cpp @@ -2145,6 +2145,152 @@ private Q_SLOTS: QCOMPARE(actualResult[j], expectedResult[j]); } } + + void checkGenerateClipFormatIndices_data() + { + QTest::addColumn<QVector<ChannelNameAndType>>("targetChannels"); + QTest::addColumn<QVector<ComponentIndices>>("targetIndices"); + QTest::addColumn<AnimationClipLoader *>("clip"); + QTest::addColumn<ComponentIndices>("expectedResults"); + + { + QVector<ChannelNameAndType> targetChannels; + targetChannels.push_back({ QLatin1String("Rotation"), static_cast<int>(QVariant::Quaternion) }); + targetChannels.push_back({ QLatin1String("Location"), static_cast<int>(QVariant::Vector3D) }); + targetChannels.push_back({ QLatin1String("Base Color"), static_cast<int>(QVariant::Vector3D) }); + targetChannels.push_back({ QLatin1String("Metalness"), static_cast<int>(QVariant::Double) }); + targetChannels.push_back({ QLatin1String("Roughness"), static_cast<int>(QVariant::Double) }); + + QVector<ComponentIndices> targetIndices; + targetIndices.push_back({ 0, 1, 2, 3 }); + targetIndices.push_back({ 4, 5, 6 }); + targetIndices.push_back({ 7, 8, 9 }); + targetIndices.push_back({ 10 }); + targetIndices.push_back({ 11 }); + + auto *clip = new AnimationClipLoader(); + clip->setSource(QUrl("qrc:/clip3.json")); + clip->loadAnimation(); + + ComponentIndices expectedResults = { 0, 1, 2, 3, // Rotation + 4, 5, 6, // Location + 7, 8, 9, // Base Color + 10, // Metalness + 11 }; // Roughness + + QTest::newRow("rotation, location, pbr metal-rough") + << targetChannels << targetIndices << clip << expectedResults; + } + + { + QVector<ChannelNameAndType> targetChannels; + targetChannels.push_back({ QLatin1String("Location"), static_cast<int>(QVariant::Vector3D) }); + targetChannels.push_back({ QLatin1String("Rotation"), static_cast<int>(QVariant::Quaternion) }); + targetChannels.push_back({ QLatin1String("Base Color"), static_cast<int>(QVariant::Vector3D) }); + targetChannels.push_back({ QLatin1String("Metalness"), static_cast<int>(QVariant::Double) }); + targetChannels.push_back({ QLatin1String("Roughness"), static_cast<int>(QVariant::Double) }); + + QVector<ComponentIndices> targetIndices; + targetIndices.push_back({ 0, 1, 2 }); + targetIndices.push_back({ 3, 4, 5, 6 }); + targetIndices.push_back({ 7, 8, 9 }); + targetIndices.push_back({ 10 }); + targetIndices.push_back({ 11 }); + + auto *clip = new AnimationClipLoader(); + clip->setSource(QUrl("qrc:/clip3.json")); + clip->loadAnimation(); + + ComponentIndices expectedResults = { 4, 5, 6, // Location + 0, 1, 2, 3, // Rotation + 7, 8, 9, // Base Color + 10, // Metalness + 11 }; // Roughness + + QTest::newRow("location, rotation, pbr metal-rough") + << targetChannels << targetIndices << clip << expectedResults; + } + + { + QVector<ChannelNameAndType> targetChannels; + targetChannels.push_back({ QLatin1String("Rotation"), static_cast<int>(QVariant::Quaternion) }); + targetChannels.push_back({ QLatin1String("Location"), static_cast<int>(QVariant::Vector3D) }); + targetChannels.push_back({ QLatin1String("Albedo"), static_cast<int>(QVariant::Vector3D) }); + targetChannels.push_back({ QLatin1String("Metalness"), static_cast<int>(QVariant::Double) }); + targetChannels.push_back({ QLatin1String("Roughness"), static_cast<int>(QVariant::Double) }); + + QVector<ComponentIndices> targetIndices; + targetIndices.push_back({ 0, 1, 2, 3 }); + targetIndices.push_back({ 4, 5, 6 }); + targetIndices.push_back({ 7, 8, 9 }); + targetIndices.push_back({ 10 }); + targetIndices.push_back({ 11 }); + + auto *clip = new AnimationClipLoader(); + clip->setSource(QUrl("qrc:/clip3.json")); + clip->loadAnimation(); + + ComponentIndices expectedResults = { 0, 1, 2, 3, // Rotation + 4, 5, 6, // Location + -1, -1, -1, // Albedo (missing from clip) + 10, // Metalness + 11 }; // Roughness + + QTest::newRow("rotation, location, albedo (missing), metal-rough") + << targetChannels << targetIndices << clip << expectedResults; + } + + { + QVector<ChannelNameAndType> targetChannels; + targetChannels.push_back({ QLatin1String("Location"), static_cast<int>(QVariant::Vector3D) }); + targetChannels.push_back({ QLatin1String("Rotation"), static_cast<int>(QVariant::Quaternion) }); + targetChannels.push_back({ QLatin1String("Albedo"), static_cast<int>(QVariant::Vector3D) }); + targetChannels.push_back({ QLatin1String("Metalness"), static_cast<int>(QVariant::Double) }); + targetChannels.push_back({ QLatin1String("Roughness"), static_cast<int>(QVariant::Double) }); + + QVector<ComponentIndices> targetIndices; + targetIndices.push_back({ 0, 1, 2 }); + targetIndices.push_back({ 3, 4, 5, 6 }); + targetIndices.push_back({ 7, 8, 9 }); + targetIndices.push_back({ 10 }); + targetIndices.push_back({ 11 }); + + auto *clip = new AnimationClipLoader(); + clip->setSource(QUrl("qrc:/clip3.json")); + clip->loadAnimation(); + + ComponentIndices expectedResults = { 4, 5, 6, // Location + 0, 1, 2, 3, // Rotation + -1, -1, -1, // Albedo (missing from clip) + 10, // Metalness + 11 }; // Roughness + + QTest::newRow("location, rotation, albedo (missing), metal-rough") + << targetChannels << targetIndices << clip << expectedResults; + } + } + + void checkGenerateClipFormatIndices() + { + // GIVEN + QFETCH(QVector<ChannelNameAndType>, targetChannels); + QFETCH(QVector<ComponentIndices>, targetIndices); + QFETCH(AnimationClipLoader *, clip); + QFETCH(ComponentIndices, expectedResults); + + // WHEN + const ComponentIndices actualResults = generateClipFormatIndices(targetChannels, + targetIndices, + clip); + + // THEN + QCOMPARE(actualResults.size(), expectedResults.size()); + for (int i = 0; i < actualResults.size(); ++i) + QCOMPARE(actualResults[i], expectedResults[i]); + + // Cleanup + delete clip; + } }; QTEST_MAIN(tst_AnimationUtils) |