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
25QT_BEGIN_NAMESPACE
26
27#if defined(QT_BUILD_INTERNAL)
28class tst_Handler;
29#endif
30
31namespace Qt3DAnimation {
32namespace Animation {
33
34class AnimationClip;
35class AnimationClipLoaderManager;
36class ClockManager;
37class ClipAnimator;
38class ClipAnimatorManager;
39class BlendedClipAnimator;
40class BlendedClipAnimatorManager;
41class ChannelMapping;
42class ChannelMappingManager;
43class ChannelMapper;
44class ChannelMapperManager;
45class ClipBlendNodeManager;
46class SkeletonManager;
47
48class FindRunningClipAnimatorsJob;
49class LoadAnimationClipJob;
50class EvaluateClipAnimatorJob;
51class BuildBlendTreesJob;
52class EvaluateBlendClipAnimatorJob;
53
54using BuildBlendTreesJobPtr = QSharedPointer<BuildBlendTreesJob>;
55using EvaluateBlendClipAnimatorJobPtr = QSharedPointer<EvaluateBlendClipAnimatorJob>;
56
57class Q_AUTOTEST_EXPORT Handler
58{
59public:
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
95private:
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
129QT_END_NAMESPACE
130
131#endif // QT3DANIMATION_ANIMATION_HANDLER_H
132

source code of qt3d/src/animation/backend/handler_p.h