Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qssgmeshbvhbuilder_p.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QSSGMESHBVHBUILDER_H
5#define QSSGMESHBVHBUILDER_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#include <QtQuick3DUtils/private/qtquick3dutilsglobal_p.h>
18#include <QtQuick3DUtils/private/qssgmeshbvh_p.h>
19#include <QtQuick3DUtils/private/qssgmesh_p.h>
20
22
23class Q_QUICK3DUTILS_EXPORT QSSGMeshBVHBuilder
24{
25public:
27 QSSGMeshBVHBuilder(const QByteArray &vertexBuffer,
28 int stride,
29 int posOffset,
30 bool hasUV = false,
31 int uvOffset = -1,
32 bool hasIndexBuffer = false,
33 const QByteArray &indexBuffer = QByteArray(),
35
36 QSSGMeshBVH* buildTree();
37
38private:
39 enum class Axis
40 {
41 None = -1,
42 X = 0,
43 Y = 1,
44 Z = 2
45 };
46 struct Split {
47 Axis axis;
48 float pos;
49 };
50
51 QVector<QSSGMeshBVHTriangle*> calculateTriangleBounds(quint32 indexOffset, quint32 indexCount) const;
52 quint32 getIndexBufferValue(quint32 index) const;
53 QVector3D getVertexBufferValuePosition(quint32 index) const;
54 QVector2D getVertexBufferValueUV(quint32 index) const;
55
58 Split getOptimalSplit(const QSSGBounds3 &nodeBounds, quint32 offset, quint32 count) const;
59 static Axis getLongestDimension(const QSSGBounds3 &nodeBounds);
60 float getAverageValue(quint32 offset, quint32 count, Axis axis) const;
61 quint32 partition(quint32 offset, quint32 count, const Split &split);
62
63 QSSGMesh::Mesh m_mesh;
64 QSSGRenderComponentType m_indexBufferComponentType;
65 QByteArray m_indexBufferData;
66 QByteArray m_vertexBufferData;
67 quint32 m_vertexStride;
68 bool m_hasPositionData = false;
69 quint32 m_vertexPosOffset;
70 bool m_hasUVData = false;
71 quint32 m_vertexUVOffset;
72 bool m_hasIndexBuffer = true;
73
74
75 QVector<QSSGMeshBVHTriangle *> m_triangleBounds;
77 quint32 m_maxTreeDepth = 40;
78 quint32 m_maxLeafTriangles = 10;
79};
80
82
83#endif // QSSGMESHBVHBUILDER_H
\inmodule QtCore
Definition qbytearray.h:57
Definition qlist.h:74
Class representing 3D range or axis aligned bounding box.
The QVector2D class represents a vector or vertex in 2D space.
Definition qvectornd.h:31
The QVector3D class represents a vector or vertex in 3D space.
Definition qvectornd.h:171
Combined button and popup list for selecting options.
@ Split
Definition qbezier.cpp:277
static void getBounds(const QList< TTF_POINT > &points, qint16 *xmin, qint16 *xmax, qint16 *ymin, qint16 *ymax)
GLint GLenum GLsizei GLsizei GLsizei depth
GLuint index
[2]
GLenum GLenum GLsizei count
const void GLsizei GLsizei stride
GLenum GLuint GLintptr offset
#define X(name)
static void split(QT_FT_Vector *b)
QSSGRenderComponentType
unsigned int quint32
Definition qtypes.h:45