1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef QSSGDEBUGDRAWSYSTEM_H
#define QSSGDEBUGDRAWSYSTEM_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtQuick3DRuntimeRender/private/qtquick3druntimerenderglobal_p.h>
#include <QtQuick3DRuntimeRender/private/qssgrhicontext_p.h>
#include <QtQuick3DUtils/private/qssgbounds3_p.h>
#include <QtGui/QVector3D>
#include <QtGui/QColor>
QT_BEGIN_NAMESPACE
struct QSSGRenderSubset;
class QSSGBufferManager;
class QSSGModelContext;
class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGDebugDrawSystem
{
Q_DISABLE_COPY(QSSGDebugDrawSystem)
public:
QSSGDebugDrawSystem();
~QSSGDebugDrawSystem();
bool hasContent() const;
void drawLine(const QVector3D &startPoint,
const QVector3D &endPoint,
const QColor &color,
bool isPersistent = false);
void drawBounds(const QSSGBounds3 &bounds,
const QColor &color,
bool isPersistent = false);
void drawPoint(const QVector3D &vertex,
const QColor &color,
bool isPersistent = false);
void prepareGeometry(QSSGRhiContext *rhiCtx, QRhiResourceUpdateBatch *rub);
void recordRenderDebugObjects(QSSGRhiContext *rhiCtx,
QSSGRhiGraphicsPipelineState *ps,
QRhiShaderResourceBindings *srb,
QRhiRenderPassDescriptor *rpDesc);
void setEnabled(bool v);
[[nodiscard]] bool isEnabled() const { return Mode(modes) != Mode::None; }
private:
friend class QSSGLayerRenderData;
enum class Mode : quint8
{
None,
MeshLod = 0x1,
MeshLodNormal = 0x2,
Other = 0x4
};
using ModeFlagT = std::underlying_type_t<Mode>;
struct LineData {
QVector3D startPoint;
QVector3D endPoint;
QColor color;
};
struct BoundsData {
QSSGBounds3 bounds;
QColor color;
};
struct VertexData {
QVector3D position;
QVector3D color;
};
void generateLine(const LineData &line, QVector<VertexData> &vertexArray, QVector<quint32> &indexArray);
void generateBox(const BoundsData &bounds, QVector<VertexData> &vertexArray, QVector<quint32> &indexArray);
// Internal helper functions
[[nodiscard]] bool isEnabled(Mode mode) const { return ((ModeFlagT(mode) & modes) != 0); }
[[nodiscard]] static QColor levelOfDetailColor(quint32 lod);
void debugNormals(QSSGBufferManager &bufferManager, const QSSGModelContext &theModelContext, const QSSGRenderSubset &theSubset, quint32 subsetLevelOfDetail, float lineLength);
quint32 m_indexSize = 0;
quint32 m_pointsSize = 0;
QVector<LineData> m_persistentLines;
QVector<LineData> m_lines;
QVector<BoundsData> m_persistentBounds;
QVector<BoundsData> m_bounds;
QVector<VertexData> m_persistentPoints;
QVector<VertexData> m_points;
QSSGRhiBufferPtr m_lineVertexBuffer;
QSSGRhiBufferPtr m_lineIndexBuffer;
QSSGRhiBufferPtr m_pointVertexBuffer;
ModeFlagT modes { 0 };
};
QT_END_NAMESPACE
#endif // QSSGDEBUGDRAWSYSTEM_H
|