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
qssglightmapuvgenerator_p.h
Go to the documentation of this file.
1
// Copyright (C) 2021 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
QSSGLIGHTMAPUVGENERATOR_P_H
7
#
define
QSSGLIGHTMAPUVGENERATOR_P_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
/
qssgmesh_p
.
h
>
21
22
QT_BEGIN_NAMESPACE
23
24
struct
QSSGLightmapUVGeneratorResult
25
{
26
QByteArray lightmapUVChannel;
27
QVector<quint32> vertexMap;
28
QByteArray indexData;
29
quint32 lightmapWidth = 0;
30
quint32 lightmapHeight = 0;
31
32
bool
isValid()
const
{
33
return
!lightmapUVChannel.isEmpty() && !vertexMap.isEmpty();
34
}
35
};
36
37
class
Q_QUICK3DUTILS_EXPORT
QSSGLightmapUVGenerator
38
{
39
public
:
40
// Takes in position, normals, UV0, indices and returns a new lightmap UV
41
// channel, new index data, and a mapping to original vertices.
42
//
43
// The topology must be triangles. The position data is expected to contain
44
// 3 component float positions. normals is expected to contain 3 component
45
// float normal vectors. uv0 is expected to contain 2 component float UV
46
// coordinates. When not available, normals and uv0 can be left empty.
47
//
48
// The resulting index data has always the same number of indices as the
49
// original, but regardless of the original component type, the new data
50
// always has a component type of uint32.
51
//
52
// The resulting lightmapUVChannel contains 2 component floats. There can
53
// be more lightmap UVs than input positions, because the unwrapping
54
// process may add extra vertices to avoid seams. The new vertices always
55
// correspond to an original vertex. That is why the result also has a list
56
// that has one element for each UV in the lightmap UV data, the value
57
// being an index of a vertex in the original position channel. This
58
// mapping must be used by the caller to grow and rewrite all vertex input
59
// data (position, normals, UVs, etc.) so that the count of their elements
60
// matches the lightmap UV channel.
61
//
62
// texelsPerUnit
63
// Unit to texel scale. e.g. a 1x1 quad with texelsPerUnit of 32 will take
64
// up approximately 32x32 texels in the atlas.
65
//
66
QSSGLightmapUVGeneratorResult run(
const
QByteArray &positions,
67
const
QByteArray &normals,
68
const
QByteArray &uv0,
69
const
QByteArray &index,
70
QSSGMesh::Mesh::ComponentType indexComponentType,
71
float
texelsPerUnit);
72
73
// source is of N elements of componentCount * sizeof(T) bytes each. The
74
// returned data is M elements of componentCount * sizeof(T) bytes each, where
75
// M >= N. vertexMap is the mapping table with M elements where each element
76
// is an index in range [0, N-1].
77
template
<
typename
T>
78
static
QByteArray remap(
const
QByteArray &source,
const
QVector<quint32> &vertexMap,
int
componentCount)
79
{
80
if
(source.isEmpty())
81
return
QByteArray();
82
const
T *src =
reinterpret_cast
<
const
T *>(source.constData());
83
const
int
byteStride =
sizeof
(T) * componentCount;
84
QByteArray result(vertexMap.size() * byteStride, Qt::Uninitialized);
85
T *dst =
reinterpret_cast
<T *>(result.data());
86
for
(
int
i = 0, count = vertexMap.size(); i != count; ++i) {
87
const
quint32 originalVertexIndex = vertexMap[i];
88
for
(
int
j = 0; j < componentCount; ++j)
89
*dst++ = src[originalVertexIndex * componentCount + j];
90
}
91
return
result;
92
}
93
};
94
95
QT_END_NAMESPACE
96
97
#
endif
// QSSGLIGHTMAPUVGENERATOR_P_H
QSSGLightmapUVGenerator
Definition
qssglightmapuvgenerator_p.h:38
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtquick3d
src
utils
qssglightmapuvgenerator_p.h
Generated on
for Qt by
1.18.0