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
qssgrendergeometry.cpp
Go to the documentation of this file.
1
// Copyright (C) 2019 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
#
include
"qssgrendergeometry_p.h"
7
#
include
"qssgrendermesh_p.h"
8
#
include
"resourcemanager/qssgrenderbuffermanager_p.h"
9
10
QSSGRenderGeometry::QSSGRenderGeometry()
11
: QSSGRenderGraphObject(QSSGRenderGraphObject::Type::Geometry, FlagT(Flags::HasGraphicsResources))
12
{
13
}
14
15
QSSGRenderGeometry::~QSSGRenderGeometry()
16
{
17
}
18
19
const
QByteArray &QSSGRenderGeometry::vertexBuffer()
const
20
{
21
return
m_meshData.m_vertexBuffer;
22
}
23
24
QByteArray &QSSGRenderGeometry::vertexBuffer()
25
{
26
return
m_meshData.m_vertexBuffer;
27
}
28
29
const
QByteArray &QSSGRenderGeometry::indexBuffer()
const
30
{
31
return
m_meshData.m_indexBuffer;
32
}
33
34
QByteArray &QSSGRenderGeometry::indexBuffer()
35
{
36
return
m_meshData.m_indexBuffer;
37
}
38
39
int
QSSGRenderGeometry::attributeCount()
const
40
{
41
return
m_meshData.m_attributeCount;
42
}
43
44
QVector3D QSSGRenderGeometry::boundsMin()
const
45
{
46
return
m_bounds.minimum;
47
}
48
49
QVector3D QSSGRenderGeometry::boundsMax()
const
50
{
51
return
m_bounds.maximum;
52
}
53
54
int
QSSGRenderGeometry::stride()
const
55
{
56
return
m_meshData.m_stride;
57
}
58
59
QSSGMesh::Mesh::DrawMode QSSGRenderGeometry::primitiveType()
const
60
{
61
return
m_meshData.m_primitiveType;
62
}
63
64
QSSGRenderGeometry::Attribute QSSGRenderGeometry::attribute(
int
idx)
const
65
{
66
Attribute attr;
67
const
auto
&mattr = m_meshData.m_attributes[idx];
68
attr.offset = mattr.offset;
69
attr.semantic = mattr.semantic;
70
attr.componentType = mattr.componentType;
71
return
attr;
72
}
73
74
void
QSSGRenderGeometry::addAttribute(QSSGMesh::RuntimeMeshData::Attribute::Semantic semantic,
75
int
offset,
76
QSSGMesh::Mesh::ComponentType componentType)
77
{
78
Attribute attr;
79
attr.semantic = semantic;
80
attr.offset = offset;
81
attr.componentType = componentType;
82
addAttribute(attr);
83
}
84
85
void
QSSGRenderGeometry::addAttribute(
const
Attribute &att)
86
{
87
const
int
index = m_meshData.m_attributeCount;
88
if
(index == QSSGMesh::RuntimeMeshData::MAX_ATTRIBUTES) {
89
qWarning(
"Maximum number (%d) of vertex attributes in custom geometry has been reached; ignoring extra attributes"
,
90
QSSGMesh::RuntimeMeshData::MAX_ATTRIBUTES);
91
return
;
92
}
93
m_meshData.m_attributes[index].semantic
94
=
static_cast
<QSSGMesh::RuntimeMeshData::Attribute::Semantic>(att.semantic);
95
m_meshData.m_attributes[index].offset = att.offset;
96
m_meshData.m_attributes[index].componentType = att.componentType;
97
++m_meshData.m_attributeCount;
98
markDirty();
99
}
100
101
void
QSSGRenderGeometry::addTargetAttribute(quint32 targetId,
102
QSSGMesh::RuntimeMeshData::Attribute::Semantic semantic,
103
int
offset,
104
int
stride)
105
{
106
TargetAttribute tAttr;
107
tAttr.targetId = targetId;
108
tAttr.attr.semantic = semantic;
109
tAttr.attr.offset = offset;
110
tAttr.stride = stride;
111
addTargetAttribute(tAttr);
112
}
113
114
void
QSSGRenderGeometry::addTargetAttribute(
const
TargetAttribute &att)
115
{
116
const
int
index = m_meshData.m_targetAttributeCount;
117
if
(index == QSSGMesh::RuntimeMeshData::MAX_TARGET_ATTRIBUTES) {
118
qWarning(
"Maximum number (%d) of morph target attributes in custom geometry has been reached; ignoring extra attributes"
,
119
QSSGMesh::RuntimeMeshData::MAX_TARGET_ATTRIBUTES);
120
return
;
121
}
122
m_meshData.m_targetAttributes[index].attr.semantic
123
=
static_cast
<QSSGMesh::RuntimeMeshData::Attribute::Semantic>(att.attr.semantic);
124
m_meshData.m_targetAttributes[index].attr.offset = att.attr.offset;
125
m_meshData.m_targetAttributes[index].targetId = att.targetId;
126
m_meshData.m_targetAttributes[index].stride = att.stride;
127
++m_meshData.m_targetAttributeCount;
128
markDirty();
129
}
130
131
void
QSSGRenderGeometry::addSubset(quint32 offset, quint32 count,
const
QVector3D &boundsMin,
const
QVector3D &boundsMax,
const
QString &name)
132
{
133
m_meshData.m_subsets.append({name, {boundsMin, boundsMax}, count, offset, {}, {}});
134
}
135
136
void
QSSGRenderGeometry::setStride(
int
stride)
137
{
138
m_meshData.m_stride = stride;
139
markDirty();
140
}
141
142
void
QSSGRenderGeometry::setPrimitiveType(QSSGMesh::Mesh::DrawMode type)
143
{
144
m_meshData.m_primitiveType = type;
145
markDirty();
146
}
147
148
void
QSSGRenderGeometry::setBounds(
const
QVector3D &min,
const
QVector3D &max)
149
{
150
m_bounds = QSSGBounds3(min, max);
151
markDirty();
152
}
153
154
void
QSSGRenderGeometry::clear()
155
{
156
m_meshData.clearVertexAndIndex();
157
m_meshData.clearTarget();
158
m_bounds.setEmpty();
159
markDirty();
160
}
161
162
void
QSSGRenderGeometry::clearVertexAndIndex()
163
{
164
m_meshData.clearVertexAndIndex();
165
m_bounds.setEmpty();
166
markDirty();
167
}
168
169
170
void
QSSGRenderGeometry::clearTarget()
171
{
172
m_meshData.clearTarget();
173
markDirty();
174
}
175
176
void
QSSGRenderGeometry::clearAttributes()
177
{
178
m_meshData.m_attributeCount = 0;
179
}
180
181
uint32_t QSSGRenderGeometry::generationId()
const
182
{
183
return
m_generationId;
184
}
185
186
const
QSSGMesh::RuntimeMeshData &QSSGRenderGeometry::meshData()
const
187
{
188
return
m_meshData;
189
}
190
191
void
QSSGRenderGeometry::setVertexData(
const
QByteArray &data)
192
{
193
m_meshData.m_vertexBuffer = data;
194
markDirty();
195
}
196
197
void
QSSGRenderGeometry::setIndexData(
const
QByteArray &data)
198
{
199
m_meshData.m_indexBuffer = data;
200
markDirty();
201
}
202
203
void
QSSGRenderGeometry::setTargetData(
const
QByteArray &data)
204
{
205
m_meshData.m_targetBuffer = data;
206
markDirty();
207
}
208
209
void
QSSGRenderGeometry::markDirty()
210
{
211
m_generationId++;
212
}
qtquick3d
src
runtimerender
graphobjects
qssgrendergeometry.cpp
Generated on
for Qt by
1.18.0