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 | #include "additiveclipblend_p.h" |
5 | #include <Qt3DAnimation/qadditiveclipblend.h> |
6 | #include <Qt3DAnimation/private/qadditiveclipblend_p.h> |
7 | |
8 | QT_BEGIN_NAMESPACE |
9 | |
10 | namespace Qt3DAnimation { |
11 | |
12 | namespace Animation { |
13 | |
14 | AdditiveClipBlend::AdditiveClipBlend() |
15 | : ClipBlendNode(ClipBlendNode::AdditiveBlendType) |
16 | , m_baseClipId() |
17 | , m_additiveClipId() |
18 | , m_additiveFactor(0.0f) |
19 | { |
20 | } |
21 | |
22 | AdditiveClipBlend::~AdditiveClipBlend() |
23 | { |
24 | } |
25 | |
26 | void AdditiveClipBlend::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) |
27 | { |
28 | BackendNode::syncFromFrontEnd(frontEnd, firstTime); |
29 | const QAdditiveClipBlend *node = qobject_cast<const QAdditiveClipBlend *>(object: frontEnd); |
30 | if (!node) |
31 | return; |
32 | |
33 | m_additiveFactor = node->additiveFactor(); |
34 | m_baseClipId = Qt3DCore::qIdForNode(node: node->baseClip()); |
35 | m_additiveClipId = Qt3DCore::qIdForNode(node: node->additiveClip()); |
36 | } |
37 | |
38 | ClipResults AdditiveClipBlend::doBlend(const QList<ClipResults> &blendData) const |
39 | { |
40 | Q_ASSERT(blendData.size() == 2); |
41 | Q_ASSERT(blendData[0].size() == blendData[1].size()); |
42 | const qsizetype elementCount = blendData.first().size(); |
43 | ClipResults blendResults(elementCount); |
44 | |
45 | for (qsizetype i = 0; i < elementCount; ++i) |
46 | blendResults[i] = blendData[0][i] + m_additiveFactor * blendData[1][i]; |
47 | |
48 | return blendResults; |
49 | } |
50 | |
51 | } // Animation |
52 | |
53 | } // Qt3DAnimation |
54 | |
55 | QT_END_NAMESPACE |
56 |