Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
4#ifndef QPHYSICSMESHUTILS_P_P_H
5#define QPHYSICSMESHUTILS_P_P_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 <QtGui/QVector3D>
20#include <QtQuick3DUtils/private/qssgmesh_p.h>
21
22namespace physx {
23class PxBoxGeometry;
24class PxConvexMesh;
25class PxConvexMeshGeometry;
26class PxTriangleMesh;
27}
28
30
32
34{
35public:
36 QQuick3DPhysicsMesh(const QString &qmlSource) : m_meshPath(qmlSource) { }
37 QQuick3DPhysicsMesh(const QQuick3DGeometry *geometrySource) : m_meshGeometry(geometrySource) { }
39
40 QList<QVector3D> positions();
41
42 QPair<QVector3D, QVector3D> bounds()
43 {
44 loadSsgMesh();
45 if (m_ssgMesh.isValid()) {
46 auto b = m_ssgMesh.subsets().constFirst().bounds;
47 return { b.min, b.max };
48 }
49 return {};
50 }
51
52 void ref() { ++refCount; }
53 int deref() { return --refCount; }
54
55 physx::PxConvexMesh *convexMesh();
56 physx::PxTriangleMesh *triangleMesh();
57
59
60private:
61 void loadSsgMesh();
62 physx::PxConvexMesh *convexMeshQmlSource();
63 physx::PxConvexMesh *convexMeshGeometrySource();
64 physx::PxTriangleMesh *triangleMeshQmlSource();
65 physx::PxTriangleMesh *triangleMeshGeometrySource();
66
67 QString m_meshPath;
68 const QQuick3DGeometry *m_meshGeometry = nullptr;
69 QSSGMesh::Mesh m_ssgMesh;
70 int m_posOffset = 0;
71
72 physx::PxConvexMesh *m_convexMesh = nullptr;
73 physx::PxTriangleMesh *m_triangleMesh = nullptr;
74 int refCount = 0;
75};
76
78{
79public:
80 static QQuick3DPhysicsMesh *getMesh(const QUrl &source, const QObject *contextObject);
82 static void releaseMesh(QQuick3DPhysicsMesh *mesh);
83
84private:
85 static QHash<QString, QQuick3DPhysicsMesh *> sourceMeshHash;
86 static QHash<QQuick3DGeometry *, QQuick3DPhysicsMesh *> geometryMeshHash;
87};
88
90
91#endif // QPHYSICSMESHUTILS_P_P_H
\inmodule QtCore
Definition qobject.h:103
\qmltype Geometry \inherits Object3D \inqmlmodule QtQuick3D \instantiates QQuick3DGeometry
static void releaseMesh(QQuick3DPhysicsMesh *mesh)
static QQuick3DPhysicsMesh * getMesh(const QUrl &source, const QObject *contextObject)
QQuick3DPhysicsMesh(const QQuick3DGeometry *geometrySource)
QQuick3DPhysicsMesh(const QString &qmlSource)
physx::PxTriangleMesh * triangleMesh()
QList< QVector3D > positions()
physx::PxConvexMesh * convexMesh()
QPair< QVector3D, QVector3D > bounds()
bool isValid() const
Definition qssgmesh_p.h:159
QVector< Subset > subsets() const
Definition qssgmesh_p.h:143
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qurl.h:94
Combined button and popup list for selecting options.
GLboolean GLboolean GLboolean b
GLsizei GLsizei GLchar * source