summaryrefslogtreecommitdiffstats
path: root/src/animation
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2017-08-22 17:04:34 +0100
committerSean Harmer <sean.harmer@kdab.com>2017-08-30 12:59:23 +0000
commitd0f45d9819c556bb5e3ec5bfd848db630f26638e (patch)
tree4fecb165af9068da8e108beb466dda813ed0d8e0 /src/animation
parent9fc405b68e8dd60ed2cd957d85147017621b85f9 (diff)
Send joint names and local poses from render to animation aspect
This will allow the animation aspect to easily update the local poses of all joints in a skeleton without needing to be able to address any frontend QJoint objects. Change-Id: Id2137f2533702387dc68296aba1dd8627b0599d6 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/animation')
-rw-r--r--src/animation/backend/skeleton.cpp25
-rw-r--r--src/animation/backend/skeleton_p.h12
2 files changed, 34 insertions, 3 deletions
diff --git a/src/animation/backend/skeleton.cpp b/src/animation/backend/skeleton.cpp
index 4e1747dd9..a920e2473 100644
--- a/src/animation/backend/skeleton.cpp
+++ b/src/animation/backend/skeleton.cpp
@@ -35,9 +35,12 @@
****************************************************************************/
#include "skeleton_p.h"
+#include <Qt3DCore/qpropertyupdatedchange.h>
QT_BEGIN_NAMESPACE
+using namespace Qt3DCore;
+
namespace Qt3DAnimation {
namespace Animation {
@@ -69,8 +72,28 @@ void Skeleton::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &cha
void Skeleton::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
{
- // TODO: Get the joint names and initial local poses from a change sent
+ // Get the joint names and initial local poses from a change sent
// by the render aspect when the skeleton has been loaded.
+ switch (e->type()) {
+ case PropertyUpdated: {
+ const auto change = qSharedPointerCast<QPropertyUpdatedChange>(e);
+ if (change->propertyName() == QByteArrayLiteral("jointNamesAndLocalPoses")) {
+ const auto payload = change->value().value<JointNamesAndLocalPoses>();
+ m_jointNames = payload.names;
+ m_jointLocalPoses = payload.localPoses;
+
+ // TODO: Mark joint info as dirty so we can rebuild any indexes used
+ // by the animators and channel mappings.
+ }
+
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ BackendNode::sceneChangeEvent(e);
}
} // namespace Animation
diff --git a/src/animation/backend/skeleton_p.h b/src/animation/backend/skeleton_p.h
index b78e207b3..0674a28a1 100644
--- a/src/animation/backend/skeleton_p.h
+++ b/src/animation/backend/skeleton_p.h
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DAnimation {
namespace Animation {
-class Skeleton : public BackendNode
+class Q_AUTOTEST_EXPORT Skeleton : public BackendNode
{
public:
Skeleton();
@@ -64,11 +64,19 @@ public:
void cleanup();
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) Q_DECL_OVERRIDE;
+#if defined(QT_BUILD_INTERNAL)
+ void setJointNames(const QVector<QString> &names) { m_jointNames = names; }
+ QVector<QString> jointNames() const { return m_jointNames; }
+ void setJointLocalPoses(const QVector<Qt3DCore::Sqt> &localPoses) { m_jointLocalPoses = localPoses; }
+ QVector<Qt3DCore::Sqt> jointLocalPoses() const { return m_jointLocalPoses; }
+#endif
+
private:
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) Q_DECL_FINAL;
QVector<QString> m_jointNames;
- QVector<Qt3DCore::Sqt> m_jointLocalPoses; };
+ QVector<Qt3DCore::Sqt> m_jointLocalPoses;
+};
} // namespace Animation
} // namespace Qt3DAnimation