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
qssgrenderparticles_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 QSSG_RENDER_PARTICLES_H
7#define QSSG_RENDER_PARTICLES_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/qssgrendernode_p.h>
21#include <QtQuick3DRuntimeRender/private/qssgrendercustommaterial_p.h>
22#include <QtQuick3DRuntimeRender/private/qssgrenderlight_p.h>
23#include <QtQuick3DRuntimeRender/private/qssgrenderparticleshaderkeys_p.h>
24#include <QtQuick3DUtils/private/qssgrenderbasetypes_p.h>
25
26QT_BEGIN_NAMESPACE
27
28struct QSSGRenderImage;
29
30struct Q_QUICK3DRUNTIMERENDER_EXPORT QSSGParticleSimple
31{
32 QVector3D position;
33 float size;
34 QVector3D rotation;
35 float age;
36 QVector4D color;
37 // total 48 bytes
38};
39
40Q_STATIC_ASSERT_X(sizeof(QSSGParticleSimple) == 48, "size of QSSGParticleSimple must be 48");
41
42struct Q_QUICK3DRUNTIMERENDER_EXPORT QSSGParticleAnimated
43{
44 QVector3D position;
45 float size;
46 QVector3D rotation;
47 float age;
48 QVector4D color;
49 float animationFrame;
50 // Padding for full 4 * 16 bytes, take into use as needed.
51 // See particleSize in vertex shader
52 QVector3D unusedPadding;
53 // total 64 bytes
54};
55
56Q_STATIC_ASSERT_X(sizeof(QSSGParticleAnimated) == 64, "size of QSSGParticleAnimated must be 64");
57
58struct Q_QUICK3DRUNTIMERENDER_EXPORT QSSGTriangleParticle
59{
60 QVector3D position; // particle position
61 float size;
62 QVector3D rotation;
63 float age;
64 QVector4D color;
65 QVector3D center; // center of the origin triangle
66 float fill;
67 // total 64 bytes
68};
69
70Q_STATIC_ASSERT_X(sizeof(QSSGTriangleParticle) == 64, "size of QSSGTriangleParticle must be 64");
71
72struct Q_QUICK3DRUNTIMERENDER_EXPORT QSSGLineParticle
73{
74 QVector3D position;
75 float size;
76 QVector4D color;
77 QVector3D binormal;
78 float animationFrame;
79 float age;
80 float length;
81 QVector2D fill;
82 // total 64 bytes
83};
84
85Q_STATIC_ASSERT_X(sizeof(QSSGLineParticle) == 64, "size of QSSGLineParticle must be 64");
86
87struct Q_QUICK3DRUNTIMERENDER_EXPORT QSSGParticleBuffer
88{
89 void resize(int particleCount, int particleSize = sizeof(QSSGParticleSimple));
90 void resizeLine(int particleCount, int segmentCount);
91 void setBounds(const QSSGBounds3& bounds);
92
93 char *pointer();
94 const char *pointer() const;
95 int particlesPerSlice() const;
96 int sliceStride() const;
97 int particleCount() const;
98 int sliceCount() const;
99 QSize size() const;
100 QByteArray data() const;
101 QSSGBounds3 bounds() const;
102 int bufferSize() const;
103 int serial() const;
104 int segments() const;
105
106private:
107 int m_particlesPerSlice = 0;
108 int m_sliceStride = 0;
109 int m_particleCount = 0;
110 int m_serial = 0;
111 int m_segments = 0;
112 QSize m_size;
113 QByteArray m_particleBuffer;
114 QSSGBounds3 m_bounds;
115};
116
117class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGRenderParticles : public QSSGRenderNode
118{
119public:
120 enum class BlendMode : quint8
121 {
122 SourceOver = 0,
123 Screen,
124 Multiply
125 };
126 enum class FeatureLevel : quint8
127 {
128 Simple = 0,
129 Mapped,
130 Animated,
131 SimpleVLight,
132 MappedVLight,
133 AnimatedVLight,
134 Line,
135 LineMapped,
136 LineAnimated,
137 LineVLight,
138 LineMappedVLight,
139 LineAnimatedVLight,
140 };
141
142 Q_DISABLE_COPY(QSSGRenderParticles)
143
144 QSSGParticleBuffer m_particleBuffer;
145
146 QVarLengthArray<QSSGRenderLight *, 4> m_lights;
147
148 QSSGRenderParticles::BlendMode m_blendMode = BlendMode::SourceOver;
149 QSSGRenderImage *m_sprite = nullptr;
150 int m_spriteImageCount = 1;
151 float m_depthBiasSq = 0.0f; // Squared as our sorting is based on the squared distance!
152 float m_sizeModifier = 0.0f;
153 float m_alphaFade = 0.0f;
154 float m_texcoordScale = 1.0f;
155 bool m_blendImages = true;
156 bool m_billboard = true;
157 bool m_hasTransparency = true;
158 bool m_depthSorting = false;
159 QSSGRenderImage *m_colorTable = nullptr;
160 QSSGRenderParticles::FeatureLevel m_featureLevel = FeatureLevel::Simple;
161 bool m_castsReflections = true;
162 QSSGShaderParticleMaterialKey materialKey;
163
164 QSSGRenderParticles();
165 ~QSSGRenderParticles() = default;
166};
167
168
169QT_END_NAMESPACE
170
171#endif
Q_STATIC_ASSERT_X(sizeof(QSSGParticleSimple)==48, "size of QSSGParticleSimple must be 48")