summaryrefslogtreecommitdiffstats
path: root/src/animation/backend
diff options
context:
space:
mode:
Diffstat (limited to 'src/animation/backend')
-rw-r--r--src/animation/backend/additiveclipblend.cpp31
-rw-r--r--src/animation/backend/additiveclipblend_p.h4
-rw-r--r--src/animation/backend/animationclip.cpp61
-rw-r--r--src/animation/backend/animationclip_p.h3
-rw-r--r--src/animation/backend/animationutils.cpp3
-rw-r--r--src/animation/backend/backendnode.cpp9
-rw-r--r--src/animation/backend/backendnode_p.h2
-rw-r--r--src/animation/backend/blendedclipanimator.cpp64
-rw-r--r--src/animation/backend/blendedclipanimator_p.h3
-rw-r--r--src/animation/backend/channelmapper.cpp47
-rw-r--r--src/animation/backend/channelmapper_p.h3
-rw-r--r--src/animation/backend/channelmapping.cpp96
-rw-r--r--src/animation/backend/channelmapping_p.h4
-rw-r--r--src/animation/backend/clipanimator.cpp61
-rw-r--r--src/animation/backend/clipanimator_p.h4
-rw-r--r--src/animation/backend/clipblendvalue.cpp20
-rw-r--r--src/animation/backend/clipblendvalue_p.h4
-rw-r--r--src/animation/backend/clock.cpp26
-rw-r--r--src/animation/backend/clock_p.h4
-rw-r--r--src/animation/backend/lerpclipblend.cpp34
-rw-r--r--src/animation/backend/lerpclipblend_p.h4
-rw-r--r--src/animation/backend/skeleton.cpp9
-rw-r--r--src/animation/backend/skeleton_p.h2
23 files changed, 183 insertions, 315 deletions
diff --git a/src/animation/backend/additiveclipblend.cpp b/src/animation/backend/additiveclipblend.cpp
index ac8b849e2..b89a1bbb2 100644
--- a/src/animation/backend/additiveclipblend.cpp
+++ b/src/animation/backend/additiveclipblend.cpp
@@ -35,10 +35,8 @@
****************************************************************************/
#include "additiveclipblend_p.h"
-#include <Qt3DAnimation/qclipblendnodecreatedchange.h>
#include <Qt3DAnimation/qadditiveclipblend.h>
#include <Qt3DAnimation/private/qadditiveclipblend_p.h>
-#include <Qt3DCore/qpropertyupdatedchange.h>
QT_BEGIN_NAMESPACE
@@ -58,17 +56,16 @@ AdditiveClipBlend::~AdditiveClipBlend()
{
}
-void AdditiveClipBlend::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
+void AdditiveClipBlend::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime)
{
- if (e->type() == Qt3DCore::PropertyUpdated) {
- Qt3DCore::QPropertyUpdatedChangePtr change = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(e);
- if (change->propertyName() == QByteArrayLiteral("additiveFactor"))
- m_additiveFactor = change->value().toFloat();
- else if (change->propertyName() == QByteArrayLiteral("baseClip"))
- m_baseClipId = change->value().value<Qt3DCore::QNodeId>();
- else if (change->propertyName() == QByteArrayLiteral("additiveClip"))
- m_additiveClipId = change->value().value<Qt3DCore::QNodeId>();
- }
+ BackendNode::syncFromFrontEnd(frontEnd, firstTime);
+ const QAdditiveClipBlend *node = qobject_cast<const QAdditiveClipBlend *>(frontEnd);
+ if (!node)
+ return;
+
+ m_additiveFactor = node->additiveFactor();
+ m_baseClipId = Qt3DCore::qIdForNode(node->baseClip());
+ m_additiveClipId = Qt3DCore::qIdForNode(node->additiveClip());
}
ClipResults AdditiveClipBlend::doBlend(const QVector<ClipResults> &blendData) const
@@ -84,16 +81,6 @@ ClipResults AdditiveClipBlend::doBlend(const QVector<ClipResults> &blendData) co
return blendResults;
}
-void AdditiveClipBlend::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change)
-{
- ClipBlendNode::initializeFromPeer(change);
- const auto creationChangeData = qSharedPointerCast<Qt3DAnimation::QClipBlendNodeCreatedChange<Qt3DAnimation::QAdditiveClipBlendData>>(change);
- const Qt3DAnimation::QAdditiveClipBlendData cloneData = creationChangeData->data;
- m_baseClipId = cloneData.baseClipId;
- m_additiveClipId = cloneData.additiveClipId;
- m_additiveFactor = cloneData.additiveFactor;
-}
-
} // Animation
} // Qt3DAnimation
diff --git a/src/animation/backend/additiveclipblend_p.h b/src/animation/backend/additiveclipblend_p.h
index 0cf74ad56..48e882303 100644
--- a/src/animation/backend/additiveclipblend_p.h
+++ b/src/animation/backend/additiveclipblend_p.h
@@ -71,7 +71,7 @@ public:
inline float additiveFactor() const { return m_additiveFactor; }
void setAdditiveFactor(float additiveFactor) { m_additiveFactor = additiveFactor; } // 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
{
@@ -94,8 +94,6 @@ protected:
ClipResults doBlend(const QVector<ClipResults> &blendData) const final;
private:
- void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
-
Qt3DCore::QNodeId m_baseClipId;
Qt3DCore::QNodeId m_additiveClipId;
float m_additiveFactor;
diff --git a/src/animation/backend/animationclip.cpp b/src/animation/backend/animationclip.cpp
index 3e0b8ce2b..690972075 100644
--- a/src/animation/backend/animationclip.cpp
+++ b/src/animation/backend/animationclip.cpp
@@ -72,29 +72,6 @@ AnimationClip::AnimationClip()
{
}
-void AnimationClip::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change)
-{
- const auto loaderTypedChange = qSharedPointerDynamicCast<Qt3DCore::QNodeCreatedChange<QAnimationClipLoaderData>>(change);
- if (loaderTypedChange) {
- const auto &data = loaderTypedChange->data;
- m_dataType = File;
- m_source = data.source;
- if (!m_source.isEmpty())
- setDirty(Handler::AnimationClipDirty);
- return;
- }
-
- const auto clipTypedChange = qSharedPointerDynamicCast<Qt3DCore::QNodeCreatedChange<QAnimationClipChangeData>>(change);
- if (clipTypedChange) {
- const auto &data = clipTypedChange->data;
- m_dataType = Data;
- m_clipData = data.clipData;
- if (m_clipData.isValid())
- setDirty(Handler::AnimationClipDirty);
- return;
- }
-}
-
void AnimationClip::cleanup()
{
setEnabled(false);
@@ -121,28 +98,36 @@ void AnimationClip::setStatus(QAnimationClipLoader::Status status)
}
}
-void AnimationClip::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
+void AnimationClip::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime)
{
- switch (e->type()) {
- case Qt3DCore::PropertyUpdated: {
- const auto change = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(e);
- if (change->propertyName() == QByteArrayLiteral("source")) {
- Q_ASSERT(m_dataType == File);
- m_source = change->value().toUrl();
- setDirty(Handler::AnimationClipDirty);
- } else if (change->propertyName() == QByteArrayLiteral("clipData")) {
- Q_ASSERT(m_dataType == Data);
- m_clipData = change->value().value<Qt3DAnimation::QAnimationClipData>();
+ BackendNode::syncFromFrontEnd(frontEnd, firstTime);
+ const QAbstractAnimationClip *node = qobject_cast<const QAbstractAnimationClip *>(frontEnd);
+ if (!node)
+ return;
+
+ const QAnimationClip *clipNode = qobject_cast<const QAnimationClip *>(frontEnd);
+ if (clipNode) {
+ if (firstTime)
+ m_dataType = Data;
+ Q_ASSERT(m_dataType == Data);
+ if (m_clipData != clipNode->clipData()) {
+ m_clipData = clipNode->clipData();
if (m_clipData.isValid())
setDirty(Handler::AnimationClipDirty);
}
- break;
}
- default:
- break;
+ const QAnimationClipLoader *loaderNode = qobject_cast<const QAnimationClipLoader *>(frontEnd);
+ if (loaderNode) {
+ if (firstTime)
+ m_dataType = File;
+ Q_ASSERT(m_dataType == File);
+ if (m_source != loaderNode->source()) {
+ m_source = loaderNode->source();
+ if (m_clipData.isValid())
+ setDirty(Handler::AnimationClipDirty);
+ }
}
- QBackendNode::sceneChangeEvent(e);
}
/*!
diff --git a/src/animation/backend/animationclip_p.h b/src/animation/backend/animationclip_p.h
index 0b8298723..22f589f72 100644
--- a/src/animation/backend/animationclip_p.h
+++ b/src/animation/backend/animationclip_p.h
@@ -72,7 +72,7 @@ public:
QUrl source() const { return m_source; }
void setStatus(QAnimationClipLoader::Status status);
QAnimationClipLoader::Status status() const { return m_status; }
- void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
+ void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override;
void addDependingClipAnimator(const Qt3DCore::QNodeId &id);
void addDependingBlendedClipAnimator(const Qt3DCore::QNodeId &id);
@@ -103,7 +103,6 @@ public:
#endif
private:
- void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
void loadAnimationFromUrl();
void loadAnimationFromData();
void clearData();
diff --git a/src/animation/backend/animationutils.cpp b/src/animation/backend/animationutils.cpp
index 92e614236..24c484dc2 100644
--- a/src/animation/backend/animationutils.cpp
+++ b/src/animation/backend/animationutils.cpp
@@ -453,6 +453,7 @@ QVector<Qt3DCore::QSceneChangePtr> preparePropertyChanges(Qt3DCore::QNodeId anim
break;
}
} else {
+ // TODOSYNC remove once we've found a way to propagate animation changes
// Construct a property update change, set target, property and delivery options
auto e = Qt3DCore::QPropertyUpdatedChangePtr::create(mappingData.targetId);
e->setDeliveryFlags(Qt3DCore::QSceneChange::DeliverToAll);
@@ -469,6 +470,7 @@ QVector<Qt3DCore::QSceneChangePtr> preparePropertyChanges(Qt3DCore::QNodeId anim
skeleton->sendLocalPoses();
if (isValidNormalizedTime(normalizedLocalTime)) {
+ // TODOSYNC remove once we've found a way to propagate animation changes
auto e = Qt3DCore::QPropertyUpdatedChangePtr::create(animatorId);
e->setDeliveryFlags(Qt3DCore::QSceneChange::DeliverToAll);
e->setPropertyName("normalizedTime");
@@ -479,6 +481,7 @@ QVector<Qt3DCore::QSceneChangePtr> preparePropertyChanges(Qt3DCore::QNodeId anim
// If it's the final frame, notify the frontend that we've stopped
if (finalFrame) {
+ // TODOSYNC remove once we've found a way to propagate animation changes
auto e = Qt3DCore::QPropertyUpdatedChangePtr::create(animatorId);
e->setDeliveryFlags(Qt3DCore::QSceneChange::DeliverToAll);
e->setPropertyName("running");
diff --git a/src/animation/backend/backendnode.cpp b/src/animation/backend/backendnode.cpp
index 6ea7f89c7..f44836a67 100644
--- a/src/animation/backend/backendnode.cpp
+++ b/src/animation/backend/backendnode.cpp
@@ -38,6 +38,8 @@
****************************************************************************/
#include "backendnode_p.h"
+#include <Qt3DCore/qnode.h>
+#include <Qt3DCore/private/qbackendnode_p.h>
QT_BEGIN_NAMESPACE
@@ -65,6 +67,13 @@ void BackendNode::setDirty(Handler::DirtyFlag flag)
m_handler->setDirty(flag, peerId());
}
+void BackendNode::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime)
+{
+ Q_UNUSED(firstTime)
+
+ d_ptr->setEnabled(frontEnd->isEnabled());
+}
+
} // namespace Animation
} // namespace Qt3DAnimation
diff --git a/src/animation/backend/backendnode_p.h b/src/animation/backend/backendnode_p.h
index d7842517a..4e450b6ec 100644
--- a/src/animation/backend/backendnode_p.h
+++ b/src/animation/backend/backendnode_p.h
@@ -68,6 +68,8 @@ public:
void setHandler(Handler *handler);
+ virtual void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime);
+
protected:
void setDirty(Handler::DirtyFlag flag);
Handler *m_handler;
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
diff --git a/src/animation/backend/blendedclipanimator_p.h b/src/animation/backend/blendedclipanimator_p.h
index 09a071c06..f47b55796 100644
--- a/src/animation/backend/blendedclipanimator_p.h
+++ b/src/animation/backend/blendedclipanimator_p.h
@@ -64,7 +64,7 @@ public:
BlendedClipAnimator();
void cleanup();
- void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
+ void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override;
Qt3DCore::QNodeId blendTreeRootId() const;
Qt3DCore::QNodeId mapperId() const { return m_mapperId; }
@@ -112,7 +112,6 @@ public:
}
private:
- void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
Qt3DCore::QNodeId m_blendTreeRootId;
Qt3DCore::QNodeId m_mapperId;
Qt3DCore::QNodeId m_clockId;
diff --git a/src/animation/backend/channelmapper.cpp b/src/animation/backend/channelmapper.cpp
index 48a1335fa..7ea07557b 100644
--- a/src/animation/backend/channelmapper.cpp
+++ b/src/animation/backend/channelmapper.cpp
@@ -36,6 +36,7 @@
#include "channelmapper_p.h"
#include <Qt3DAnimation/qchannelmapper.h>
+#include <Qt3DAnimation/qchannelmapping.h>
#include <Qt3DAnimation/private/qchannelmapper_p.h>
#include <Qt3DAnimation/private/animationlogging_p.h>
#include <Qt3DAnimation/private/managers_p.h>
@@ -43,6 +44,8 @@
#include <Qt3DCore/qpropertynodeaddedchange.h>
#include <Qt3DCore/qpropertynoderemovedchange.h>
+#include <algorithm>
+
QT_BEGIN_NAMESPACE
namespace Qt3DAnimation {
@@ -55,14 +58,6 @@ ChannelMapper::ChannelMapper()
{
}
-void ChannelMapper::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change)
-{
- const auto typedChange = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<QChannelMapperData>>(change);
- const auto &data = typedChange->data;
- m_mappingIds = data.mappingIds;
- m_isDirty = true;
-}
-
void ChannelMapper::cleanup()
{
setEnabled(false);
@@ -71,33 +66,21 @@ void ChannelMapper::cleanup()
m_isDirty = true;
}
-void ChannelMapper::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
+void ChannelMapper::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime)
{
- switch (e->type()) {
- case Qt3DCore::PropertyValueAdded: {
- const auto change = qSharedPointerCast<Qt3DCore::QPropertyNodeAddedChange>(e);
- if (change->propertyName() == QByteArrayLiteral("mappings")) {
- m_mappingIds.push_back(change->addedNodeId());
- setDirty(Handler::ChannelMappingsDirty);
- m_isDirty = true;
- }
- break;
- }
-
- case Qt3DCore::PropertyValueRemoved: {
- const auto change = qSharedPointerCast<Qt3DCore::QPropertyNodeRemovedChange>(e);
- if (change->propertyName() == QByteArrayLiteral("mappings")) {
- m_mappingIds.removeOne(change->removedNodeId());
- setDirty(Handler::ChannelMappingsDirty);
- m_isDirty = true;
- }
- break;
- }
+ BackendNode::syncFromFrontEnd(frontEnd, firstTime);
+ const QChannelMapper *node = qobject_cast<const QChannelMapper *>(frontEnd);
+ if (!node)
+ return;
- default:
- break;
+ auto ids = Qt3DCore::qIdsForNodes(node->mappings());
+ std::sort(std::begin(ids), std::end(ids));
+ m_isDirty = firstTime;
+ if (m_mappingIds != ids) {
+ m_mappingIds = ids;
+ setDirty(Handler::ChannelMappingsDirty);
+ m_isDirty = true;
}
- QBackendNode::sceneChangeEvent(e);
}
void ChannelMapper::updateMappings() const
diff --git a/src/animation/backend/channelmapper_p.h b/src/animation/backend/channelmapper_p.h
index fd99c8dbd..45a3e789e 100644
--- a/src/animation/backend/channelmapper_p.h
+++ b/src/animation/backend/channelmapper_p.h
@@ -69,7 +69,7 @@ public:
void cleanup();
- void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
+ void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override;
void setMappingIds(const QVector<Qt3DCore::QNodeId> &mappingIds) { m_mappingIds = mappingIds; }
QVector<Qt3DCore::QNodeId> mappingIds() const { return m_mappingIds; }
@@ -82,7 +82,6 @@ public:
}
private:
- void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
void updateMappings() const;
QVector<Qt3DCore::QNodeId> m_mappingIds;
diff --git a/src/animation/backend/channelmapping.cpp b/src/animation/backend/channelmapping.cpp
index 2323182c6..83e7322da 100644
--- a/src/animation/backend/channelmapping.cpp
+++ b/src/animation/backend/channelmapping.cpp
@@ -36,13 +36,15 @@
#include "channelmapping_p.h"
#include <Qt3DAnimation/qchannelmapping.h>
+#include <Qt3DAnimation/qskeletonmapping.h>
+#include <Qt3DAnimation/qcallbackmapping.h>
#include <Qt3DAnimation/private/qcallbackmapping_p.h>
#include <Qt3DAnimation/private/qchannelmapping_p.h>
#include <Qt3DAnimation/private/qskeletonmapping_p.h>
#include <Qt3DAnimation/private/animationlogging_p.h>
#include <Qt3DAnimation/private/qchannelmappingcreatedchange_p.h>
#include <Qt3DAnimation/private/managers_p.h>
-#include <Qt3DCore/qpropertyupdatedchange.h>
+#include <Qt3DCore/qabstractskeleton.h>
QT_BEGIN_NAMESPACE
@@ -63,43 +65,6 @@ ChannelMapping::ChannelMapping()
{
}
-void ChannelMapping::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change)
-{
- const auto createdChange = qSharedPointerCast<QChannelMappingCreatedChangeBase>(change);
- switch (createdChange->type()) {
- case QChannelMappingCreatedChangeBase::ChannelMapping: {
- const auto typedChange = qSharedPointerCast<QChannelMappingCreatedChange<QChannelMappingData>>(change);
- const auto &data = typedChange->data;
- m_channelName = data.channelName;
- m_targetId = data.targetId;
- m_type = data.type;
- m_componentCount = data.componentCount;
- m_propertyName = data.propertyName;
- m_mappingType = ChannelMappingType;
- break;
- }
-
- case QChannelMappingCreatedChangeBase::SkeletonMapping: {
- const auto typedChange = qSharedPointerCast<QChannelMappingCreatedChange<QSkeletonMappingData>>(change);
- const auto &data = typedChange->data;
- m_skeletonId = data.skeletonId;
- m_mappingType = SkeletonMappingType;
- break;
- }
-
- case QChannelMappingCreatedChangeBase::CallbackMapping: {
- const auto typedChange = qSharedPointerCast<QChannelMappingCreatedChange<QCallbackMappingData>>(change);
- const auto &data = typedChange->data;
- m_channelName = data.channelName;
- m_type = data.type;
- m_callback = data.callback;
- m_callbackFlags = data.callbackFlags;
- m_mappingType = ChannelMappingType;
- break;
- }
- }
-}
-
void ChannelMapping::cleanup()
{
setEnabled(false);
@@ -113,34 +78,41 @@ void ChannelMapping::cleanup()
m_skeletonId = Qt3DCore::QNodeId();
}
-void ChannelMapping::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
+void ChannelMapping::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime)
{
- switch (e->type()) {
- case Qt3DCore::PropertyUpdated: {
- const auto change = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(e);
- if (change->propertyName() == QByteArrayLiteral("channelName"))
- m_channelName = change->value().toString();
- else if (change->propertyName() == QByteArrayLiteral("target"))
- m_targetId = change->value().value<Qt3DCore::QNodeId>();
- else if (change->propertyName() == QByteArrayLiteral("type"))
- m_type = change->value().toInt();
- else if (change->propertyName() == QByteArrayLiteral("propertyName"))
- m_propertyName = static_cast<const char *>(const_cast<const void *>(change->value().value<void *>()));
- else if (change->propertyName() == QByteArrayLiteral("componentCount"))
- m_componentCount = change->value().toInt();
- else if (change->propertyName() == QByteArrayLiteral("callback"))
- m_callback = static_cast<QAnimationCallback *>(change->value().value<void *>());
- else if (change->propertyName() == QByteArrayLiteral("callbackFlags"))
- m_callbackFlags = QAnimationCallback::Flags(change->value().toInt());
- else if (change->propertyName() == QByteArrayLiteral("skeleton"))
- m_skeletonId = change->value().value<Qt3DCore::QNodeId>();
- break;
+ BackendNode::syncFromFrontEnd(frontEnd, firstTime);
+ const QAbstractChannelMapping *node = qobject_cast<const QAbstractChannelMapping *>(frontEnd);
+ if (!node)
+ return;
+
+ const QChannelMapping *channelMapping = qobject_cast<const QChannelMapping *>(frontEnd);
+ if (channelMapping) {
+ m_mappingType = ChannelMappingType;
+ m_channelName = channelMapping->channelName();
+ m_targetId = Qt3DCore::qIdForNode(channelMapping->target());
+
+ QChannelMappingPrivate *d = static_cast<QChannelMappingPrivate *>(Qt3DCore::QNodePrivate::get(const_cast<QChannelMapping *>(channelMapping)));
+ m_type = d->m_type;
+ m_propertyName = d->m_propertyName;
+ m_componentCount = d->m_componentCount;
}
- default:
- break;
+ const QSkeletonMapping *skeletonMapping = qobject_cast<const QSkeletonMapping *>(frontEnd);
+ if (skeletonMapping) {
+ m_mappingType = SkeletonMappingType;
+ m_skeletonId = Qt3DCore::qIdForNode(skeletonMapping->skeleton());
+ }
+
+ const QCallbackMapping *callbackMapping = qobject_cast<const QCallbackMapping *>(frontEnd);
+ if (callbackMapping) {
+ m_mappingType = ChannelMappingType;
+ m_channelName = channelMapping->channelName();
+
+ const QCallbackMappingPrivate *d = static_cast<const QCallbackMappingPrivate *>(Qt3DCore::QNodePrivate::get(channelMapping));
+ m_type = d->m_type;
+ m_callback = d->m_callback;
+ m_callbackFlags = d->m_callbackFlags;
}
- QBackendNode::sceneChangeEvent(e);
}
Skeleton *ChannelMapping::skeleton() const
diff --git a/src/animation/backend/channelmapping_p.h b/src/animation/backend/channelmapping_p.h
index aa30e84ee..a0ff5f1ca 100644
--- a/src/animation/backend/channelmapping_p.h
+++ b/src/animation/backend/channelmapping_p.h
@@ -76,7 +76,7 @@ public:
void cleanup();
- void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
+ void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override;
void setChannelName(const QString &channelName) { m_channelName = channelName; }
QString channelName() const { return m_channelName; }
@@ -107,8 +107,6 @@ public:
MappingType mappingType() const { return m_mappingType; }
private:
- void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
-
// Properties from QChannelMapping
QString m_channelName;
Qt3DCore::QNodeId m_targetId;
diff --git a/src/animation/backend/clipanimator.cpp b/src/animation/backend/clipanimator.cpp
index acb3c8170..b6bcc9239 100644
--- a/src/animation/backend/clipanimator.cpp
+++ b/src/animation/backend/clipanimator.cpp
@@ -36,6 +36,8 @@
#include "clipanimator_p.h"
#include <Qt3DAnimation/qclipanimator.h>
+#include <Qt3DAnimation/qchannelmapper.h>
+#include <Qt3DAnimation/qclock.h>
#include <Qt3DAnimation/private/qclipanimator_p.h>
#include <Qt3DAnimation/private/animationclip_p.h>
#include <Qt3DAnimation/private/managers_p.h>
@@ -65,19 +67,6 @@ ClipAnimator::ClipAnimator()
{
}
-void ClipAnimator::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change)
-{
- const auto typedChange = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<QClipAnimatorData>>(change);
- const auto &data = typedChange->data;
- m_clipId = data.clipId;
- m_mapperId = data.mapperId;
- m_clockId = data.clockId;
- m_running = data.running;
- m_loops = data.loops;
- m_normalizedLocalTime = data.normalizedTime;
- setDirty(Handler::ClipAnimatorDirty);
-}
-
void ClipAnimator::setClipId(Qt3DCore::QNodeId clipId)
{
m_clipId = clipId;
@@ -129,30 +118,32 @@ void ClipAnimator::cleanup()
m_normalizedLocalTime = m_lastNormalizedLocalTime = -1.0f;
}
-void ClipAnimator::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
+void ClipAnimator::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime)
{
- switch (e->type()) {
- case Qt3DCore::PropertyUpdated: {
- const auto change = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(e);
- if (change->propertyName() == QByteArrayLiteral("clip"))
- setClipId(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;
- }
+ BackendNode::syncFromFrontEnd(frontEnd, firstTime);
+ const QClipAnimator *node = qobject_cast<const QClipAnimator *>(frontEnd);
+ if (!node)
+ return;
- default:
- break;
- }
- QBackendNode::sceneChangeEvent(e);
+ auto id = Qt3DCore::qIdForNode(node->clip());
+ if (m_clipId != id)
+ setClipId(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::ClipAnimatorDirty);
}
void ClipAnimator::sendPropertyChanges(const QVector<Qt3DCore::QSceneChangePtr> &changes)
diff --git a/src/animation/backend/clipanimator_p.h b/src/animation/backend/clipanimator_p.h
index f4c04a4bf..54d1527a4 100644
--- a/src/animation/backend/clipanimator_p.h
+++ b/src/animation/backend/clipanimator_p.h
@@ -80,7 +80,7 @@ public:
void setNormalizedLocalTime(float normalizedLocalTime);
float normalizedLocalTime() const { return m_normalizedLocalTime; }
- void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
+ void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override;
void setHandler(Handler *handler) { m_handler = handler; }
// Called by jobs
@@ -116,8 +116,6 @@ public:
}
private:
- void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
-
Qt3DCore::QNodeId m_clipId;
Qt3DCore::QNodeId m_mapperId;
Qt3DCore::QNodeId m_clockId;
diff --git a/src/animation/backend/clipblendvalue.cpp b/src/animation/backend/clipblendvalue.cpp
index 5685d5191..e1586953b 100644
--- a/src/animation/backend/clipblendvalue.cpp
+++ b/src/animation/backend/clipblendvalue.cpp
@@ -54,22 +54,14 @@ ClipBlendValue::~ClipBlendValue()
{
}
-void ClipBlendValue::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change)
+void ClipBlendValue::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime)
{
- ClipBlendNode::initializeFromPeer(change);
- const auto creationChange
- = qSharedPointerCast<QClipBlendNodeCreatedChange<QClipBlendValueData>>(change);
- const Qt3DAnimation::QClipBlendValueData data = creationChange->data;
- m_clipId = data.clipId;
-}
+ BackendNode::syncFromFrontEnd(frontEnd, firstTime);
+ const QClipBlendValue *node = qobject_cast<const QClipBlendValue *>(frontEnd);
+ if (!node)
+ return;
-void ClipBlendValue::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
-{
- if (e->type() == Qt3DCore::PropertyUpdated) {
- Qt3DCore::QPropertyUpdatedChangePtr change = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(e);
- if (change->propertyName() == QByteArrayLiteral("clip"))
- m_clipId = change->value().value<Qt3DCore::QNodeId>();
- }
+ m_clipId = Qt3DCore::qIdForNode(node->clip());
}
ClipResults ClipBlendValue::doBlend(const QVector<ClipResults> &blendData) const
diff --git a/src/animation/backend/clipblendvalue_p.h b/src/animation/backend/clipblendvalue_p.h
index 168989a89..8a0f93d3d 100644
--- a/src/animation/backend/clipblendvalue_p.h
+++ b/src/animation/backend/clipblendvalue_p.h
@@ -64,7 +64,7 @@ public:
inline Qt3DCore::QNodeId clipId() const { return m_clipId; }
void setClipId(Qt3DCore::QNodeId clipId) { m_clipId = clipId; } // For unit tests
- void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
+ void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override;
inline QVector<Qt3DCore::QNodeId> allDependencyIds() const override
{
@@ -86,8 +86,6 @@ protected:
ClipResults doBlend(const QVector<ClipResults> &blendData) const override;
private:
- void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
-
Qt3DCore::QNodeId m_clipId;
QVector<Qt3DCore::QNodeId> m_animatorIds;
diff --git a/src/animation/backend/clock.cpp b/src/animation/backend/clock.cpp
index f5b2bd1d3..ab30f735c 100644
--- a/src/animation/backend/clock.cpp
+++ b/src/animation/backend/clock.cpp
@@ -52,28 +52,16 @@ Clock::Clock()
{
}
-void Clock::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change)
+void Clock::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime)
{
- const auto typedChange = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<QClockData>>(change);
- const auto &data = typedChange->data;
- m_playbackRate = data.playbackRate;
-}
-
-void Clock::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
-{
- switch (e->type()) {
- case Qt3DCore::PropertyUpdated: {
- const auto change = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(e);
- if (change->propertyName() == QByteArrayLiteral("playbackRate")) {
- m_playbackRate = change.data()->value().toDouble();
- }
- break;
- }
+ BackendNode::syncFromFrontEnd(frontEnd, firstTime);
+ const QClock *node = qobject_cast<const QClock *>(frontEnd);
+ if (!node)
+ return;
- default:
- break;
+ if (!qFuzzyCompare(m_playbackRate, node->playbackRate())) {
+ m_playbackRate = node->playbackRate();
}
- QBackendNode::sceneChangeEvent(e);
}
void Clock::cleanup()
diff --git a/src/animation/backend/clock_p.h b/src/animation/backend/clock_p.h
index 10987655a..b4a60b3a7 100644
--- a/src/animation/backend/clock_p.h
+++ b/src/animation/backend/clock_p.h
@@ -61,15 +61,13 @@ class Q_AUTOTEST_EXPORT Clock : public BackendNode
public:
Clock();
- void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e);
+ void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override;
void cleanup();
void setPlaybackRate(double playbackRate) { m_playbackRate = playbackRate; }
double playbackRate() const { return m_playbackRate; }
private:
- void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
-
double m_playbackRate;
};
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/backend/skeleton.cpp b/src/animation/backend/skeleton.cpp
index dcfaf55e7..720b43e33 100644
--- a/src/animation/backend/skeleton.cpp
+++ b/src/animation/backend/skeleton.cpp
@@ -62,14 +62,7 @@ void Skeleton::cleanup()
m_jointLocalPoses.clear();
}
-void Skeleton::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change)
-{
- // Nothing to initialize from the frontend. We get all of our internal state
- // from whatever aspect loads the skeleton data - the render aspect in the
- // default case.
- Q_UNUSED(change);
-}
-
+// TODOSYNC remove once backend > backend communication no longer requires messages
void Skeleton::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
{
// Get the joint names and initial local poses from a change sent
diff --git a/src/animation/backend/skeleton_p.h b/src/animation/backend/skeleton_p.h
index f1ddb1e81..668ff8712 100644
--- a/src/animation/backend/skeleton_p.h
+++ b/src/animation/backend/skeleton_p.h
@@ -112,8 +112,6 @@ public:
#endif
private:
- void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) Q_DECL_FINAL;
-
QVector<QString> m_jointNames;
QVector<Qt3DCore::Sqt> m_jointLocalPoses;
};