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
58QT_BEGIN_NAMESPACE
59
60#if defined(QT_BUILD_INTERNAL)
61class tst_Handler;
62#endif
63
64namespace Qt3DAnimation {
65namespace Animation {
66
67class AnimationClip;
68class AnimationClipLoaderManager;
69class ClockManager;
70class ClipAnimator;
71class ClipAnimatorManager;
72class BlendedClipAnimator;
73class BlendedClipAnimatorManager;
74class ChannelMapping;
75class ChannelMappingManager;
76class ChannelMapper;
77class ChannelMapperManager;
78class ClipBlendNodeManager;
79class SkeletonManager;
80
81class FindRunningClipAnimatorsJob;
82class LoadAnimationClipJob;
83class EvaluateClipAnimatorJob;
84class BuildBlendTreesJob;
85class EvaluateBlendClipAnimatorJob;
86
87using BuildBlendTreesJobPtr = QSharedPointer<BuildBlendTreesJob>;
88using EvaluateBlendClipAnimatorJobPtr = QSharedPointer<EvaluateBlendClipAnimatorJob>;
89
90class Q_AUTOTEST_EXPORT Handler
91{
92public:
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
128private:
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<HChannelMapper> m_dirtyChannelMappers;
141 QVector<HClipAnimator> m_dirtyClipAnimators;
142 QVector<HBlendedClipAnimator> m_dirtyBlendedAnimators;
143
144 QVector<HClipAnimator> m_runningClipAnimators;
145 QVector<HBlendedClipAnimator> m_runningBlendedClipAnimators;
146
147 QSharedPointer<LoadAnimationClipJob> m_loadAnimationClipJob;
148 QSharedPointer<FindRunningClipAnimatorsJob> m_findRunningClipAnimatorsJob;
149 QVector<QSharedPointer<EvaluateClipAnimatorJob>> m_evaluateClipAnimatorJobs;
150 QVector<EvaluateBlendClipAnimatorJobPtr> m_evaluateBlendClipAnimatorJobs;
151 BuildBlendTreesJobPtr m_buildBlendTreesJob;
152
153 qint64 m_simulationTime;
154
155#if defined(QT_BUILD_INTERNAL)
156 friend class QT_PREPEND_NAMESPACE(tst_Handler);
157#endif
158};
159
160} // namespace Animation
161} // namespace Qt3DAnimation
162
163QT_END_NAMESPACE
164
165#endif // QT3DANIMATION_ANIMATION_HANDLER_H
166