29 Q_PROPERTY(QQuickParticleSystem* system READ system WRITE setSystem NOTIFY systemChanged)
30 Q_PROPERTY(QStringList groups READ groups WRITE setGroups NOTIFY groupsChanged)
31 Q_PROPERTY(QStringList whenCollidingWith READ whenCollidingWith WRITE setWhenCollidingWith NOTIFY whenCollidingWithChanged)
32 Q_PROPERTY(
bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged OVERRIDE)
33 Q_PROPERTY(
bool once READ onceOff WRITE setOnceOff NOTIFY onceChanged)
34 Q_PROPERTY(QQuickParticleExtruder* shape READ shape WRITE setShape NOTIFY shapeChanged)
36 QML_NAMED_ELEMENT(ParticleAffector)
37 QML_ADDED_IN_VERSION(2, 0)
38 QML_UNCREATABLE(
"Abstract type. Use one of the inheriting types instead.")
41 explicit QQuickParticleAffector(QQuickItem *parent =
nullptr);
42 virtual void affectSystem(qreal dt);
43 virtual void reset(QQuickParticleData*);
44 QQuickParticleSystem* system()
const
49 QStringList groups()
const
64 QQuickParticleExtruder* shape()
const
69 QStringList whenCollidingWith()
const
71 return m_whenCollidingWith;
76 void systemChanged(QQuickParticleSystem* arg);
78 void groupsChanged(
const QStringList &arg);
80 void enabledChanged(
bool arg);
82 void onceChanged(
bool arg);
84 void shapeChanged(QQuickParticleExtruder* arg);
86 void affected(qreal x, qreal y);
88 void whenCollidingWithChanged(
const QStringList &arg);
91void setSystem(QQuickParticleSystem* arg)
93 if (m_system != arg) {
95 m_system->unregisterParticleAffector(
this);
98 m_system->registerParticleAffector(
this);
99 Q_EMIT systemChanged(arg);
103void setGroups(
const QStringList &arg)
105 if (m_groups != arg) {
107 m_updateIntSet =
true;
108 Q_EMIT groupsChanged(arg);
112void setEnabled(
bool arg)
114 if (m_enabled != arg) {
116 Q_EMIT enabledChanged(arg);
120void setOnceOff(
bool arg)
122 if (m_onceOff != arg) {
125 Q_EMIT onceChanged(arg);
129void setShape(QQuickParticleExtruder* arg)
131 if (m_shape != arg) {
133 Q_EMIT shapeChanged(arg);
137void setWhenCollidingWith(
const QStringList &arg)
139 if (m_whenCollidingWith != arg) {
140 m_whenCollidingWith = arg;
141 Q_EMIT whenCollidingWithChanged(arg);
145 void updateOffsets();
148 friend class QQuickParticleSystem;
149 virtual bool affectParticle(QQuickParticleData *d, qreal dt);
151 bool m_ignoresTime:1;
155 QQuickParticleSystem* m_system;
156 QStringList m_groups;
157 bool activeGroup(
int g);
158 bool shouldAffect(QQuickParticleData* datum);
159 void postAffect(QQuickParticleData* datum);
160 void componentComplete() override;
161 bool isAffectedConnected();
162 static const qreal simulationDelta;
163 static const qreal simulationCutoff;
166 QSet<std::pair<
int,
int>> m_onceOffed;
168 QSet<
int> m_groupIds;
171 QQuickParticleExtruder* m_shape;
173 QStringList m_whenCollidingWith;
175 bool isColliding(QQuickParticleData* d)
const;