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