Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qphysicsmeshutils_p_p.h
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QPHYSICSMESHUTILS_P_P_H
6#define QPHYSICSMESHUTILS_P_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtQuick3DPhysics/qtquick3dphysicsglobal.h>
20#include <QtGui/QVector3D>
21#include <QtQuick3DUtils/private/qssgmesh_p.h>
22
23namespace physx {
24class PxBoxGeometry;
25class PxConvexMesh;
26class PxConvexMeshGeometry;
27class PxTriangleMesh;
28}
29
30QT_BEGIN_NAMESPACE
31
32class QQuick3DGeometry;
33
35{
36public:
37 QQuick3DPhysicsMesh(const QString &qmlSource) : m_meshPath(qmlSource) { }
38 QQuick3DPhysicsMesh(const QQuick3DGeometry *geometrySource) : m_meshGeometry(geometrySource) { }
40
42
44 {
45 loadSsgMesh();
46 if (m_ssgMesh.isValid()) {
47 auto b = m_ssgMesh.subsets().constFirst().bounds;
48 return { b.min, b.max };
49 }
50 return {};
51 }
52
53 void ref() { ++refCount; }
54 int deref() { return --refCount; }
55
56 physx::PxConvexMesh *convexMesh();
57 physx::PxTriangleMesh *triangleMesh();
58
60
61private:
62 void loadSsgMesh();
63 physx::PxConvexMesh *convexMeshQmlSource();
64 physx::PxConvexMesh *convexMeshGeometrySource();
65 physx::PxTriangleMesh *triangleMeshQmlSource();
66 physx::PxTriangleMesh *triangleMeshGeometrySource();
67
68 QString m_meshPath;
69 const QQuick3DGeometry *m_meshGeometry = nullptr;
70 QSSGMesh::Mesh m_ssgMesh;
71 int m_posOffset = 0;
72
73 physx::PxConvexMesh *m_convexMesh = nullptr;
74 physx::PxTriangleMesh *m_triangleMesh = nullptr;
75 int refCount = 0;
76};
77
79{
80public:
81 static QQuick3DPhysicsMesh *getMesh(const QUrl &source, QObject *contextObject);
82 static QQuick3DPhysicsMesh *getMesh(QQuick3DGeometry *source);
83 static void releaseMesh(QQuick3DPhysicsMesh *mesh);
84
85private:
86 static QHash<QString, QQuick3DPhysicsMesh *> sourceMeshHash;
87 static QHash<QQuick3DGeometry *, QQuick3DPhysicsMesh *> geometryMeshHash;
88};
89
90QT_END_NAMESPACE
91
92#endif // QPHYSICSMESHUTILS_P_P_H
static void releaseMesh(QQuick3DPhysicsMesh *mesh)
static QQuick3DPhysicsMesh * getMesh(const QUrl &source, QObject *contextObject)
static QQuick3DPhysicsMesh * getMesh(QQuick3DGeometry *source)
QQuick3DPhysicsMesh(const QQuick3DGeometry *geometrySource)
QQuick3DPhysicsMesh(const QString &qmlSource)
physx::PxTriangleMesh * triangleMesh()
QList< QVector3D > positions()
physx::PxConvexMesh * convexMesh()
QPair< QVector3D, QVector3D > bounds()
void writeCachedConvexMesh(const QString &filePath, physx::PxDefaultMemoryOutputStream &buf)
void writeCachedTriangleMesh(const QString &filePath, physx::PxDefaultMemoryOutputStream &buf)
Combined button and popup list for selecting options.
static QT_BEGIN_NAMESPACE QQuick3DGeometry::Attribute attributeBySemantic(const QQuick3DGeometry *geometry, QQuick3DGeometry::Attribute::Semantic semantic)