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)
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) {
96 m_system->registerParticleAffector(
this);
97 Q_EMIT systemChanged(arg);
101void setGroups(
const QStringList &arg)
103 if (m_groups != arg) {
105 m_updateIntSet =
true;
106 Q_EMIT groupsChanged(arg);
110void setEnabled(
bool arg)
112 if (m_enabled != arg) {
114 Q_EMIT enabledChanged(arg);
118void setOnceOff(
bool arg)
120 if (m_onceOff != arg) {
123 Q_EMIT onceChanged(arg);
127void setShape(QQuickParticleExtruder* arg)
129 if (m_shape != arg) {
131 Q_EMIT shapeChanged(arg);
135void setWhenCollidingWith(
const QStringList &arg)
137 if (m_whenCollidingWith != arg) {
138 m_whenCollidingWith = arg;
139 Q_EMIT whenCollidingWithChanged(arg);
143 void updateOffsets();
146 friend class QQuickParticleSystem;
147 virtual bool affectParticle(QQuickParticleData *d, qreal dt);
149 bool m_ignoresTime:1;
153 QQuickParticleSystem* m_system;
154 QStringList m_groups;
155 bool activeGroup(
int g);
156 bool shouldAffect(QQuickParticleData* datum);
157 void postAffect(QQuickParticleData* datum);
158 void componentComplete() override;
159 bool isAffectedConnected();
160 static const qreal simulationDelta;
161 static const qreal simulationCutoff;
164 QSet<std::pair<
int,
int>> m_onceOffed;
166 QSet<
int> m_groupIds;
169 QQuickParticleExtruder* m_shape;
171 QStringList m_whenCollidingWith;
173 bool isColliding(QQuickParticleData* d)
const;