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
qssgdebugdrawsystem_p.h
Go to the documentation of this file.
1// Copyright (C) 2022 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 QSSGDEBUGDRAWSYSTEM_H
7#define QSSGDEBUGDRAWSYSTEM_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 <QtQuick3DRuntimeRender/private/qtquick3druntimerenderglobal_p.h>
21#include <QtQuick3DRuntimeRender/private/qssgrhicontext_p.h>
22#include <QtQuick3DUtils/private/qssgbounds3_p.h>
23#include <QtGui/QVector3D>
24#include <QtGui/QColor>
25
27
28struct QSSGRenderSubset;
29class QSSGBufferManager;
30class QSSGModelContext;
31
32class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGDebugDrawSystem
33{
34 Q_DISABLE_COPY(QSSGDebugDrawSystem)
35public:
36 QSSGDebugDrawSystem();
37 ~QSSGDebugDrawSystem();
38
39 bool hasContent() const;
40
41 void drawLine(const QVector3D &startPoint,
42 const QVector3D &endPoint,
43 const QColor &color,
44 bool isPersistent = false);
45 void drawBounds(const QSSGBounds3 &bounds,
46 const QColor &color,
47 bool isPersistent = false);
48 void drawPoint(const QVector3D &vertex,
49 const QColor &color,
50 bool isPersistent = false);
51
52 void prepareGeometry(QSSGRhiContext *rhiCtx, QRhiResourceUpdateBatch *rub);
53 void recordRenderDebugObjects(QSSGRhiContext *rhiCtx,
54 QSSGRhiGraphicsPipelineState *ps,
55 QRhiShaderResourceBindings *srb,
56 QRhiRenderPassDescriptor *rpDesc);
57
58 void setEnabled(bool v);
59 [[nodiscard]] bool isEnabled() const { return Mode(modes) != Mode::None; }
60
61private:
62 friend class QSSGLayerRenderData;
63
64 enum class Mode : quint8
65 {
66 None,
67 MeshLod = 0x1,
68 MeshLodNormal = 0x2,
69 Other = 0x4
70 };
71 using ModeFlagT = std::underlying_type_t<Mode>;
72
73 struct LineData {
74 QVector3D startPoint;
75 QVector3D endPoint;
76 QColor color;
77 };
78 struct BoundsData {
79 QSSGBounds3 bounds;
80 QColor color;
81 };
82 struct VertexData {
83 QVector3D position;
84 QVector3D color;
85 };
86
87
88 void generateLine(const LineData &line, QVector<VertexData> &vertexArray, QVector<quint32> &indexArray);
89 void generateBox(const BoundsData &bounds, QVector<VertexData> &vertexArray, QVector<quint32> &indexArray);
90
91 // Internal helper functions
92 [[nodiscard]] bool isEnabled(Mode mode) const { return ((ModeFlagT(mode) & modes) != 0); }
93 [[nodiscard]] static QColor levelOfDetailColor(quint32 lod);
94 void debugNormals(QSSGBufferManager &bufferManager, const QSSGModelContext &theModelContext, const QSSGRenderSubset &theSubset, quint32 subsetLevelOfDetail, float lineLength);
95
96 quint32 m_indexSize = 0;
97 quint32 m_pointsSize = 0;
98 QVector<LineData> m_persistentLines;
99 QVector<LineData> m_lines;
100 QVector<BoundsData> m_persistentBounds;
101 QVector<BoundsData> m_bounds;
102 QVector<VertexData> m_persistentPoints;
103 QVector<VertexData> m_points;
104
105 QSSGRhiBufferPtr m_lineVertexBuffer;
106 QSSGRhiBufferPtr m_lineIndexBuffer;
107 QSSGRhiBufferPtr m_pointVertexBuffer;
108
109 ModeFlagT modes { 0 };
110};
111
112QT_END_NAMESPACE
113
114#endif // QSSGDEBUGDRAWSYSTEM_H
void drawLine(const QVector3D &startPoint, const QVector3D &endPoint, const QColor &color, bool isPersistent=false)
void recordRenderDebugObjects(QSSGRhiContext *rhiCtx, QSSGRhiGraphicsPipelineState *ps, QRhiShaderResourceBindings *srb, QRhiRenderPassDescriptor *rpDesc)
void drawPoint(const QVector3D &vertex, const QColor &color, bool isPersistent=false)
void prepareGeometry(QSSGRhiContext *rhiCtx, QRhiResourceUpdateBatch *rub)
void drawBounds(const QSSGBounds3 &bounds, const QColor &color, bool isPersistent=false)
Combined button and popup list for selecting options.