summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2017-03-20 15:13:49 +0000
committerSean Harmer <sean.harmer@kdab.com>2017-03-25 14:23:32 +0000
commit6af77603f97cf4f4dc68b3f18e89e930d547afdc (patch)
tree5f40ccb484308a6563b28e559522d4d36e930c9c /tests
parent1929b3e48c0a327e7a741275d6d4847b72ddf704 (diff)
Add function assignChannelComponentIndices
This iterates through the channel description and assigns channel component indices in ascending order. The next step will be to use this in conjunction with the channel description with the layout of channels in each clip to generate the format indices that will allow us to quickly map from the clip's raw ClipResults to ClipResults formatted in the layotu used by the blend tree/animator. Change-Id: I04dd5a21ca8355529118cfb2b05f4904e43ef0e2 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/animation/animationutils/tst_animationutils.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/auto/animation/animationutils/tst_animationutils.cpp b/tests/auto/animation/animationutils/tst_animationutils.cpp
index a96f7d2d2..0d758d3d3 100644
--- a/tests/auto/animation/animationutils/tst_animationutils.cpp
+++ b/tests/auto/animation/animationutils/tst_animationutils.cpp
@@ -2079,6 +2079,72 @@ private Q_SLOTS:
// Cleanup
delete handler;
}
+
+ void checkAssignChannelComponentIndices_data()
+ {
+ QTest::addColumn<QVector<ChannelNameAndType>>("allChannels");
+ QTest::addColumn<QVector<ComponentIndices>>("expectedResults");
+
+ {
+ QVector<ChannelNameAndType> allChannels;
+ allChannels.push_back({ QLatin1String("Location"), static_cast<int>(QVariant::Vector3D) });
+
+ QVector<ComponentIndices> expectedResults;
+ expectedResults.push_back({ 0, 1, 2 });
+
+ QTest::newRow("vec3 location") << allChannels << expectedResults;
+ }
+
+ {
+ QVector<ChannelNameAndType> allChannels;
+ allChannels.push_back({ QLatin1String("Location"), static_cast<int>(QVariant::Vector3D) });
+ allChannels.push_back({ QLatin1String("Rotation"), static_cast<int>(QVariant::Quaternion) });
+
+ QVector<ComponentIndices> expectedResults;
+ expectedResults.push_back({ 0, 1, 2 });
+ expectedResults.push_back({ 3, 4, 5, 6 });
+
+ QTest::newRow("vec3 location, quaterion rotation") << allChannels << expectedResults;
+ }
+
+ {
+ QVector<ChannelNameAndType> allChannels;
+ allChannels.push_back({ QLatin1String("Location"), static_cast<int>(QVariant::Vector3D) });
+ allChannels.push_back({ QLatin1String("Rotation"), static_cast<int>(QVariant::Quaternion) });
+ allChannels.push_back({ QLatin1String("BaseColor"), static_cast<int>(QVariant::Vector3D) });
+ allChannels.push_back({ QLatin1String("Metalness"), static_cast<int>(QVariant::Double) });
+ allChannels.push_back({ QLatin1String("Roughness"), static_cast<int>(QVariant::Double) });
+
+ QVector<ComponentIndices> expectedResults;
+ expectedResults.push_back({ 0, 1, 2 });
+ expectedResults.push_back({ 3, 4, 5, 6 });
+ expectedResults.push_back({ 7, 8, 9 });
+ expectedResults.push_back({ 10 });
+ expectedResults.push_back({ 11 });
+
+ QTest::newRow("vec3 location, quaterion rotation, pbr metal-rough") << allChannels << expectedResults;
+ }
+ }
+
+ void checkAssignChannelComponentIndices()
+ {
+ // GIVEN
+ QFETCH(QVector<ChannelNameAndType>, allChannels);
+ QFETCH(QVector<ComponentIndices>, expectedResults);
+
+ // WHEN
+ const QVector<ComponentIndices> actualResults = assignChannelComponentIndices(allChannels);
+
+ // THEN
+ QCOMPARE(actualResults.size(), expectedResults.size());
+ for (int i = 0; i < actualResults.size(); ++i) {
+ const ComponentIndices &actualResult = actualResults[i];
+ const ComponentIndices &expectedResult = expectedResults[i];
+
+ for (int j = 0; j < actualResult.size(); ++j)
+ QCOMPARE(actualResult[j], expectedResult[j]);
+ }
+ }
};
QTEST_MAIN(tst_AnimationUtils)