| 1 | // Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QT3DANIMATION_ANIMATION_HANDLER_H |
| 5 | #define QT3DANIMATION_ANIMATION_HANDLER_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists for the convenience |
| 12 | // of other Qt classes. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QtGlobal> |
| 19 | #include <Qt3DAnimation/private/handle_types_p.h> |
| 20 | #include <Qt3DCore/qaspectjob.h> |
| 21 | #include <Qt3DCore/qnodeid.h> |
| 22 | #include <QtCore/qscopedpointer.h> |
| 23 | #include <QtCore/qmutex.h> |
| 24 | |
| 25 | QT_BEGIN_NAMESPACE |
| 26 | |
| 27 | #if defined(QT_BUILD_INTERNAL) |
| 28 | class tst_Handler; |
| 29 | #endif |
| 30 | |
| 31 | namespace Qt3DAnimation { |
| 32 | namespace Animation { |
| 33 | |
| 34 | class AnimationClip; |
| 35 | class AnimationClipLoaderManager; |
| 36 | class ClockManager; |
| 37 | class ClipAnimator; |
| 38 | class ClipAnimatorManager; |
| 39 | class BlendedClipAnimator; |
| 40 | class BlendedClipAnimatorManager; |
| 41 | class ChannelMapping; |
| 42 | class ChannelMappingManager; |
| 43 | class ChannelMapper; |
| 44 | class ChannelMapperManager; |
| 45 | class ClipBlendNodeManager; |
| 46 | class SkeletonManager; |
| 47 | |
| 48 | class FindRunningClipAnimatorsJob; |
| 49 | class LoadAnimationClipJob; |
| 50 | class EvaluateClipAnimatorJob; |
| 51 | class BuildBlendTreesJob; |
| 52 | class EvaluateBlendClipAnimatorJob; |
| 53 | |
| 54 | using BuildBlendTreesJobPtr = QSharedPointer<BuildBlendTreesJob>; |
| 55 | using EvaluateBlendClipAnimatorJobPtr = QSharedPointer<EvaluateBlendClipAnimatorJob>; |
| 56 | |
| 57 | class Q_AUTOTEST_EXPORT Handler |
| 58 | { |
| 59 | public: |
| 60 | Handler(); |
| 61 | ~Handler(); |
| 62 | |
| 63 | enum DirtyFlag { |
| 64 | AnimationClipDirty, |
| 65 | ChannelMappingsDirty, |
| 66 | ClipAnimatorDirty, |
| 67 | BlendedClipAnimatorDirty |
| 68 | }; |
| 69 | |
| 70 | qint64 simulationTime() const { return m_simulationTime; } |
| 71 | |
| 72 | void setDirty(DirtyFlag flag, Qt3DCore::QNodeId nodeId); |
| 73 | |
| 74 | void setClipAnimatorRunning(const HClipAnimator &handle, bool running); |
| 75 | QVector<HClipAnimator> runningClipAnimators() const { return m_runningClipAnimators; } |
| 76 | |
| 77 | void setBlendedClipAnimatorRunning(const HBlendedClipAnimator &handle, bool running); |
| 78 | QVector<HBlendedClipAnimator> runningBlenndedClipAnimators() const { return m_runningBlendedClipAnimators; } |
| 79 | |
| 80 | AnimationClipLoaderManager *animationClipLoaderManager() const noexcept { return m_animationClipLoaderManager.data(); } |
| 81 | ClockManager *clockManager() const noexcept { return m_clockManager.data(); } |
| 82 | ClipAnimatorManager *clipAnimatorManager() const noexcept { return m_clipAnimatorManager.data(); } |
| 83 | BlendedClipAnimatorManager *blendedClipAnimatorManager() const noexcept { return m_blendedClipAnimatorManager.data(); } |
| 84 | ChannelMappingManager *channelMappingManager() const noexcept { return m_channelMappingManager.data(); } |
| 85 | ChannelMapperManager *channelMapperManager() const noexcept { return m_channelMapperManager.data(); } |
| 86 | ClipBlendNodeManager *clipBlendNodeManager() const noexcept { return m_clipBlendNodeManager.data(); } |
| 87 | SkeletonManager *skeletonManager() const noexcept { return m_skeletonManager.data(); } |
| 88 | |
| 89 | std::vector<Qt3DCore::QAspectJobPtr> jobsToExecute(qint64 time); |
| 90 | |
| 91 | void cleanupHandleList(QVector<HAnimationClip> *clips); |
| 92 | void cleanupHandleList(QVector<HClipAnimator> *animators); |
| 93 | void cleanupHandleList(QVector<HBlendedClipAnimator> *animators); |
| 94 | |
| 95 | private: |
| 96 | QMutex m_mutex; |
| 97 | QScopedPointer<AnimationClipLoaderManager> m_animationClipLoaderManager; |
| 98 | QScopedPointer<ClockManager> m_clockManager; |
| 99 | QScopedPointer<ClipAnimatorManager> m_clipAnimatorManager; |
| 100 | QScopedPointer<BlendedClipAnimatorManager> m_blendedClipAnimatorManager; |
| 101 | QScopedPointer<ChannelMappingManager> m_channelMappingManager; |
| 102 | QScopedPointer<ChannelMapperManager> m_channelMapperManager; |
| 103 | QScopedPointer<ClipBlendNodeManager> m_clipBlendNodeManager; |
| 104 | QScopedPointer<SkeletonManager> m_skeletonManager; |
| 105 | |
| 106 | QVector<HAnimationClip> m_dirtyAnimationClips; |
| 107 | QVector<HClipAnimator> m_dirtyClipAnimators; |
| 108 | QVector<HBlendedClipAnimator> m_dirtyBlendedAnimators; |
| 109 | |
| 110 | QVector<HClipAnimator> m_runningClipAnimators; |
| 111 | QVector<HBlendedClipAnimator> m_runningBlendedClipAnimators; |
| 112 | |
| 113 | QSharedPointer<LoadAnimationClipJob> m_loadAnimationClipJob; |
| 114 | QSharedPointer<FindRunningClipAnimatorsJob> m_findRunningClipAnimatorsJob; |
| 115 | QVector<QSharedPointer<EvaluateClipAnimatorJob>> m_evaluateClipAnimatorJobs; |
| 116 | QVector<EvaluateBlendClipAnimatorJobPtr> m_evaluateBlendClipAnimatorJobs; |
| 117 | BuildBlendTreesJobPtr m_buildBlendTreesJob; |
| 118 | |
| 119 | qint64 m_simulationTime; |
| 120 | |
| 121 | #if defined(QT_BUILD_INTERNAL) |
| 122 | friend class QT_PREPEND_NAMESPACE(tst_Handler); |
| 123 | #endif |
| 124 | }; |
| 125 | |
| 126 | } // namespace Animation |
| 127 | } // namespace Qt3DAnimation |
| 128 | |
| 129 | QT_END_NAMESPACE |
| 130 | |
| 131 | #endif // QT3DANIMATION_ANIMATION_HANDLER_H |
| 132 |
