summaryrefslogtreecommitdiffstats
path: root/src/animation
diff options
context:
space:
mode:
authorMike Krus <mike.krus@kdab.com>2019-09-20 07:32:08 +0100
committerMike Krus <mike.krus@kdab.com>2019-09-20 11:11:31 +0100
commit722425eccd099936a15b850698c5fc3047f162a2 (patch)
tree21406593fac2594c4bdfa936beaf73e3046d7138 /src/animation
parent6d65beef4118e896980ba881e270e5da50a1299a (diff)
Update QLerpClipBlend to use direct sync
Change-Id: I91ce052b27eb822e79b80fa11ccd3d4b9f76ded4 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/animation')
-rw-r--r--src/animation/backend/lerpclipblend.cpp34
-rw-r--r--src/animation/backend/lerpclipblend_p.h4
-rw-r--r--src/animation/frontend/qanimationaspect.cpp2
3 files changed, 13 insertions, 27 deletions
diff --git a/src/animation/backend/lerpclipblend.cpp b/src/animation/backend/lerpclipblend.cpp
index eef0072f9..b2ba2ff7e 100644
--- a/src/animation/backend/lerpclipblend.cpp
+++ b/src/animation/backend/lerpclipblend.cpp
@@ -35,9 +35,8 @@
****************************************************************************/
#include "lerpclipblend_p.h"
-#include <Qt3DAnimation/qclipblendnodecreatedchange.h>
+#include <Qt3DAnimation/qlerpclipblend.h>
#include <Qt3DAnimation/private/qlerpclipblend_p.h>
-#include <Qt3DCore/qpropertyupdatedchange.h>
QT_BEGIN_NAMESPACE
@@ -57,17 +56,16 @@ LerpClipBlend::~LerpClipBlend()
{
}
-void LerpClipBlend::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
+void LerpClipBlend::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime)
{
- if (e->type() == Qt3DCore::PropertyUpdated) {
- Qt3DCore::QPropertyUpdatedChangePtr change = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(e);
- if (change->propertyName() == QByteArrayLiteral("blendFactor"))
- m_blendFactor = change->value().toFloat();
- else if (change->propertyName() == QByteArrayLiteral("startClip"))
- m_startClipId = change->value().value<Qt3DCore::QNodeId>();
- else if (change->propertyName() == QByteArrayLiteral("endClip"))
- m_endClipId = change->value().value<Qt3DCore::QNodeId>();
- }
+ BackendNode::syncFromFrontEnd(frontEnd, firstTime);
+ const QLerpClipBlend *node = qobject_cast<const QLerpClipBlend *>(frontEnd);
+ if (!node)
+ return;
+
+ m_blendFactor = node->blendFactor();
+ m_startClipId = Qt3DCore::qIdForNode(node->startClip());
+ m_endClipId = Qt3DCore::qIdForNode(node->endClip());
}
ClipResults LerpClipBlend::doBlend(const QVector<ClipResults> &blendData) const
@@ -83,16 +81,6 @@ ClipResults LerpClipBlend::doBlend(const QVector<ClipResults> &blendData) const
return blendResults;
}
-void LerpClipBlend::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change)
-{
- ClipBlendNode::initializeFromPeer(change);
- const auto creationChangeData = qSharedPointerCast<Qt3DAnimation::QClipBlendNodeCreatedChange<Qt3DAnimation::QLerpClipBlendData>>(change);
- const Qt3DAnimation::QLerpClipBlendData cloneData = creationChangeData->data;
- m_startClipId = cloneData.startClipId;
- m_endClipId = cloneData.endClipId;
- m_blendFactor = cloneData.blendFactor;
-}
-
double LerpClipBlend::duration() const
{
ClipBlendNode *startNode = clipBlendNodeManager()->lookupNode(m_startClipId);
@@ -101,7 +89,7 @@ double LerpClipBlend::duration() const
ClipBlendNode *endNode = clipBlendNodeManager()->lookupNode(m_endClipId);
const double endNodeDuration = endNode ? endNode->duration() : 0.0;
- return (1.0f - m_blendFactor) * startNodeDuration + m_blendFactor * endNodeDuration;
+ return (1.0 - static_cast<double>(m_blendFactor)) * startNodeDuration + static_cast<double>(m_blendFactor) * endNodeDuration;
}
} // Animation
diff --git a/src/animation/backend/lerpclipblend_p.h b/src/animation/backend/lerpclipblend_p.h
index 6120f8afa..61434af2c 100644
--- a/src/animation/backend/lerpclipblend_p.h
+++ b/src/animation/backend/lerpclipblend_p.h
@@ -71,7 +71,7 @@ public:
inline Qt3DCore::QNodeId endClipId() const { return m_endClipId; }
void setEndClipId(Qt3DCore::QNodeId endClipId) { m_endClipId = endClipId; } // For unit tests
- void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) final;
+ void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) final;
inline QVector<Qt3DCore::QNodeId> allDependencyIds() const override
{
@@ -89,8 +89,6 @@ protected:
ClipResults doBlend(const QVector<ClipResults> &blendData) const final;
private:
- void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
-
Qt3DCore::QNodeId m_startClipId;
Qt3DCore::QNodeId m_endClipId;
float m_blendFactor;
diff --git a/src/animation/frontend/qanimationaspect.cpp b/src/animation/frontend/qanimationaspect.cpp
index 3b7946714..986ab3d22 100644
--- a/src/animation/frontend/qanimationaspect.cpp
+++ b/src/animation/frontend/qanimationaspect.cpp
@@ -122,7 +122,7 @@ 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<QLerpClipBlend>(
+ registerBackendType<QLerpClipBlend, true>(
QSharedPointer<Animation::ClipBlendNodeFunctor<Animation::LerpClipBlend, Animation::ClipAnimatorManager>>::create(d->m_handler.data(),
d->m_handler->clipBlendNodeManager()));
registerBackendType<QAdditiveClipBlend, true>(