Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qssgmeshbvh_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
// Qt-Security score:significant reason:default
4
5
6
#
ifndef
QSSGMESHBVH_H
7
#
define
QSSGMESHBVH_H
8
9
//
10
// W A R N I N G
11
// -------------
12
//
13
// This file is not part of the Qt API. It exists purely as an
14
// implementation detail. This header file may change from version to
15
// version without notice, or even be removed.
16
//
17
// We mean it.
18
//
19
20
#
include
<
QtQuick3DUtils
/
private
/
qtquick3dutilsglobal_p
.
h
>
21
#
include
<
QtQuick3DUtils
/
private
/
qssgbounds3_p
.
h
>
22
#
include
<
QtQuick3DUtils
/
private
/
qssgassert_p
.
h
>
23
24
#
include
<
QtGui
/
QVector2D
>
25
#
include
<
QtCore
/
QVector
>
26
27
QT_BEGIN_NAMESPACE
28
29
class
QSSGMeshBVH;
30
31
class
Q_QUICK3DUTILS_EXPORT
QSSGMeshBVHNode
32
{
33
public
:
34
class
Handle
35
{
36
public
:
37
Handle() =
default
;
38
bool
isNull()
const
{
return
!m_owner || m_idx < size_t(FallbackIndex::Count); }
39
40
inline
explicit
operator
const
QSSGMeshBVHNode *()
const
;
41
inline
QSSGMeshBVHNode *operator->()
const
;
42
private
:
43
friend
class
QSSGMeshBVH;
44
Handle(QSSGMeshBVH *owner, size_t idx)
45
: m_owner(owner)
46
, m_idx(idx)
47
{}
48
QSSGMeshBVH *m_owner =
nullptr
;
49
size_t m_idx = 0;
50
};
51
52
// Internal
53
Handle left;
54
Handle right;
55
QSSGBounds3 boundingData;
56
//splitAxis
57
58
// Leaf
59
int
offset = 0;
60
int
count = 0;
61
62
private
:
63
friend
class
QSSGMeshBVH;
64
friend
class
QSSGMeshBVHBuilder;
65
66
enum
class
FallbackIndex : quint8
67
{
68
InvalidRead = 0,
69
InvalidWrite = 1,
70
Count
71
};
72
};
73
74
struct
Q_QUICK3DUTILS_EXPORT
QSSGMeshBVHTriangle
75
{
76
QSSGBounds3 bounds;
77
QVector3D vertex1;
78
QVector3D vertex2;
79
QVector3D vertex3;
80
QVector2D uvCoord1;
81
QVector2D uvCoord2;
82
QVector2D uvCoord3;
83
};
84
85
using
QSSGMeshBVHTriangles = std::vector<QSSGMeshBVHTriangle>;
86
using
QSSGMeshBVHRoots = std::vector<QSSGMeshBVHNode::Handle>;
87
using
QSSGMeshBVHNodes = std::vector<QSSGMeshBVHNode>;
88
89
class
Q_QUICK3DUTILS_EXPORT
QSSGMeshBVH
90
{
91
public
:
92
QSSGMeshBVH() =
default
;
93
~QSSGMeshBVH();
94
95
[[nodiscard]] QSSGMeshBVHNode::Handle newHandle()
96
{
97
m_nodes.emplace_back();
98
return
{
this
, m_nodes.size() - 1 };
99
}
100
101
[[nodiscard]]
const
QSSGMeshBVHTriangles &triangles()
const
{
return
m_triangles; }
102
[[nodiscard]]
const
QSSGMeshBVHRoots &roots()
const
{
return
m_roots; }
103
[[nodiscard]]
const
QSSGMeshBVHNodes &nodes()
const
{
return
m_nodes; }
104
105
private
:
106
friend
class
QSSGMeshBVHNode::Handle;
107
friend
class
QSSGMeshBVHBuilder;
108
using
FallbackIndex = QSSGMeshBVHNode::FallbackIndex;
109
size_t getNodeIndex(size_t idx, FallbackIndex op)
const
110
{
111
const
bool
valid = (idx >= size_t(FallbackIndex::Count) && idx < m_nodes.size());
112
return
(valid * idx) + (!valid * size_t(op));
113
}
114
115
QSSGMeshBVHNode &mutableValue(qsizetype idx)
116
{
117
return
m_nodes[getNodeIndex(idx, FallbackIndex::InvalidWrite)];
118
}
119
120
const
QSSGMeshBVHNode &value(qsizetype idx)
const
121
{
122
return
m_nodes[getNodeIndex(idx, FallbackIndex::InvalidRead)];
123
}
124
125
QSSGMeshBVHRoots m_roots;
126
QSSGMeshBVHNodes m_nodes { {
/* 0 - reserved for invalid reads */
}, {
/* 1 - reserved for invalid writes */
} };
127
QSSGMeshBVHTriangles m_triangles;
128
};
129
130
QSSGMeshBVHNode::Handle::operator
const
QSSGMeshBVHNode *()
const
131
{
132
return
&m_owner->value(m_idx);
133
}
134
135
QSSGMeshBVHNode *QSSGMeshBVHNode::Handle::operator->()
const
136
{
137
return
&m_owner->mutableValue(m_idx);
138
}
139
140
QT_END_NAMESPACE
141
142
#
endif
// QSSGMESHBVH_H
QSSGMeshBVHNode
Definition
qssgmeshbvh_p.h:32
QSSGMeshBVH
Definition
qssgmeshbvh_p.h:90
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
QSSGMeshBVHTriangle
Definition
qssgmeshbvh_p.h:75
qtquick3d
src
utils
qssgmeshbvh_p.h
Generated on
for Qt by
1.18.0