summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2017-08-10 20:41:17 +0100
committerSean Harmer <sean.harmer@kdab.com>2017-08-16 13:19:28 +0000
commite11df19a6854c9fb4cb1138fa619d3030b9eea8b (patch)
treed233cd03611607ae825244fd96c3e4d8aa9452e4 /tests
parenta06c583bd21985d6b1da680fdb8dc6bebef18f9e (diff)
Create SkeletonData from Joint backend nodes
This can be done either by using a QSkeleton on the frontend or with a QSkeletonLoader that has the createJointsEnabled property set to true. In the latter case, the loader creates the joint node hierarchy on the backend then moves them to the main thread in a similar way to QGeometryRenderer handles Geoemtry. Once the joint hierarchy is set on the frontend QSkeletonLoader, it notifies the backend and from there it follows the same code path as for QSkeleton. Change-Id: I5f673e154bb3a3e677b80b8ee984f4168403c288 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/render/joint/tst_joint.cpp2
-rw-r--r--tests/auto/render/skeleton/tst_skeleton.cpp31
2 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/render/joint/tst_joint.cpp b/tests/auto/render/joint/tst_joint.cpp
index c7fc2409d..fb9ebc861 100644
--- a/tests/auto/render/joint/tst_joint.cpp
+++ b/tests/auto/render/joint/tst_joint.cpp
@@ -109,6 +109,7 @@ private Q_SLOTS:
QCOMPARE(backendJoint.scale(), QVector3D(1.0f, 1.0f, 1.0f));
QCOMPARE(backendJoint.inverseBindMatrix(), QMatrix4x4());
QCOMPARE(backendJoint.childJointIds(), QNodeIdVector());
+ QCOMPARE(backendJoint.owningSkeleton(), HSkeleton());
// GIVEN
QJoint joint;
@@ -137,6 +138,7 @@ private Q_SLOTS:
QCOMPARE(backendJoint.scale(), QVector3D(1.0f, 1.0f, 1.0f));
QCOMPARE(backendJoint.inverseBindMatrix(), QMatrix4x4());
QCOMPARE(backendJoint.childJointIds(), QNodeIdVector());
+ QCOMPARE(backendJoint.owningSkeleton(), HSkeleton());
}
void checkPropertyChanges()
diff --git a/tests/auto/render/skeleton/tst_skeleton.cpp b/tests/auto/render/skeleton/tst_skeleton.cpp
index 64359fc78..f9d5bb2f2 100644
--- a/tests/auto/render/skeleton/tst_skeleton.cpp
+++ b/tests/auto/render/skeleton/tst_skeleton.cpp
@@ -30,6 +30,7 @@
#include <Qt3DRender/private/skeleton_p.h>
#include <Qt3DRender/private/nodemanagers_p.h>
#include <Qt3DCore/qjoint.h>
+#include <Qt3DCore/qskeleton.h>
#include <Qt3DCore/qskeletonloader.h>
#include <Qt3DCore/private/qnode_p.h>
#include <Qt3DCore/private/qscene_p.h>
@@ -89,6 +90,24 @@ private Q_SLOTS:
QCOMPARE(backendSkeleton.peerId(), skeleton.id());
QCOMPARE(backendSkeleton.isEnabled(), skeleton.isEnabled());
QCOMPARE(backendSkeleton.source(), skeleton.source());
+ QCOMPARE(backendSkeleton.rootJointId(), QNodeId());
+
+ // GIVEN
+ Skeleton backendSkeleton2;
+ backendSkeleton2.setRenderer(&renderer);
+ QSkeleton skeleton2;
+
+ QJoint *joint = new QJoint();
+ skeleton2.setRootJoint(joint);
+
+ // WHEN
+ simulateInitialization(&skeleton2, &backendSkeleton2);
+
+ // THEN
+ QCOMPARE(backendSkeleton2.peerId(), skeleton2.id());
+ QCOMPARE(backendSkeleton2.isEnabled(), skeleton2.isEnabled());
+ QCOMPARE(backendSkeleton2.source(), QUrl());
+ QCOMPARE(backendSkeleton2.rootJointId(), joint->id());
}
void checkInitialAndCleanedUpState()
@@ -105,6 +124,7 @@ private Q_SLOTS:
QCOMPARE(backendSkeleton.isEnabled(), false);
QCOMPARE(backendSkeleton.source(), QUrl());
QCOMPARE(backendSkeleton.status(), QSkeletonLoader::NotReady);
+ QCOMPARE(backendSkeleton.rootJointId(), QNodeId());
// GIVEN
QSkeletonLoader skeleton;
@@ -118,6 +138,7 @@ private Q_SLOTS:
QCOMPARE(backendSkeleton.source(), QUrl());
QCOMPARE(backendSkeleton.isEnabled(), false);
QCOMPARE(backendSkeleton.status(), QSkeletonLoader::NotReady);
+ QCOMPARE(backendSkeleton.rootJointId(), QNodeId());
}
void checkPropertyChanges()
@@ -154,6 +175,16 @@ private Q_SLOTS:
// THEN
QCOMPARE(backendSkeleton.source(), newSource);
+
+ // WHEN
+ const QNodeId newRootJointId = QNodeId::createId();
+ updateChange.reset(new Qt3DCore::QPropertyUpdatedChange(Qt3DCore::QNodeId()));
+ updateChange->setPropertyName("rootJoint");
+ updateChange->setValue(QVariant::fromValue(newRootJointId));
+ backendSkeleton.sceneChangeEvent(updateChange);
+
+ // THEN
+ QCOMPARE(backendSkeleton.rootJointId(), newRootJointId);
}
void checkStatusPropertyBackendNotification()