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 | #include "clipblendvalue_p.h" |
38 | #include <Qt3DAnimation/qclipblendnodecreatedchange.h> |
39 | #include <Qt3DAnimation/qclipblendvalue.h> |
40 | #include <Qt3DAnimation/private/qclipblendvalue_p.h> |
41 | |
42 | QT_BEGIN_NAMESPACE |
43 | |
44 | namespace Qt3DAnimation { |
45 | namespace Animation { |
46 | |
47 | ClipBlendValue::ClipBlendValue() |
48 | : ClipBlendNode(ValueType) |
49 | { |
50 | } |
51 | |
52 | ClipBlendValue::~ClipBlendValue() |
53 | { |
54 | } |
55 | |
56 | void ClipBlendValue::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) |
57 | { |
58 | BackendNode::syncFromFrontEnd(frontEnd, firstTime); |
59 | const QClipBlendValue *node = qobject_cast<const QClipBlendValue *>(object: frontEnd); |
60 | if (!node) |
61 | return; |
62 | |
63 | m_clipId = Qt3DCore::qIdForNode(node: node->clip()); |
64 | } |
65 | |
66 | ClipResults ClipBlendValue::doBlend(const QVector<ClipResults> &blendData) const |
67 | { |
68 | // Should never be called for the value node |
69 | Q_UNUSED(blendData); |
70 | Q_UNREACHABLE(); |
71 | return ClipResults(); |
72 | } |
73 | |
74 | double ClipBlendValue::duration() const |
75 | { |
76 | if (m_clipId.isNull()) |
77 | return 0.0; |
78 | AnimationClip *clip = m_handler->animationClipLoaderManager()->lookupResource(id: m_clipId); |
79 | Q_ASSERT(clip); |
80 | return clip->duration(); |
81 | } |
82 | |
83 | void ClipBlendValue::setClipFormat(Qt3DCore::QNodeId animatorId, const ClipFormat &formatIndices) |
84 | { |
85 | // Do we already have an entry for this animator? |
86 | const int animatorIndex = m_animatorIds.indexOf(t: animatorId); |
87 | if (animatorIndex == -1) { |
88 | // Nope, add it |
89 | m_animatorIds.push_back(t: animatorId); |
90 | m_clipFormats.push_back(t: formatIndices); |
91 | } else { |
92 | m_clipFormats[animatorIndex] = formatIndices; |
93 | } |
94 | } |
95 | |
96 | ClipFormat &ClipBlendValue::clipFormat(Qt3DCore::QNodeId animatorId) |
97 | { |
98 | const int animatorIndex = m_animatorIds.indexOf(t: animatorId); |
99 | return m_clipFormats[animatorIndex]; |
100 | } |
101 | |
102 | const ClipFormat &ClipBlendValue::clipFormat(Qt3DCore::QNodeId animatorId) const |
103 | { |
104 | const int animatorIndex = m_animatorIds.indexOf(t: animatorId); |
105 | return m_clipFormats[animatorIndex]; |
106 | } |
107 | |
108 | } // namespace Animation |
109 | } // namespace Qt3DAnimation |
110 | |
111 | QT_END_NAMESPACE |
112 |