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
qquick3dparticledynamicburst.cpp
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
7
9
10/*!
11 \qmltype DynamicBurst3D
12 \inherits EmitBurst3D
13 \inqmlmodule QtQuick3D.Particles3D
14 \brief Dynamic emitter bursts.
15 \since 6.3
16
17 This element defines particle bursts in the \l ParticleEmitter3D. These bursts are
18 dynamic, meaning that they are evaluated while the particlesystem runs. Use these
19 instead of \l EmitBurst3D for example when the emitter moves, so that emitting
20 happens at the correct position.
21
22 For example, to emit 100 particles at 1 second time and 200 particles at 2 second:
23
24 \qml
25 ParticleEmitter3D {
26 ...
27 emitBursts: [
28 DynamicBurst3D {
29 time: 1000
30 amount: 100
31 },
32 DynamicBurst3D {
33 time: 2000
34 amount: 200
35 }
36 ]
37 }
38 \endqml
39*/
40
41QQuick3DParticleDynamicBurst::QQuick3DParticleDynamicBurst(QObject *parent)
42 : QQuick3DParticleEmitBurst(parent)
43{
44
45}
46
47/*!
48 \qmlproperty bool DynamicBurst3D::enabled
49
50 If enabled is set to \c false, this burst will not emit any particles.
51
52 The default value is \c true.
53*/
54bool QQuick3DParticleDynamicBurst::enabled() const
55{
56 return m_enabled;
57}
58
59/*!
60 \qmlproperty int DynamicBurst3D::amountVariation
61
62 This property defines the random variation in particle emit amount.
63
64 For example, to have a random range between 0 and 10
65 \qml
66 DynamicBurst3D {
67 time: 1000
68 amount: 5
69 amountVariation: 5
70 }
71 \endqml
72
73 The default value is \c 0.
74*/
75int QQuick3DParticleDynamicBurst::amountVariation() const
76{
77 return m_amountVariation;
78}
79
80/*!
81 \qmlproperty ShapeType DynamicBurst3D::triggerMode
82
83 This property defines the emitting mode.
84
85 The default value is \c TriggerMode.TriggerTime.
86*/
87
88/*!
89 \qmlproperty enumeration DynamicBurst3D::TriggerMode
90
91 Defines the mode of the bursting.
92
93 \value DynamicBurst3D.TriggerTime
94 The particles are emitted when the burst \l {EmitBurst3D::time}{time} is due.
95 \value DynamicBurst3D.TriggerStart
96 The particles are emitted when the followed particle is emitted.
97 \note This property is restricted to only work with trail emitters.
98 \note In this mode, \c time and \c duration properties don't have an effect.
99 \value DynamicBurst3D.TriggerEnd
100 The particles are emitted when the followed particle \c lifeSpan ends.
101 \note This property is restricted to only work with trail emitters.
102 \note In this mode, \c time and \c duration properties don't have an effect.
103*/
104
105QQuick3DParticleDynamicBurst::TriggerMode QQuick3DParticleDynamicBurst::triggerMode() const
106{
107 return m_triggerMode;
108}
109
110void QQuick3DParticleDynamicBurst::setEnabled(bool enabled)
111{
112 if (m_enabled == enabled)
113 return;
114
115 m_enabled = enabled;
116 Q_EMIT enabledChanged();
117}
118
119void QQuick3DParticleDynamicBurst::setAmountVariation(int value)
120{
121 if (m_amountVariation == value)
122 return;
123
124 if (value < 0) {
125 qWarning () << "DynamicBurst3D: Amount variation must be positive.";
126 return;
127 }
128 m_amountVariation = value;
129 Q_EMIT amountVariationChanged();
130}
131
132void QQuick3DParticleDynamicBurst::setTriggerMode(TriggerMode mode)
133{
134 if (m_triggerMode == mode)
135 return;
136
137 m_triggerMode = mode;
138 Q_EMIT triggerModeChanged();
139}
140
141QT_END_NAMESPACE
Combined button and popup list for selecting options.