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