| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). |
| 4 | ** Contact: http://www.qt-project.org/legal |
| 5 | ** |
| 6 | ** This file is part of the Qt3D module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL3$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at http://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPLv3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or later as published by the Free |
| 28 | ** Software Foundation and appearing in the file LICENSE.GPL included in |
| 29 | ** the packaging of this file. Please review the following information to |
| 30 | ** ensure the GNU General Public License version 2.0 requirements will be |
| 31 | ** met: http://www.gnu.org/licenses/gpl-2.0.html. |
| 32 | ** |
| 33 | ** $QT_END_LICENSE$ |
| 34 | ** |
| 35 | ****************************************************************************/ |
| 36 | |
| 37 | #ifndef QT3DANIMATION_ANIMATION_HANDLER_H |
| 38 | #define QT3DANIMATION_ANIMATION_HANDLER_H |
| 39 | |
| 40 | // |
| 41 | // W A R N I N G |
| 42 | // ------------- |
| 43 | // |
| 44 | // This file is not part of the Qt API. It exists for the convenience |
| 45 | // of other Qt classes. This header file may change from version to |
| 46 | // version without notice, or even be removed. |
| 47 | // |
| 48 | // We mean it. |
| 49 | // |
| 50 | |
| 51 | #include <QtGlobal> |
| 52 | #include <Qt3DAnimation/private/handle_types_p.h> |
| 53 | #include <Qt3DCore/qaspectjob.h> |
| 54 | #include <Qt3DCore/qnodeid.h> |
| 55 | #include <QtCore/qscopedpointer.h> |
| 56 | #include <QtCore/qmutex.h> |
| 57 | |
| 58 | QT_BEGIN_NAMESPACE |
| 59 | |
| 60 | #if defined(QT_BUILD_INTERNAL) |
| 61 | class tst_Handler; |
| 62 | #endif |
| 63 | |
| 64 | namespace Qt3DAnimation { |
| 65 | namespace Animation { |
| 66 | |
| 67 | class AnimationClip; |
| 68 | class AnimationClipLoaderManager; |
| 69 | class ClockManager; |
| 70 | class ClipAnimator; |
| 71 | class ClipAnimatorManager; |
| 72 | class BlendedClipAnimator; |
| 73 | class BlendedClipAnimatorManager; |
| 74 | class ChannelMapping; |
| 75 | class ChannelMappingManager; |
| 76 | class ChannelMapper; |
| 77 | class ChannelMapperManager; |
| 78 | class ClipBlendNodeManager; |
| 79 | class SkeletonManager; |
| 80 | |
| 81 | class FindRunningClipAnimatorsJob; |
| 82 | class LoadAnimationClipJob; |
| 83 | class EvaluateClipAnimatorJob; |
| 84 | class BuildBlendTreesJob; |
| 85 | class EvaluateBlendClipAnimatorJob; |
| 86 | |
| 87 | using BuildBlendTreesJobPtr = QSharedPointer<BuildBlendTreesJob>; |
| 88 | using EvaluateBlendClipAnimatorJobPtr = QSharedPointer<EvaluateBlendClipAnimatorJob>; |
| 89 | |
| 90 | class Q_AUTOTEST_EXPORT Handler |
| 91 | { |
| 92 | public: |
| 93 | Handler(); |
| 94 | ~Handler(); |
| 95 | |
| 96 | enum DirtyFlag { |
| 97 | AnimationClipDirty, |
| 98 | ChannelMappingsDirty, |
| 99 | ClipAnimatorDirty, |
| 100 | BlendedClipAnimatorDirty |
| 101 | }; |
| 102 | |
| 103 | qint64 simulationTime() const { return m_simulationTime; } |
| 104 | |
| 105 | void setDirty(DirtyFlag flag, Qt3DCore::QNodeId nodeId); |
| 106 | |
| 107 | void setClipAnimatorRunning(const HClipAnimator &handle, bool running); |
| 108 | QVector<HClipAnimator> runningClipAnimators() const { return m_runningClipAnimators; } |
| 109 | |
| 110 | void setBlendedClipAnimatorRunning(const HBlendedClipAnimator &handle, bool running); |
| 111 | QVector<HBlendedClipAnimator> runningBlenndedClipAnimators() const { return m_runningBlendedClipAnimators; } |
| 112 | |
| 113 | AnimationClipLoaderManager *animationClipLoaderManager() const Q_DECL_NOTHROW { return m_animationClipLoaderManager.data(); } |
| 114 | ClockManager *clockManager() const Q_DECL_NOTHROW { return m_clockManager.data(); } |
| 115 | ClipAnimatorManager *clipAnimatorManager() const Q_DECL_NOTHROW { return m_clipAnimatorManager.data(); } |
| 116 | BlendedClipAnimatorManager *blendedClipAnimatorManager() const Q_DECL_NOTHROW { return m_blendedClipAnimatorManager.data(); } |
| 117 | ChannelMappingManager *channelMappingManager() const Q_DECL_NOTHROW { return m_channelMappingManager.data(); } |
| 118 | ChannelMapperManager *channelMapperManager() const Q_DECL_NOTHROW { return m_channelMapperManager.data(); } |
| 119 | ClipBlendNodeManager *clipBlendNodeManager() const Q_DECL_NOTHROW { return m_clipBlendNodeManager.data(); } |
| 120 | SkeletonManager *skeletonManager() const Q_DECL_NOTHROW { return m_skeletonManager.data(); } |
| 121 | |
| 122 | QVector<Qt3DCore::QAspectJobPtr> jobsToExecute(qint64 time); |
| 123 | |
| 124 | void cleanupHandleList(QVector<HAnimationClip> *clips); |
| 125 | void cleanupHandleList(QVector<HClipAnimator> *animators); |
| 126 | void cleanupHandleList(QVector<HBlendedClipAnimator> *animators); |
| 127 | |
| 128 | private: |
| 129 | QMutex m_mutex; |
| 130 | QScopedPointer<AnimationClipLoaderManager> m_animationClipLoaderManager; |
| 131 | QScopedPointer<ClockManager> m_clockManager; |
| 132 | QScopedPointer<ClipAnimatorManager> m_clipAnimatorManager; |
| 133 | QScopedPointer<BlendedClipAnimatorManager> m_blendedClipAnimatorManager; |
| 134 | QScopedPointer<ChannelMappingManager> m_channelMappingManager; |
| 135 | QScopedPointer<ChannelMapperManager> m_channelMapperManager; |
| 136 | QScopedPointer<ClipBlendNodeManager> m_clipBlendNodeManager; |
| 137 | QScopedPointer<SkeletonManager> m_skeletonManager; |
| 138 | |
| 139 | QVector<HAnimationClip> m_dirtyAnimationClips; |
| 140 | QVector<HClipAnimator> m_dirtyClipAnimators; |
| 141 | QVector<HBlendedClipAnimator> m_dirtyBlendedAnimators; |
| 142 | |
| 143 | QVector<HClipAnimator> m_runningClipAnimators; |
| 144 | QVector<HBlendedClipAnimator> m_runningBlendedClipAnimators; |
| 145 | |
| 146 | QSharedPointer<LoadAnimationClipJob> m_loadAnimationClipJob; |
| 147 | QSharedPointer<FindRunningClipAnimatorsJob> m_findRunningClipAnimatorsJob; |
| 148 | QVector<QSharedPointer<EvaluateClipAnimatorJob>> m_evaluateClipAnimatorJobs; |
| 149 | QVector<EvaluateBlendClipAnimatorJobPtr> m_evaluateBlendClipAnimatorJobs; |
| 150 | BuildBlendTreesJobPtr m_buildBlendTreesJob; |
| 151 | |
| 152 | qint64 m_simulationTime; |
| 153 | |
| 154 | #if defined(QT_BUILD_INTERNAL) |
| 155 | friend class QT_PREPEND_NAMESPACE(tst_Handler); |
| 156 | #endif |
| 157 | }; |
| 158 | |
| 159 | } // namespace Animation |
| 160 | } // namespace Qt3DAnimation |
| 161 | |
| 162 | QT_END_NAMESPACE |
| 163 | |
| 164 | #endif // QT3DANIMATION_ANIMATION_HANDLER_H |
| 165 | |