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 "skeleton_p.h" |
5 | #include <Qt3DCore/private/qabstractskeleton_p.h> |
6 | |
7 | QT_BEGIN_NAMESPACE |
8 | |
9 | |
10 | namespace Qt3DAnimation { |
11 | namespace Animation { |
12 | |
13 | using namespace Qt3DCore; |
14 | |
15 | // Rather than store backend nodes for the individual joints, the |
16 | // animation aspect operates on the vector of local poses as aggregated |
17 | // by the skeleton. This allows us to animate a skeleton even when the |
18 | // frontend QSkeletonLoader does not instantiate the frontend QJoint nodes. |
19 | // It also means we don't need a QChannelMapping for each property of each |
20 | // joint. |
21 | |
22 | Skeleton::Skeleton() |
23 | : BackendNode(Qt3DCore::QBackendNode::ReadWrite) |
24 | { |
25 | } |
26 | |
27 | void Skeleton::cleanup() |
28 | { |
29 | m_jointNames.clear(); |
30 | m_jointLocalPoses.clear(); |
31 | } |
32 | |
33 | void Skeleton::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) |
34 | { |
35 | BackendNode::syncFromFrontEnd(frontEnd, firstTime); |
36 | |
37 | const Qt3DCore::QAbstractSkeleton *node = qobject_cast<const Qt3DCore::QAbstractSkeleton *>(object: frontEnd); |
38 | if (!node) |
39 | return; |
40 | |
41 | auto dnode = Qt3DCore::QAbstractSkeletonPrivate::get(q: node); |
42 | |
43 | // TODO: Mark joint info as dirty so we can rebuild any indexes used |
44 | // by the animators and channel mappings. |
45 | m_jointNames = dnode->m_jointNames; |
46 | m_jointLocalPoses = dnode->m_localPoses; |
47 | } |
48 | |
49 | } // namespace Animation |
50 | } // namespace Qt3DAnimation |
51 | |
52 | QT_END_NAMESPACE |
53 |