diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2017-10-08 10:54:50 +0100 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2018-01-19 09:41:59 +0000 |
commit | 1712de946ad9a9c9d70c29d9a388a33d6fe5d33d (patch) | |
tree | 3520c724b4d9428adee7962423aa7acf08c5f360 /tests | |
parent | 4b64822915cb6029b76e0c1b664ad52d948fff01 (diff) |
Add getters for joint transformations to Skeleton
Change-Id: I29e6dec8486f1e9efe709815615cb09ab5be5598
Reviewed-by: Christian Stromme <christian.stromme@qt.io>
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/animation/skeleton/tst_skeleton.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/auto/animation/skeleton/tst_skeleton.cpp b/tests/auto/animation/skeleton/tst_skeleton.cpp index 6b7fc12f1..9116be199 100644 --- a/tests/auto/animation/skeleton/tst_skeleton.cpp +++ b/tests/auto/animation/skeleton/tst_skeleton.cpp @@ -41,6 +41,8 @@ using namespace Qt3DCore; using namespace Qt3DAnimation; using namespace Qt3DAnimation::Animation; +Q_DECLARE_METATYPE(Skeleton*) + class tst_Skeleton : public QBackendNodeTester { Q_OBJECT @@ -157,6 +159,62 @@ private Q_SLOTS: QCOMPARE(backendSkeleton.jointNames(), names); QCOMPARE(backendSkeleton.jointLocalPoses(), localPoses); } + + void checkJointTransforms_data() + { + QTest::addColumn<Skeleton*>("skeleton"); + QTest::addColumn<QVector<Sqt>>("jointTransforms"); + + const int count = 5; + auto skeleton = new Skeleton; + skeleton->setJointCount(count); + QVector<Sqt> jointTransforms; + jointTransforms.reserve(count); + for (int i = 0; i < count; ++i) { + const float f = float(i); + Sqt transform; + transform.scale = QVector3D(f, f, f); + transform.rotation = QQuaternion(f, 1.0f, 0.0f, 0.0f).normalized(); + transform.translation = QVector3D(1.0 * f, 2.0 * f, 3.0 * f); + skeleton->setJointScale(i, transform.scale); + skeleton->setJointRotation(i, transform.rotation); + skeleton->setJointTranslation(i, transform.translation); + jointTransforms.push_back(transform); + } + + QTest::newRow("5 joints") << skeleton << jointTransforms; + } + + void checkJointTransforms() + { + // GIVEN + QFETCH(Skeleton*, skeleton); + QFETCH(QVector<Sqt>, jointTransforms); + + const int count = skeleton->jointCount(); + for (int i = 0; i < count; ++i) { + // WHEN + const QVector3D s = skeleton->jointScale(i); + + // THEN + QCOMPARE(s, jointTransforms[i].scale); + + // WHEN + const QQuaternion q = skeleton->jointRotation(i); + + // THEN + QCOMPARE(q, jointTransforms[i].rotation); + + // WHEN + const QVector3D t = skeleton->jointTranslation(i); + + // THEN + QCOMPARE(t, jointTransforms[i].translation); + } + + // Cleanup + delete skeleton; + } }; QTEST_APPLESS_MAIN(tst_Skeleton) |