diff options
author | Mike Krus <mike.krus@kdab.com> | 2019-09-20 07:09:45 +0100 |
---|---|---|
committer | Mike Krus <mike.krus@kdab.com> | 2019-09-23 06:27:45 +0100 |
commit | 5815bb74788f9c0f355754d6a56cfa527684ea98 (patch) | |
tree | 692cfd678d5fe4dc2d727bfb3dba352884400347 /src/animation/backend/channelmapper.cpp | |
parent | c7f10617a0be44cf2b61fdc0809fafe7a0aef49a (diff) |
Update QChannelMapper to use direct sync
Change-Id: I066b6742cc272155f55322e3aaf73e28980341d0
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/animation/backend/channelmapper.cpp')
-rw-r--r-- | src/animation/backend/channelmapper.cpp | 47 |
1 files changed, 15 insertions, 32 deletions
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 |