Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickparticleaffector_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef PARTICLEAFFECTOR_H
5#define PARTICLEAFFECTOR_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 <QObject>
19#include <QSet>
23
25
26class Q_QUICKPARTICLES_EXPORT QQuickParticleAffector : public QQuickItem
27{
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)
35
36 QML_NAMED_ELEMENT(ParticleAffector)
38 QML_UNCREATABLE("Abstract type. Use one of the inheriting types instead.")
39
40public:
42 virtual void affectSystem(qreal dt);
43 virtual void reset(QQuickParticleData*);//As some store their own data per particle?
44 QQuickParticleSystem* system() const
45 {
46 return m_system;
47 }
48
50 {
51 return m_groups;
52 }
53
54 bool enabled() const
55 {
56 return m_enabled;
57 }
58
59 bool onceOff() const
60 {
61 return m_onceOff;
62 }
63
65 {
66 return m_shape;
67 }
68
70 {
71 return m_whenCollidingWith;
72 }
73
75
77
79
80 void enabledChanged(bool arg);
81
82 void onceChanged(bool arg);
83
85
87
89
90public Q_SLOTS:
92{
93 if (m_system != arg) {
94 m_system = arg;
95 if (m_system)
96 m_system->registerParticleAffector(this);
97 Q_EMIT systemChanged(arg);
98 }
99}
100
102{
103 if (m_groups != arg) {
104 m_groups = arg;
105 m_updateIntSet = true;
106 Q_EMIT groupsChanged(arg);
107 }
108}
109
110void setEnabled(bool arg)
111{
112 if (m_enabled != arg) {
113 m_enabled = arg;
114 Q_EMIT enabledChanged(arg);
115 }
116}
117
118void setOnceOff(bool arg)
119{
120 if (m_onceOff != arg) {
121 m_onceOff = arg;
122 m_needsReset = true;
123 Q_EMIT onceChanged(arg);
124 }
125}
126
128{
129 if (m_shape != arg) {
130 m_shape = arg;
131 Q_EMIT shapeChanged(arg);
132 }
133}
134
136{
137 if (m_whenCollidingWith != arg) {
138 m_whenCollidingWith = arg;
139 Q_EMIT whenCollidingWithChanged(arg);
140 }
141}
142public Q_SLOTS:
143 void updateOffsets();
144
145protected:
147 virtual bool affectParticle(QQuickParticleData *d, qreal dt);
148 bool m_needsReset:1;//### What is this really saving?
150 bool m_onceOff:1;
151 bool m_enabled:1;
152
155 bool activeGroup(int g);
156 bool shouldAffect(QQuickParticleData* datum);//Call to do the logic on whether it is affecting that datum
157 void postAffect(QQuickParticleData* datum);//Call to do the post-affect logic on particles which WERE affected(once off, needs reset, affected signal)
158 void componentComplete() override;
159 bool isAffectedConnected();
160 static const qreal simulationDelta;
162
164 QSet<QPair<int, int>> m_onceOffed;
165private:
166 QSet<int> m_groupIds;
167 bool m_updateIntSet;
168
169 QQuickParticleExtruder* m_shape;
170
171 QStringList m_whenCollidingWith;
172
173 bool isColliding(QQuickParticleData* d) const;
174};
175
177#endif // PARTICLEAFFECTOR_H
\inmodule QtCore\reentrant
Definition qpoint.h:217
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
void whenCollidingWithChanged(const QStringList &arg)
void groupsChanged(const QStringList &arg)
void shapeChanged(QQuickParticleExtruder *arg)
QQuickParticleExtruder * shape() const
void onceChanged(bool arg)
void setSystem(QQuickParticleSystem *arg)
void systemChanged(QQuickParticleSystem *arg)
QQuickParticleSystem * m_system
void setWhenCollidingWith(const QStringList &arg)
QSet< QPair< int, int > > m_onceOffed
void setGroups(const QStringList &arg)
QStringList whenCollidingWith() const
void setShape(QQuickParticleExtruder *arg)
void enabledChanged(bool arg)
void affected(qreal x, qreal y)
\inmodule QtCore
Combined button and popup list for selecting options.
GLint GLint GLint GLint GLint x
[0]
GLsizei GLuint * groups
GLsizei GLenum GLenum * types
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLenum type
GLboolean GLboolean g
GLint y
GLboolean reset
#define QML_UNCREATABLE(REASON)
#define QML_NAMED_ELEMENT(NAME)
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
SSL_CTX int void * arg
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_EMIT
#define Q_SLOTS
#define Q_SIGNALS
double qreal
Definition qtypes.h:187
#define explicit