| 1 | // Copyright (C) 2022 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QSSGSKIN_H |
| 5 | #define QSSGSKIN_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QtQuick3D/qquick3dobject.h> |
| 19 | #include <QtQuick3D/private/qquick3dnode_p.h> |
| 20 | #include <QtCore/qlist.h> |
| 21 | #include <QtCore/qhash.h> |
| 22 | |
| 23 | QT_BEGIN_NAMESPACE |
| 24 | |
| 25 | class Q_QUICK3D_EXPORT QQuick3DSkin : public QQuick3DObject |
| 26 | { |
| 27 | Q_OBJECT |
| 28 | Q_PROPERTY(QQmlListProperty<QQuick3DNode> joints READ joints) |
| 29 | Q_PROPERTY(QList<QMatrix4x4> inverseBindPoses READ inverseBindPoses WRITE setInverseBindPoses NOTIFY inverseBindPosesChanged) |
| 30 | |
| 31 | QML_NAMED_ELEMENT(Skin) |
| 32 | |
| 33 | public: |
| 34 | explicit QQuick3DSkin(QQuick3DObject *parent = nullptr); |
| 35 | ~QQuick3DSkin() override; |
| 36 | |
| 37 | QQmlListProperty<QQuick3DNode> joints(); |
| 38 | QList<QMatrix4x4> inverseBindPoses() const; |
| 39 | |
| 40 | public Q_SLOTS: |
| 41 | void setInverseBindPoses(const QList<QMatrix4x4> &poses); |
| 42 | |
| 43 | Q_SIGNALS: |
| 44 | void inverseBindPosesChanged(); |
| 45 | |
| 46 | private: |
| 47 | static void qmlAppendJoint(QQmlListProperty<QQuick3DNode> *list, QQuick3DNode *joint); |
| 48 | static QQuick3DNode *qmlJointAt(QQmlListProperty<QQuick3DNode> *list, qsizetype index); |
| 49 | static qsizetype qmlJointsCount(QQmlListProperty<QQuick3DNode> *list); |
| 50 | static void qmlClearJoints(QQmlListProperty<QQuick3DNode> *list); |
| 51 | |
| 52 | QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override; |
| 53 | |
| 54 | QVector<QQuick3DNode *> m_joints; |
| 55 | QByteArray m_boneData; |
| 56 | QList<QMatrix4x4> m_inverseBindPoses; |
| 57 | using JointConnections = std::pair<QMetaObject::Connection, QMetaObject::Connection>; |
| 58 | QHash<QObject *, JointConnections> m_jointsConnections; |
| 59 | QSet<QQuick3DNode *> m_dirtyJoints; |
| 60 | QSet<QQuick3DNode *> m_removedJoints; |
| 61 | int m_updatedByNewInverseBindPoses = 0; |
| 62 | }; |
| 63 | |
| 64 | QT_END_NAMESPACE |
| 65 | |
| 66 | #endif // QSSGSKIN_H |
| 67 |
