diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2017-03-24 13:21:25 +0000 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2017-03-26 07:29:29 +0000 |
commit | 9a5139a2b59ac27afa190caa46ba22138f9dfa6c (patch) | |
tree | e0ceb21228fd923aa72cdeb87d637377ae92060a /src | |
parent | 78280da782ea8c1882afe18ee611aa199e914418 (diff) |
Remove clips property from QAbstractClipBlendNode and friends
No longer needed as concrete subclasses each provide their own specific
APIs for managing clips or sub trees.
Change-Id: I8e090bcf18ad9bf0d19e36128d7556aaa6cd6edf
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src')
11 files changed, 2 insertions, 358 deletions
diff --git a/src/animation/backend/clipblendnode.cpp b/src/animation/backend/clipblendnode.cpp index f22df7b74..0db22a057 100644 --- a/src/animation/backend/clipblendnode.cpp +++ b/src/animation/backend/clipblendnode.cpp @@ -67,89 +67,14 @@ Qt3DCore::QNodeIdVector ClipBlendNode::childrenIds() const return m_childrenIds; } -Qt3DCore::QNodeIdVector ClipBlendNode::clipIds() const -{ - return m_clipIds; -} - -void ClipBlendNode::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) -{ - switch (e->type()) { - - case Qt3DCore::PropertyValueAdded: { - Qt3DCore::QPropertyNodeAddedChangePtr change = qSharedPointerCast<Qt3DCore::QPropertyNodeAddedChange>(e); - if (change->metaObject()->inherits(&QAbstractClipBlendNode::staticMetaObject)) - addChildId(change->addedNodeId()); - else if (change->metaObject()->inherits(&QAbstractAnimationClip::staticMetaObject)) - m_clipIds.push_back(change->addedNodeId()); - break; - } - - case Qt3DCore::PropertyValueRemoved: { - Qt3DCore::QPropertyNodeRemovedChangePtr change = qSharedPointerCast<Qt3DCore::QPropertyNodeRemovedChange>(e); - if (change->metaObject()->inherits(&QAbstractClipBlendNode::staticMetaObject)) - removeChildId(change->removedNodeId()); - else if (change->metaObject()->inherits(&QAbstractAnimationClip::staticMetaObject)) - m_clipIds.removeOne(change->removedNodeId()); - break; - } - - default: - break; - } - - Qt3DCore::QBackendNode::sceneChangeEvent(e); -} - void ClipBlendNode::setClipBlendNodeManager(ClipBlendNodeManager *manager) { m_manager = manager; } - - void ClipBlendNode::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) { - const auto creationChange = qSharedPointerCast<QClipBlendNodeCreatedChangeBase>(change); - setParentId(creationChange->parentClipBlendNodeId()); - m_clipIds = creationChange->clips(); -} - -void ClipBlendNode::setParentId(Qt3DCore::QNodeId parentId) -{ - if (parentId != m_parentId) { - // We already had a parent, tell it to abandon us - if (!m_parentId.isNull()) { - ClipBlendNode *parent = m_manager->lookupNode(m_parentId); - if (parent != nullptr) - parent->m_childrenIds.removeAll(peerId()); - } - m_parentId = parentId; - ClipBlendNode *parent = m_manager->lookupNode(m_parentId); - if (parent != nullptr && !parent->m_childrenIds.contains(peerId())) - parent->m_childrenIds.append(peerId()); - } -} - -void ClipBlendNode::addChildId(Qt3DCore::QNodeId childId) -{ - if (!m_childrenIds.contains(childId)) { - ClipBlendNode *child = m_manager->lookupNode(childId); - if (child != nullptr) { - m_childrenIds.push_back(childId); - child->m_parentId = peerId(); - } - } -} - -void ClipBlendNode::removeChildId(Qt3DCore::QNodeId childId) -{ - if (m_childrenIds.contains(childId)) { - ClipBlendNode *child = m_manager->lookupNode(childId); - if (child != nullptr) - child->m_parentId = Qt3DCore::QNodeId(); - m_childrenIds.removeAll(childId); - } + Q_UNUSED(change); } ClipBlendNode::BlendType Animation::ClipBlendNode::blendType() const diff --git a/src/animation/backend/clipblendnode_p.h b/src/animation/backend/clipblendnode_p.h index 17e219dd4..eeb69cb75 100644 --- a/src/animation/backend/clipblendnode_p.h +++ b/src/animation/backend/clipblendnode_p.h @@ -78,9 +78,6 @@ public: BlendType blendType() const; Qt3DCore::QNodeId parentId() const; Qt3DCore::QNodeIdVector childrenIds() const; - Qt3DCore::QNodeIdVector clipIds() const; - - void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) Q_DECL_OVERRIDE; // TODO: Remove this old blend() virtual and rename performBlend() to blend() virtual float blend(float value1, float value2) const = 0; @@ -98,13 +95,6 @@ protected: virtual ClipResults doBlend(const QVector<ClipResults> &blendData) const = 0; private: - void setParentId(Qt3DCore::QNodeId parentId); - void addChildId(Qt3DCore::QNodeId childId); - void removeChildId(Qt3DCore::QNodeId childId); - - // Can either contain clips or nothing (tree of other blend nodes) - Qt3DCore::QNodeIdVector m_clipIds; - Qt3DCore::QNodeId m_parentId; Qt3DCore::QNodeIdVector m_childrenIds; ClipBlendNodeManager *m_manager; diff --git a/src/animation/frontend/qabstractclipblendnode.cpp b/src/animation/frontend/qabstractclipblendnode.cpp index 10e3b9ef5..9cc6f3de6 100644 --- a/src/animation/frontend/qabstractclipblendnode.cpp +++ b/src/animation/frontend/qabstractclipblendnode.cpp @@ -36,9 +36,6 @@ #include "qabstractclipblendnode.h" #include "qabstractclipblendnode_p.h" -#include <Qt3DCore/qpropertynodeaddedchange.h> -#include <Qt3DCore/qpropertynoderemovedchange.h> -#include <Qt3DAnimation/qabstractanimationclip.h> QT_BEGIN_NAMESPACE @@ -63,62 +60,6 @@ QAbstractClipBlendNode::~QAbstractClipBlendNode() { } -void QAbstractClipBlendNode::addClip(QAbstractAnimationClip *clip) -{ - Q_D(QAbstractClipBlendNode); - if (!d->m_clips.contains(clip)) { - d->m_clips.push_back(clip); - - // Ensures proper bookkeeping - d->registerDestructionHelper(clip, &QAbstractClipBlendNode::removeClip, d->m_clips); - - // We need to add it as a child of the current node if it has been declared inline - // Or not previously added as a child of the current node so that - // 1) The backend gets notified about it's creation - // 2) When the current node is destroyed, it gets destroyed as well - if (!clip->parent()) - clip->setParent(this); - - if (d->m_changeArbiter != nullptr) { - const auto change = Qt3DCore::QPropertyNodeAddedChangePtr::create(id(), clip); - change->setPropertyName("clip"); - d->notifyObservers(change); - } - } -} - -void QAbstractClipBlendNode::removeClip(QAbstractAnimationClip *clip) -{ - Q_D(QAbstractClipBlendNode); - if (d->m_changeArbiter != nullptr) { - const auto change = Qt3DCore::QPropertyNodeRemovedChangePtr::create(id(), clip); - change->setPropertyName("clip"); - d->notifyObservers(change); - } - d->m_clips.removeOne(clip); - // Remove bookkeeping connection - d->unregisterDestructionHelper(clip); -} - -QVector<QAbstractAnimationClip *> QAbstractClipBlendNode::clips() const -{ - Q_D(const QAbstractClipBlendNode); - return d->m_clips; -} - -QAbstractClipBlendNode *QAbstractClipBlendNode::parentClipBlendNode() const -{ - QAbstractClipBlendNode *parentBlendClipNode = nullptr; - QNode *parentN = parentNode(); - while (parentN != nullptr) { - parentBlendClipNode = qobject_cast<QAbstractClipBlendNode *>(parentN); - if (parentBlendClipNode != nullptr) - break; - parentN = parentN->parentNode(); - } - return parentBlendClipNode; -} - } // Qt3DAnimation QT_END_NAMESPACE diff --git a/src/animation/frontend/qabstractclipblendnode.h b/src/animation/frontend/qabstractclipblendnode.h index d51190351..d981bd7a5 100644 --- a/src/animation/frontend/qabstractclipblendnode.h +++ b/src/animation/frontend/qabstractclipblendnode.h @@ -53,16 +53,10 @@ class QT3DANIMATIONSHARED_EXPORT QAbstractClipBlendNode : public Qt3DCore::QNode public: ~QAbstractClipBlendNode(); - QVector<QAbstractAnimationClip *> clips() const; - QAbstractClipBlendNode *parentClipBlendNode() const; - void addClip(QAbstractAnimationClip *clip); - void removeClip(QAbstractAnimationClip *clip); - protected: explicit QAbstractClipBlendNode(Qt3DCore::QNode *parent = nullptr); explicit QAbstractClipBlendNode(QAbstractClipBlendNodePrivate &dd, Qt3DCore::QNode *parent = nullptr); - private: Q_DECLARE_PRIVATE(QAbstractClipBlendNode) }; diff --git a/src/animation/frontend/qclipblendnodecreatedchange.cpp b/src/animation/frontend/qclipblendnodecreatedchange.cpp index 72266ade4..9251442bb 100644 --- a/src/animation/frontend/qclipblendnodecreatedchange.cpp +++ b/src/animation/frontend/qclipblendnodecreatedchange.cpp @@ -45,8 +45,6 @@ namespace Qt3DAnimation { QClipBlendNodeCreatedChangeBasePrivate::QClipBlendNodeCreatedChangeBasePrivate(const QAbstractClipBlendNode *node) : Qt3DCore::QNodeCreatedChangeBasePrivate(node) - , m_parentClipBlendNodeId(Qt3DCore::qIdForNode(node->parentClipBlendNode())) - , m_clips(Qt3DCore::qIdsForNodes(node->clips())) { } @@ -59,19 +57,6 @@ QClipBlendNodeCreatedChangeBase::~QClipBlendNodeCreatedChangeBase() { } -Qt3DCore::QNodeId QClipBlendNodeCreatedChangeBase::parentClipBlendNodeId() const -{ - Q_D(const QClipBlendNodeCreatedChangeBase); - return d->m_parentClipBlendNodeId; -} - -Qt3DCore::QNodeIdVector QClipBlendNodeCreatedChangeBase::clips() const -{ - Q_D(const QClipBlendNodeCreatedChangeBase); - return d->m_clips; -} - - } // Qt3DAnimation QT_END_NAMESPACE diff --git a/src/animation/frontend/qclipblendnodecreatedchange.h b/src/animation/frontend/qclipblendnodecreatedchange.h index b07d080bd..01f17d7ca 100644 --- a/src/animation/frontend/qclipblendnodecreatedchange.h +++ b/src/animation/frontend/qclipblendnodecreatedchange.h @@ -53,9 +53,6 @@ public: explicit QClipBlendNodeCreatedChangeBase(const QAbstractClipBlendNode *node); ~QClipBlendNodeCreatedChangeBase(); - Qt3DCore::QNodeId parentClipBlendNodeId() const; - Qt3DCore::QNodeIdVector clips() const; - private: Q_DECLARE_PRIVATE(QClipBlendNodeCreatedChangeBase) }; diff --git a/src/animation/frontend/qclipblendnodecreatedchange_p.h b/src/animation/frontend/qclipblendnodecreatedchange_p.h index 0b853cd96..31342d3a8 100644 --- a/src/animation/frontend/qclipblendnodecreatedchange_p.h +++ b/src/animation/frontend/qclipblendnodecreatedchange_p.h @@ -60,9 +60,6 @@ class QClipBlendNodeCreatedChangeBasePrivate : public Qt3DCore::QNodeCreatedChan { public: QClipBlendNodeCreatedChangeBasePrivate(const QAbstractClipBlendNode *node); - - Qt3DCore::QNodeId m_parentClipBlendNodeId; - Qt3DCore::QNodeIdVector m_clips; }; } // Qt3DAnimation diff --git a/src/quick3d/imports/animation/qt3dquick3danimationplugin.cpp b/src/quick3d/imports/animation/qt3dquick3danimationplugin.cpp index 85c5c270c..fe673b16b 100644 --- a/src/quick3d/imports/animation/qt3dquick3danimationplugin.cpp +++ b/src/quick3d/imports/animation/qt3dquick3danimationplugin.cpp @@ -57,7 +57,6 @@ #include <Qt3DQuickAnimation/private/qt3dquickanimation_global_p.h> #include <Qt3DQuickAnimation/private/quick3dchannelmapper_p.h> -#include <Qt3DQuickAnimation/private/quick3dabstractclipblendnode_p.h> #include <Qt3DQuickAnimation/private/quick3dkeyframeanimation_p.h> #include <Qt3DQuickAnimation/private/quick3danimationgroup_p.h> #include <Qt3DQuickAnimation/private/quick3danimationcontroller_p.h> @@ -80,8 +79,7 @@ void Qt3DQuick3DAnimationPlugin::registerTypes(const char *uri) qmlRegisterType<Qt3DAnimation::QAnimationClipLoader>(uri, 2, 9, "AnimationClip"); qmlRegisterExtendedType<Qt3DAnimation::QChannelMapper, Qt3DAnimation::Animation::Quick::Quick3DChannelMapper>(uri, 2, 9, "ChannelMapper"); - qmlRegisterExtendedUncreatableType<Qt3DAnimation::QAbstractClipBlendNode, - Qt3DAnimation::Animation::Quick::Quick3DAbstractClipBlendNode>(uri, 2, 9, "AbstractClipBlendNode", QStringLiteral("QAbstractClipBlendNode is abstract")); + qmlRegisterUncreatableType<Qt3DAnimation::QAbstractClipBlendNode>(uri, 2, 9, "AbstractClipBlendNode", QStringLiteral("QAbstractClipBlendNode is abstract")); qmlRegisterType<Qt3DAnimation::QLerpClipBlend>(uri, 2, 9, "LerpClipBlend"); qmlRegisterType<Qt3DAnimation::QAdditiveClipBlend>(uri, 2, 9, "AdditiveClipBlend"); qmlRegisterType<Qt3DAnimation::QClipBlendValue>(uri, 2, 9, "ClipBlendValue"); diff --git a/src/quick3d/quick3danimation/items/items.pri b/src/quick3d/quick3danimation/items/items.pri index 1c88df570..3f19965b5 100644 --- a/src/quick3d/quick3danimation/items/items.pri +++ b/src/quick3d/quick3danimation/items/items.pri @@ -1,6 +1,5 @@ SOURCES += \ $$PWD/quick3dchannelmapper.cpp \ - $$PWD/quick3dabstractclipblendnode.cpp \ $$PWD/quick3danimationcontroller.cpp \ $$PWD/quick3danimationgroup.cpp \ $$PWD/quick3dkeyframeanimation.cpp \ @@ -9,7 +8,6 @@ SOURCES += \ HEADERS += \ $$PWD/quick3dchannelmapper_p.h \ - $$PWD/quick3dabstractclipblendnode_p.h \ $$PWD/quick3danimationcontroller_p.h \ $$PWD/quick3danimationgroup_p.h \ $$PWD/quick3dkeyframeanimation_p.h \ diff --git a/src/quick3d/quick3danimation/items/quick3dabstractclipblendnode.cpp b/src/quick3d/quick3danimation/items/quick3dabstractclipblendnode.cpp deleted file mode 100644 index 7094d2bcf..000000000 --- a/src/quick3d/quick3danimation/items/quick3dabstractclipblendnode.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "quick3dabstractclipblendnode_p.h" - -QT_BEGIN_NAMESPACE - -namespace Qt3DAnimation { -namespace Animation { -namespace Quick { - -Quick3DAbstractClipBlendNode::Quick3DAbstractClipBlendNode(QObject *parent) - : QObject(parent) -{ -} - -QQmlListProperty<QAbstractAnimationClip> Quick3DAbstractClipBlendNode::clipList() -{ - return QQmlListProperty<QAbstractAnimationClip>(this, 0, - &Quick3DAbstractClipBlendNode::appendClip, - &Quick3DAbstractClipBlendNode::clipCount, - &Quick3DAbstractClipBlendNode::clipAt, - &Quick3DAbstractClipBlendNode::clearClips); -} - -void Quick3DAbstractClipBlendNode::appendClip(QQmlListProperty<QAbstractAnimationClip> *list, QAbstractAnimationClip *clip) -{ - Quick3DAbstractClipBlendNode *extension = qobject_cast<Quick3DAbstractClipBlendNode *>(list->object); - extension->parentAbstractClipBlendNode()->addClip(clip); -} - -QAbstractAnimationClip *Quick3DAbstractClipBlendNode::clipAt(QQmlListProperty<QAbstractAnimationClip> *list, int index) -{ - Quick3DAbstractClipBlendNode *extension = qobject_cast<Quick3DAbstractClipBlendNode *>(list->object); - return extension->parentAbstractClipBlendNode()->clips().at(index); -} - -int Quick3DAbstractClipBlendNode::clipCount(QQmlListProperty<QAbstractAnimationClip> *list) -{ - Quick3DAbstractClipBlendNode *extension = qobject_cast<Quick3DAbstractClipBlendNode *>(list->object); - return extension->parentAbstractClipBlendNode()->clips().count(); -} - -void Quick3DAbstractClipBlendNode::clearClips(QQmlListProperty<QAbstractAnimationClip> *list) -{ - Quick3DAbstractClipBlendNode *extension = qobject_cast<Quick3DAbstractClipBlendNode *>(list->object); - const QVector<QAbstractAnimationClip *> clips = extension->parentAbstractClipBlendNode()->clips(); - for (QAbstractAnimationClip *clip : clips) - extension->parentAbstractClipBlendNode()->removeClip(clip); -} - -} // Quick -} // Animation -} // Qt3DAnimation - -QT_END_NAMESPACE diff --git a/src/quick3d/quick3danimation/items/quick3dabstractclipblendnode_p.h b/src/quick3d/quick3danimation/items/quick3dabstractclipblendnode_p.h deleted file mode 100644 index 8524600f4..000000000 --- a/src/quick3d/quick3danimation/items/quick3dabstractclipblendnode_p.h +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DANIMATION_ANIMATION_QUICK3DABSTRACTCLIPBLENDNODE_P_H -#define QT3DANIMATION_ANIMATION_QUICK3DABSTRACTCLIPBLENDNODE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <Qt3DQuickAnimation/private/qt3dquickanimation_global_p.h> -#include <Qt3DAnimation/qabstractclipblendnode.h> -#include <Qt3DAnimation/qabstractanimationclip.h> -#include <QQmlListProperty> - -QT_BEGIN_NAMESPACE - -namespace Qt3DAnimation { -namespace Animation { -namespace Quick { - -class QT3DQUICKANIMATIONSHARED_PRIVATE_EXPORT Quick3DAbstractClipBlendNode : public QObject -{ - Q_OBJECT - Q_PROPERTY(QQmlListProperty<Qt3DAnimation::QAbstractAnimationClip> clips READ clipList CONSTANT) - -public: - explicit Quick3DAbstractClipBlendNode(QObject *parent = nullptr); - - inline QAbstractClipBlendNode *parentAbstractClipBlendNode() const { return qobject_cast<QAbstractClipBlendNode *>(parent()); } - QQmlListProperty<QAbstractAnimationClip> clipList(); - -private: - static void appendClip(QQmlListProperty<QAbstractAnimationClip> *list, QAbstractAnimationClip *clip); - static QAbstractAnimationClip *clipAt(QQmlListProperty<QAbstractAnimationClip> *list, int index); - static int clipCount(QQmlListProperty<QAbstractAnimationClip> *list); - static void clearClips(QQmlListProperty<QAbstractAnimationClip> *list); -}; - -} // Quick -} // Animation -} // Qt3DAnimation - -QT_END_NAMESPACE - -#endif // QT3DANIMATION_ANIMATION_QUICK3DABSTRACTCLIPBLENDNODE_P_H |