Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
4#ifndef QSSGDEBUGDRAWSYSTEM_H
5#define QSSGDEBUGDRAWSYSTEM_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQuick3DRuntimeRender/private/qtquick3druntimerenderglobal_p.h>
19#include <QtQuick3DRuntimeRender/private/qssgrhicontext_p.h>
20#include <QtQuick3DUtils/private/qssgbounds3_p.h>
21#include <QtGui/QVector3D>
22#include <QtGui/QColor>
23
25
26struct QSSGRenderSubset;
28struct QSSGModelContext;
29
30class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGDebugDrawSystem
31{
32 Q_DISABLE_COPY(QSSGDebugDrawSystem)
33public:
36
37 bool hasContent() const;
38
39 void drawLine(const QVector3D &startPoint,
40 const QVector3D &endPoint,
41 const QColor &color,
42 bool isPersistent = false);
43 void drawBounds(const QSSGBounds3 &bounds,
44 const QColor &color,
45 bool isPersistent = false);
46 void drawPoint(const QVector3D &vertex,
47 const QColor &color,
48 bool isPersistent = false);
49
50 void prepareGeometry(QSSGRhiContext *rhiCtx, QRhiResourceUpdateBatch *rub);
51 void recordRenderDebugObjects(QSSGRhiContext *rhiCtx,
55
56 void setEnabled(bool v);
57 [[nodiscard]] bool isEnabled() const { return Mode(modes) != Mode::None; }
58
59private:
60 friend class QSSGLayerRenderData;
61
62 enum class Mode : quint8
63 {
64 None,
65 MeshLod = 0x1,
66 MeshLodNormal = 0x2,
67 Other = 0x4
68 };
69 using ModeFlagT = std::underlying_type_t<Mode>;
70
71 struct LineData {
72 QVector3D startPoint;
73 QVector3D endPoint;
75 };
76 struct BoundsData {
77 QSSGBounds3 bounds;
79 };
80 struct VertexData {
83 };
84
85
86 void generateLine(const LineData &line, QVector<VertexData> &vertexArray, QVector<quint32> &indexArray);
87 void generateBox(const BoundsData &bounds, QVector<VertexData> &vertexArray, QVector<quint32> &indexArray);
88
89 // Internal helper functions
90 [[nodiscard]] bool isEnabled(Mode mode) const { return ((ModeFlagT(mode) & modes) != 0); }
91 [[nodiscard]] static QColor levelOfDetailColor(quint32 lod);
92 void debugNormals(QSSGBufferManager &bufferManager, const QSSGModelContext &theModelContext, const QSSGRenderSubset &theSubset, quint32 subsetLevelOfDetail, float lineLength);
93
94 quint32 m_indexSize = 0;
95 quint32 m_pointsSize = 0;
96 QVector<LineData> m_persistentLines;
97 QVector<LineData> m_lines;
98 QVector<BoundsData> m_persistentBounds;
99 QVector<BoundsData> m_bounds;
100 QVector<VertexData> m_persistentPoints;
101 QVector<VertexData> m_points;
102
103 QSSGRhiBufferPtr m_lineVertexBuffer;
104 QSSGRhiBufferPtr m_lineIndexBuffer;
105 QSSGRhiBufferPtr m_pointVertexBuffer;
106
107 ModeFlagT modes { 0 };
108};
109
111
112#endif // QSSGDEBUGDRAWSYSTEM_H
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\inmodule QtGui
Definition qrhi.h:1142
\inmodule QtGui
Definition qrhi.h:1731
\inmodule QtGui
Definition qrhi.h:1214
Class representing 3D range or axis aligned bounding box.
\inmodule QtQuick3D
The QVector3D class represents a vector or vertex in 3D space.
Definition qvectornd.h:171
Combined button and popup list for selecting options.
bool isEnabled()
static bool drawLine(QCosmeticStroker *stroker, qreal x1, qreal y1, qreal x2, qreal y2, int caps)
@ None
Definition qhash.cpp:531
GLsizei const GLfloat * v
[13]
GLenum mode
GLuint color
[2]
GLint lod
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
std::shared_ptr< QSSGRhiBuffer > QSSGRhiBufferPtr
unsigned int quint32
Definition qtypes.h:50
unsigned char quint8
Definition qtypes.h:46