aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick3d/qquick3dskin_p.h
blob: 005dfe2d3e85183490fab56c30668f60c562bb83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#ifndef QSSGSKIN_H
#define QSSGSKIN_H

//
//  W A R N I N G
//  -------------
//
// This file is not part of the Qt API.  It exists purely as an
// implementation detail.  This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//

#include <QtQuick3D/qquick3dobject.h>
#include <QtQuick3D/private/qquick3dnode_p.h>
#include <QtCore/qlist.h>
#include <QtCore/qhash.h>

QT_BEGIN_NAMESPACE

class Q_QUICK3D_EXPORT QQuick3DSkin : public QQuick3DObject
{
    Q_OBJECT
    Q_PROPERTY(QQmlListProperty<QQuick3DNode> joints READ joints)
    Q_PROPERTY(QList<QMatrix4x4> inverseBindPoses READ inverseBindPoses WRITE setInverseBindPoses NOTIFY inverseBindPosesChanged)

    QML_NAMED_ELEMENT(Skin)

public:
    explicit QQuick3DSkin(QQuick3DObject *parent = nullptr);
    ~QQuick3DSkin() override;

    QQmlListProperty<QQuick3DNode> joints();
    QList<QMatrix4x4> inverseBindPoses() const;

public Q_SLOTS:
    void setInverseBindPoses(const QList<QMatrix4x4> &poses);

Q_SIGNALS:
    void inverseBindPosesChanged();

private:
    static void qmlAppendJoint(QQmlListProperty<QQuick3DNode> *list, QQuick3DNode *joint);
    static QQuick3DNode *qmlJointAt(QQmlListProperty<QQuick3DNode> *list, qsizetype index);
    static qsizetype qmlJointsCount(QQmlListProperty<QQuick3DNode> *list);
    static void qmlClearJoints(QQmlListProperty<QQuick3DNode> *list);

    QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override;

    QVector<QQuick3DNode *> m_joints;
    QByteArray m_boneData;
    QList<QMatrix4x4> m_inverseBindPoses;
    using JointConnections = std::pair<QMetaObject::Connection, QMetaObject::Connection>;
    QHash<QObject *, JointConnections> m_jointsConnections;
    QSet<QQuick3DNode *> m_dirtyJoints;
    QSet<QQuick3DNode *> m_removedJoints;
    int m_updatedByNewInverseBindPoses = 0;
};

QT_END_NAMESPACE

#endif // QSSGSKIN_H