1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef TRIANGLEMESHSHAPE_H
5#define TRIANGLEMESHSHAPE_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 <QtQuick3DPhysics/qtquick3dphysicsglobal.h>
19#include <QtQuick3DPhysics/private/qabstractcollisionshape_p.h>
20#include <QtCore/QObject>
21#include <QtGui/QVector3D>
22#include <QtQml/QQmlEngine>
23
24namespace physx {
25class PxBoxGeometry;
26class PxTriangleMesh;
27class PxTriangleMeshGeometry;
28}
29
30QT_BEGIN_NAMESPACE
31class QQuick3DPhysicsMesh;
32
33class Q_QUICK3DPHYSICS_EXPORT QTriangleMeshShape : public QAbstractCollisionShape
34{
35 Q_OBJECT
36 Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged REVISION(6, 5))
37
38 QML_NAMED_ELEMENT(TriangleMeshShape)
39public:
40 QTriangleMeshShape();
41 ~QTriangleMeshShape();
42
43 physx::PxGeometry *getPhysXGeometry() override;
44 Q_REVISION(6, 5) const QUrl &source() const;
45 Q_REVISION(6, 5) void setSource(const QUrl &newSource);
46 bool isStaticShape() const override { return true; }
47
48signals:
49 Q_REVISION(6, 5) void sourceChanged();
50
51private:
52 void updatePhysXGeometry();
53
54 bool m_dirtyPhysx = false;
55 QUrl m_meshSource;
56 QQuick3DPhysicsMesh *m_mesh = nullptr;
57
58 physx::PxTriangleMeshGeometry *m_meshGeometry = nullptr;
59};
60
61QT_END_NAMESPACE
62
63#endif // TRIANGLEMESHSHAPE_H
64

source code of qtquick3dphysics/src/quick3dphysics/qtrianglemeshshape_p.h