summaryrefslogtreecommitdiffstats
path: root/src/animation/backend/blendedclipanimator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/animation/backend/blendedclipanimator.cpp')
-rw-r--r--src/animation/backend/blendedclipanimator.cpp64
1 files changed, 28 insertions, 36 deletions
diff --git a/src/animation/backend/blendedclipanimator.cpp b/src/animation/backend/blendedclipanimator.cpp
index fe8a5d815..254883478 100644
--- a/src/animation/backend/blendedclipanimator.cpp
+++ b/src/animation/backend/blendedclipanimator.cpp
@@ -36,6 +36,9 @@
#include "blendedclipanimator_p.h"
#include <Qt3DAnimation/qblendedclipanimator.h>
+#include <Qt3DAnimation/qchannelmapper.h>
+#include <Qt3DAnimation/qclock.h>
+#include <Qt3DAnimation/qabstractclipblendnode.h>
#include <Qt3DAnimation/private/qblendedclipanimator_p.h>
#include <Qt3DAnimation/private/qanimationcallbacktrigger_p.h>
#include <Qt3DCore/qpropertyupdatedchange.h>
@@ -57,19 +60,6 @@ BlendedClipAnimator::BlendedClipAnimator()
{
}
-void BlendedClipAnimator::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change)
-{
- const auto typedChange = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<QBlendedClipAnimatorData>>(change);
- const QBlendedClipAnimatorData &data = typedChange->data;
- m_blendTreeRootId = data.blendTreeRootId;
- m_mapperId = data.mapperId;
- m_clockId = data.clockId;
- m_running = data.running;
- m_loops = data.loops;
- m_normalizedLocalTime = data.normalizedTime;
- setDirty(Handler::BlendedClipAnimatorDirty);
-}
-
double BlendedClipAnimator::lastLocalTime() const
{
return m_lastLocalTime;
@@ -167,30 +157,32 @@ void BlendedClipAnimator::setNormalizedLocalTime(float normalizedTime)
setDirty(Handler::BlendedClipAnimatorDirty);
}
-void BlendedClipAnimator::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
-{
- switch (e->type()) {
- case Qt3DCore::PropertyUpdated: {
- const auto change = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(e);
- if (change->propertyName() == QByteArrayLiteral("blendTree"))
- setBlendTreeRootId(change->value().value<Qt3DCore::QNodeId>());
- else if (change->propertyName() == QByteArrayLiteral("channelMapper"))
- setMapperId(change->value().value<Qt3DCore::QNodeId>());
- else if (change->propertyName() == QByteArrayLiteral("clock"))
- setClockId(change->value().value<Qt3DCore::QNodeId>());
- else if (change->propertyName() == QByteArrayLiteral("running"))
- setRunning(change->value().toBool());
- else if (change->propertyName() == QByteArrayLiteral("loops"))
- m_loops = change->value().toInt();
- else if (change->propertyName() == QByteArrayLiteral("normalizedTime"))
- setNormalizedLocalTime(change->value().toFloat());
- break;
- }
+void BlendedClipAnimator::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime)
+{
+ BackendNode::syncFromFrontEnd(frontEnd, firstTime);
+ const QBlendedClipAnimator *node = qobject_cast<const QBlendedClipAnimator *>(frontEnd);
+ if (!node)
+ return;
- default:
- break;
- }
- BackendNode::sceneChangeEvent(e);
+ auto id = Qt3DCore::qIdForNode(node->blendTree());
+ if (id != m_blendTreeRootId)
+ setBlendTreeRootId(id);
+ id = Qt3DCore::qIdForNode(node->channelMapper());
+ if (m_mapperId != id)
+ setMapperId(id);
+ id = Qt3DCore::qIdForNode(node->clock());
+ if (m_clockId != id)
+ setClockId(id);
+
+ if (m_running != node->isRunning())
+ setRunning(node->isRunning());
+ if (m_loops != node->loopCount())
+ m_loops = node->loopCount();
+ if (!qFuzzyCompare(m_normalizedLocalTime, node->normalizedTime()))
+ setNormalizedLocalTime(node->normalizedTime());
+
+ if (firstTime)
+ setDirty(Handler::BlendedClipAnimatorDirty);
}
} // namespace Animation