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 "qskeletonmapping.h"
5#include "qskeletonmapping_p.h"
6#include <Qt3DCore/qabstractskeleton.h>
7
8QT_BEGIN_NAMESPACE
9
10namespace Qt3DAnimation {
11
12QSkeletonMappingPrivate::QSkeletonMappingPrivate()
13 : QAbstractChannelMappingPrivate()
14 , m_skeleton(nullptr)
15{
16 m_mappingType = QAbstractChannelMappingPrivate::SkeletonMapping;
17}
18
19QSkeletonMapping::QSkeletonMapping(Qt3DCore::QNode *parent)
20 : QAbstractChannelMapping(*new QSkeletonMappingPrivate, parent)
21{
22}
23
24QSkeletonMapping::QSkeletonMapping(QSkeletonMappingPrivate &dd, Qt3DCore::QNode *parent)
25 : QAbstractChannelMapping(dd, parent)
26{
27}
28
29QSkeletonMapping::~QSkeletonMapping()
30{
31}
32
33Qt3DCore::QAbstractSkeleton *QSkeletonMapping::skeleton() const
34{
35 Q_D(const QSkeletonMapping);
36 return d->m_skeleton;
37}
38
39void QSkeletonMapping::setSkeleton(Qt3DCore::QAbstractSkeleton *skeleton)
40{
41 Q_D(QSkeletonMapping);
42 if (d->m_skeleton == skeleton)
43 return;
44
45 if (d->m_skeleton)
46 d->unregisterDestructionHelper(node: d->m_skeleton);
47
48 if (skeleton && !skeleton->parent())
49 skeleton->setParent(this);
50 d->m_skeleton = skeleton;
51
52 // Ensures proper bookkeeping
53 if (d->m_skeleton)
54 d->registerDestructionHelper(node: d->m_skeleton, func: &QSkeletonMapping::setSkeleton, d->m_skeleton);
55
56 emit skeletonChanged(skeleton);
57}
58
59} // namespace Qt3DAnimation
60
61QT_END_NAMESPACE
62
63#include "moc_qskeletonmapping.cpp"
64

source code of qt3d/src/animation/frontend/qskeletonmapping.cpp