diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2017-01-27 16:44:57 +0100 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2017-01-29 09:39:48 +0000 |
commit | a6e1ac3f584eb08cecfb154ac7d96dee6beaf44d (patch) | |
tree | f5d5c328d6c8de0899cf4be51375cebb7b813ed7 | |
parent | 98399b24b778af6c26c8c73736805083ce614df5 (diff) |
Register QLerpBlend node with Animation aspect
Change-Id: I7b8fade4aa8855030e882227df21882e55d8690f
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r-- | src/animation/backend/clipblendnode.cpp | 4 | ||||
-rw-r--r-- | src/animation/backend/clipblendnode_p.h | 41 | ||||
-rw-r--r-- | src/animation/backend/handler.cpp | 1 | ||||
-rw-r--r-- | src/animation/backend/handler_p.h | 3 | ||||
-rw-r--r-- | src/animation/frontend/qanimationaspect.cpp | 5 |
5 files changed, 50 insertions, 4 deletions
diff --git a/src/animation/backend/clipblendnode.cpp b/src/animation/backend/clipblendnode.cpp index cd2c1701f..a763f7f48 100644 --- a/src/animation/backend/clipblendnode.cpp +++ b/src/animation/backend/clipblendnode.cpp @@ -37,7 +37,6 @@ #include "clipblendnode_p.h" #include <Qt3DAnimation/qclipblendnodecreatedchange.h> #include <Qt3DAnimation/qanimationclip.h> -#include <Qt3DAnimation/private/managers_p.h> #include <Qt3DCore/qpropertynoderemovedchange.h> #include <Qt3DCore/qpropertynodeaddedchange.h> @@ -48,7 +47,8 @@ namespace Qt3DAnimation { namespace Animation { ClipBlendNode::ClipBlendNode(BlendType blendType) - : m_manager(nullptr) + : BackendNode(ReadOnly) // Makes sense for now at least + , m_manager(nullptr) , m_blendType(blendType) { } diff --git a/src/animation/backend/clipblendnode_p.h b/src/animation/backend/clipblendnode_p.h index e4756ee67..d3af9301b 100644 --- a/src/animation/backend/clipblendnode_p.h +++ b/src/animation/backend/clipblendnode_p.h @@ -49,7 +49,8 @@ // #include <Qt3DCore/qnodeid.h> -#include <Qt3DCore/qbackendnode.h> +#include <Qt3DAnimation/private/backendnode_p.h> +#include <Qt3DAnimation/private/managers_p.h> QT_BEGIN_NAMESPACE @@ -59,7 +60,7 @@ namespace Animation { class ClipBlendNodeManager; -class Q_AUTOTEST_EXPORT ClipBlendNode : public Qt3DCore::QBackendNode +class Q_AUTOTEST_EXPORT ClipBlendNode : public BackendNode { public: ~ClipBlendNode(); @@ -97,6 +98,42 @@ private: BlendType m_blendType; }; +template<typename Backend, typename Frontend> +class ClipBlendNodeFunctor : public Qt3DCore::QBackendNodeMapper +{ +public: + explicit ClipBlendNodeFunctor(Handler *handler, ClipBlendNodeManager *manager) + : m_handler(handler) + , m_manager(manager) + { + } + + Qt3DCore::QBackendNode *create(const Qt3DCore::QNodeCreatedChangeBasePtr &change) const Q_DECL_FINAL + { + if (m_manager->containsNode(change->subjectId())) + return static_cast<Backend *>(m_manager->lookupNode(change->subjectId())); + Backend *backend = new Backend(); + backend->setClipBlendNodeManager(m_manager); + backend->setHandler(m_handler); + m_manager->appendNode(change->subjectId(), backend); + return backend; + } + + Qt3DCore::QBackendNode *get(Qt3DCore::QNodeId id) const Q_DECL_FINAL + { + return m_manager->lookupNode(id); + } + + void destroy(Qt3DCore::QNodeId id) const Q_DECL_FINAL + { + m_manager->releaseNode(id); + } + +private: + Handler *m_handler; + ClipBlendNodeManager *m_manager; +}; + } // Animation } // Qt3DAnimation diff --git a/src/animation/backend/handler.cpp b/src/animation/backend/handler.cpp index c19e8c3e8..526a9c0ff 100644 --- a/src/animation/backend/handler.cpp +++ b/src/animation/backend/handler.cpp @@ -53,6 +53,7 @@ Handler::Handler() , m_conductedClipAnimatorManager(new ConductedClipAnimatorManager) , m_channelMappingManager(new ChannelMappingManager) , m_channelMapperManager(new ChannelMapperManager) + , m_clipBlendNodeManager(new ClipBlendNodeManager) , m_loadAnimationClipJob(new LoadAnimationClipJob) , m_findRunningClipAnimatorsJob(new FindRunningClipAnimatorsJob) , m_simulationTime(0) diff --git a/src/animation/backend/handler_p.h b/src/animation/backend/handler_p.h index 4729f1889..a2f5daa8f 100644 --- a/src/animation/backend/handler_p.h +++ b/src/animation/backend/handler_p.h @@ -75,6 +75,7 @@ class ChannelMapping; class ChannelMappingManager; class ChannelMapper; class ChannelMapperManager; +class ClipBlendNodeManager; class FindRunningClipAnimatorsJob; class LoadAnimationClipJob; @@ -105,6 +106,7 @@ public: ConductedClipAnimatorManager *conductedClipAnimatorManager() const Q_DECL_NOTHROW { return m_conductedClipAnimatorManager.data(); } ChannelMappingManager *channelMappingManager() const Q_DECL_NOTHROW { return m_channelMappingManager.data(); } ChannelMapperManager *channelMapperManager() const Q_DECL_NOTHROW { return m_channelMapperManager.data(); } + ClipBlendNodeManager *clipBlendNodeManager() const Q_DECL_NOTHROW { return m_clipBlendNodeManager.data(); } QVector<Qt3DCore::QAspectJobPtr> jobsToExecute(qint64 time); @@ -115,6 +117,7 @@ private: QScopedPointer<ConductedClipAnimatorManager> m_conductedClipAnimatorManager; QScopedPointer<ChannelMappingManager> m_channelMappingManager; QScopedPointer<ChannelMapperManager> m_channelMapperManager; + QScopedPointer<ClipBlendNodeManager> m_clipBlendNodeManager; QVector<HAnimationClip> m_dirtyAnimationClips; QVector<HChannelMapper> m_dirtyChannelMappers; diff --git a/src/animation/frontend/qanimationaspect.cpp b/src/animation/frontend/qanimationaspect.cpp index 64e3f6449..3310a8b77 100644 --- a/src/animation/frontend/qanimationaspect.cpp +++ b/src/animation/frontend/qanimationaspect.cpp @@ -45,9 +45,11 @@ #include <Qt3DAnimation/qconductedclipanimator.h> #include <Qt3DAnimation/qchannelmapping.h> #include <Qt3DAnimation/qchannelmapper.h> +#include <Qt3DAnimation/qlerpblend.h> #include <Qt3DAnimation/private/handler_p.h> #include <Qt3DAnimation/private/managers_p.h> #include <Qt3DAnimation/private/nodefunctor_p.h> +#include <Qt3DAnimation/private/lerpblend_p.h> QT_BEGIN_NAMESPACE @@ -106,6 +108,9 @@ QAnimationAspect::QAnimationAspect(QAnimationAspectPrivate &dd, QObject *parent) registerBackendType<QChannelMapper>( QSharedPointer<Animation::NodeFunctor<Animation::ChannelMapper, Animation::ChannelMapperManager>>::create(d->m_handler.data(), d->m_handler->channelMapperManager())); + registerBackendType<QLerpBlend>( + QSharedPointer<Animation::ClipBlendNodeFunctor<Animation::LerpBlend, Animation::ClipAnimatorManager>>::create(d->m_handler.data(), + d->m_handler->clipBlendNodeManager())); } /*! \internal */ |