1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QQUICK3DPARTICLEDATA_H
5#define QQUICK3DPARTICLEDATA_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 <QVector3D>
19#include <private/qglobal_p.h>
20
21QT_BEGIN_NAMESPACE
22
23struct Color4ub {
24 uchar r = 255;
25 uchar g = 255;
26 uchar b = 255;
27 uchar a = 255;
28};
29
30struct Vector3b {
31 qint8 x = 0;
32 qint8 y = 0;
33 qint8 z = 0;
34};
35
36// Current particle data, only used for currently modified data, so one per system
37struct QQuick3DParticleDataCurrent
38{
39 QVector3D position;
40 QVector3D velocity;
41 QVector3D rotation;
42 QVector3D scale;
43 Color4ub color;
44};
45
46// Particle data per particle
47// Not modified after emits
48struct QQuick3DParticleData
49{
50 QVector3D startPosition;
51 QVector3D startVelocity;
52 QVector3D surfaceNormal;
53 // Use Vector3b to reduce the memory usage, rotations work with less accuracy.
54 // These need to be qint8 and not quint8 as rotations can go either direction.
55
56 Vector3b startRotation;
57 Vector3b startRotationVelocity;
58 Color4ub startColor;
59 // Seconds, system time when this particle was emitted
60 float startTime = -1.0f;
61 // Seconds, particle lifetime
62 float lifetime = 0.0f;
63 // Unified scaling among axes
64 float startSize = 1.0f;
65 float endSize = 1.0f;
66 // Seconds, sprite sequence animation total time
67 float animationTime = -1.0f;
68 // Index/id of the particle. Used to get unique random values.
69 // Might not be necessary, check later
70 int index = 0;
71 // Size: 12+12+3+3+4+4+4+4+4+4 = 54 bytes
72 bool reversed = false;
73};
74
75// Data structure for storing bursts
76struct QQuick3DParticleEmitBurstData {
77 int amount = 0;
78 int time = 0;
79 int duration = 0;
80 QVector3D position;
81};
82
83QT_END_NAMESPACE
84
85#endif // QQUICK3DPARTICLEDATA_H
86

source code of qtquick3d/src/quick3dparticles/qquick3dparticledata_p.h