Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qcollisiondebugmeshbuilder.cpp
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
6
8
9QCollisionDebugMeshBuilder::QCollisionDebugMeshBuilder() { }
10
11void QCollisionDebugMeshBuilder::reset()
12{
13 m_vertices.clear();
14 m_normals.clear();
15}
16
17void QCollisionDebugMeshBuilder::addLine(const QVector3D &start, const QVector3D &end,
18 const QVector3D &normal)
19{
20 m_vertices.append(start);
21 m_vertices.append(end);
22 m_normals.append(normal);
23}
24
25QByteArray QCollisionDebugMeshBuilder::generateVertexArray()
26{
27 QByteArray output;
28 const int size = m_normals.count();
29 output.resize(4 * 4 * sizeof(float) * size);
30
31 float *data = reinterpret_cast<float *>(output.data());
32
33 for (int i = 0; i < size; ++i) {
34 const QVector3D &start = m_vertices[i * 2];
35 const QVector3D &end = m_vertices[i * 2 + 1];
36 const QVector3D &normal = m_normals[i];
37
38 data[0] = start.x();
39 data[1] = start.y();
40 data[2] = start.z();
41 data[4] = 1.0f;
42
43 data[5] = normal.x();
44 data[6] = normal.y();
45 data[7] = normal.z();
46 data[8] = 0.0f;
47
48 data += 8;
49 data[0] = end.x();
50 data[1] = end.y();
51 data[2] = end.z();
52 data[4] = 1.0f;
53
54 data[5] = normal.x();
55 data[6] = normal.y();
56 data[7] = normal.z();
57 data[8] = 0.0f;
58
59 data += 8;
60 }
61
62 return output;
63}
64
65QT_END_NAMESPACE
Combined button and popup list for selecting options.