aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/particles/particles.pri30
-rw-r--r--src/declarative/particles/qsgage.cpp81
-rw-r--r--src/declarative/particles/qsgage_p.h (renamed from src/declarative/particles/qsgkill.cpp)57
-rw-r--r--src/declarative/particles/qsgangledirection.cpp (renamed from src/declarative/particles/qsgangleddirection.cpp)22
-rw-r--r--src/declarative/particles/qsgangledirection_p.h (renamed from src/declarative/particles/qsgangleddirection_p.h)6
-rw-r--r--src/declarative/particles/qsgcumulativedirection.cpp10
-rw-r--r--src/declarative/particles/qsgcumulativedirection_p.h10
-rw-r--r--src/declarative/particles/qsgcustomaffector.cpp80
-rw-r--r--src/declarative/particles/qsgcustomaffector_p.h (renamed from src/declarative/particles/qsgkill_p.h)26
-rw-r--r--src/declarative/particles/qsgcustomparticle.cpp94
-rw-r--r--src/declarative/particles/qsgdirection.cpp (renamed from src/declarative/particles/qsgstochasticdirection.cpp)10
-rw-r--r--src/declarative/particles/qsgdirection_p.h (renamed from src/declarative/particles/qsgstochasticdirection_p.h)4
-rw-r--r--src/declarative/particles/qsgimageparticle.cpp6
-rw-r--r--src/declarative/particles/qsgimageparticle_p.h22
-rw-r--r--src/declarative/particles/qsgmodelparticle.cpp335
-rw-r--r--src/declarative/particles/qsgmodelparticle_p.h140
-rw-r--r--src/declarative/particles/qsgparticleaffector.cpp54
-rw-r--r--src/declarative/particles/qsgparticleaffector_p.h62
-rw-r--r--src/declarative/particles/qsgparticleemitter.cpp65
-rw-r--r--src/declarative/particles/qsgparticleemitter_p.h184
-rw-r--r--src/declarative/particles/qsgparticleextruder.cpp22
-rw-r--r--src/declarative/particles/qsgparticleextruder_p.h19
-rw-r--r--src/declarative/particles/qsgparticlepainter.cpp4
-rw-r--r--src/declarative/particles/qsgparticlesmodule.cpp34
-rw-r--r--src/declarative/particles/qsgparticlesystem.cpp81
-rw-r--r--src/declarative/particles/qsgparticlesystem_p.h32
-rw-r--r--src/declarative/particles/qsgpointattractor.cpp42
-rw-r--r--src/declarative/particles/qsgpointattractor_p.h20
-rw-r--r--src/declarative/particles/qsgpointdirection.cpp4
-rw-r--r--src/declarative/particles/qsgpointdirection_p.h4
-rw-r--r--src/declarative/particles/qsgrectangleextruder.cpp86
-rw-r--r--src/declarative/particles/qsgrectangleextruder_p.h88
-rw-r--r--src/declarative/particles/qsgtargetdirection.cpp (renamed from src/declarative/particles/qsgtargeteddirection.cpp)28
-rw-r--r--src/declarative/particles/qsgtargetdirection_p.h (renamed from src/declarative/particles/qsgtargeteddirection_p.h)6
-rw-r--r--src/declarative/particles/qsgtrailemitter.cpp (renamed from src/declarative/particles/qsgfollowemitter.cpp)46
-rw-r--r--src/declarative/particles/qsgtrailemitter_p.h (renamed from src/declarative/particles/qsgfollowemitter_p.h)7
-rw-r--r--src/declarative/particles/qsgturbulence.cpp2
-rw-r--r--src/declarative/particles/qsgv8particledata.cpp58
-rw-r--r--src/declarative/particles/qsgwander.cpp33
-rw-r--r--src/declarative/particles/qsgwander_p.h22
40 files changed, 918 insertions, 1018 deletions
diff --git a/src/declarative/particles/particles.pri b/src/declarative/particles/particles.pri
index 9f63cd81b9..527bd9ae61 100644
--- a/src/declarative/particles/particles.pri
+++ b/src/declarative/particles/particles.pri
@@ -1,18 +1,18 @@
INCLUDEPATH += $$PWD
HEADERS += \
- $$PWD/qsgangleddirection_p.h \
+ $$PWD/qsgangledirection_p.h \
$$PWD/qsgcustomparticle_p.h \
+ $$PWD/qsgcustomaffector_p.h \
$$PWD/qsgellipseextruder_p.h \
- $$PWD/qsgfollowemitter_p.h \
+ $$PWD/qsgtrailemitter_p.h \
$$PWD/qsgfriction_p.h \
$$PWD/qsggravity_p.h \
$$PWD/qsgimageparticle_p.h \
$$PWD/qsgitemparticle_p.h \
- $$PWD/qsgkill_p.h \
+ $$PWD/qsgage_p.h \
$$PWD/qsglineextruder_p.h \
$$PWD/qsgmaskextruder_p.h \
- $$PWD/qsgmodelparticle_p.h \
$$PWD/qsgparticleaffector_p.h \
$$PWD/qsgparticleemitter_p.h \
$$PWD/qsgparticleextruder_p.h \
@@ -22,27 +22,28 @@ HEADERS += \
$$PWD/qsgpointattractor_p.h \
$$PWD/qsgpointdirection_p.h \
$$PWD/qsgspritegoal_p.h \
- $$PWD/qsgstochasticdirection_p.h \
- $$PWD/qsgtargeteddirection_p.h \
+ $$PWD/qsgdirection_p.h \
+ $$PWD/qsgtargetdirection_p.h \
$$PWD/qsgturbulence_p.h \
$$PWD/qsgwander_p.h \
$$PWD/qsgtargetaffector_p.h \
$$PWD/qsgcumulativedirection_p.h \
- $$PWD/qsgv8particledata_p.h
+ $$PWD/qsgv8particledata_p.h \
+ $$PWD/qsgrectangleextruder_p.h
SOURCES += \
- $$PWD/qsgangleddirection.cpp \
+ $$PWD/qsgangledirection.cpp \
$$PWD/qsgcustomparticle.cpp \
+ $$PWD/qsgcustomaffector.cpp \
$$PWD/qsgellipseextruder.cpp \
- $$PWD/qsgfollowemitter.cpp \
+ $$PWD/qsgtrailemitter.cpp \
$$PWD/qsgfriction.cpp \
$$PWD/qsggravity.cpp \
$$PWD/qsgimageparticle.cpp \
$$PWD/qsgitemparticle.cpp \
- $$PWD/qsgkill.cpp \
+ $$PWD/qsgage.cpp \
$$PWD/qsglineextruder.cpp \
$$PWD/qsgmaskextruder.cpp \
- $$PWD/qsgmodelparticle.cpp \
$$PWD/qsgparticleaffector.cpp \
$$PWD/qsgparticleemitter.cpp \
$$PWD/qsgparticleextruder.cpp \
@@ -52,13 +53,14 @@ SOURCES += \
$$PWD/qsgpointattractor.cpp \
$$PWD/qsgpointdirection.cpp \
$$PWD/qsgspritegoal.cpp \
- $$PWD/qsgstochasticdirection.cpp \
- $$PWD/qsgtargeteddirection.cpp \
+ $$PWD/qsgdirection.cpp \
+ $$PWD/qsgtargetdirection.cpp \
$$PWD/qsgturbulence.cpp \
$$PWD/qsgwander.cpp \
$$PWD/qsgtargetaffector.cpp \
$$PWD/qsgcumulativedirection.cpp \
- $$PWD/qsgv8particledata.cpp
+ $$PWD/qsgv8particledata.cpp \
+ $$PWD/qsgrectangleextruder.cpp
RESOURCES += \
$$PWD/particles.qrc
diff --git a/src/declarative/particles/qsgage.cpp b/src/declarative/particles/qsgage.cpp
new file mode 100644
index 0000000000..2c0678fd0e
--- /dev/null
+++ b/src/declarative/particles/qsgage.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Declarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgage_p.h"
+#include "qsgparticleemitter_p.h"
+QT_BEGIN_NAMESPACE
+/*!
+ \qmlclass Age QSGAgeAffector
+ \inqmlmodule QtQuick.Particles 2
+ \inherits Affector
+ \brief The Age affector allows you to prematurely age particles
+
+ The Age affector allows you to alter where the particle is in its lifecycle. Common uses
+ are to expire particles prematurely, possibly giving them time to animate out.
+
+ The Age affector only applies to particles which are still alive.
+*/
+/*!
+ \qmlproperty int QtQuick.Particles2::Age::lifeLeft
+
+ The amount of life to set the particle to have. Affected particles
+ will jump to a point in their life where they will have this many
+ milliseconds left to live.
+*/
+
+QSGAgeAffector::QSGAgeAffector(QSGItem *parent) :
+ QSGParticleAffector(parent), m_lifeLeft(0)
+{
+}
+
+
+bool QSGAgeAffector::affectParticle(QSGParticleData *d, qreal dt)
+{
+ Q_UNUSED(dt);
+ if (d->stillAlive()){
+ qreal curT = (qreal)m_system->m_timeInt/1000.0;
+ qreal ttl = (qreal)m_lifeLeft/1000.0;
+ d->t = curT - (d->lifeSpan - ttl) + 1;
+ return true;
+ }
+ return false;
+}
+QT_END_NAMESPACE
diff --git a/src/declarative/particles/qsgkill.cpp b/src/declarative/particles/qsgage_p.h
index dfd26e3f39..c4c9929ad8 100644
--- a/src/declarative/particles/qsgkill.cpp
+++ b/src/declarative/particles/qsgage_p.h
@@ -39,30 +39,49 @@
**
****************************************************************************/
-#include "qsgkill_p.h"
-#include "qsgparticleemitter_p.h"
+#ifndef KILLAFFECTOR_H
+#define KILLAFFECTOR_H
+#include "qsgparticleaffector_p.h"
+
+QT_BEGIN_HEADER
+
QT_BEGIN_NAMESPACE
-/*!
- \qmlclass Kill QSGKillAffector
- \inqmlmodule QtQuick.Particles 2
- \inherits Affector
- \brief The Kill affector allows you to expire affected particles
-*/
+QT_MODULE(Declarative)
+
-QSGKillAffector::QSGKillAffector(QSGItem *parent) :
- QSGParticleAffector(parent)
+class QSGAgeAffector : public QSGParticleAffector
{
-}
+ Q_OBJECT
+ Q_PROPERTY(int lifeLeft READ lifeLeft WRITE setLifeLeft NOTIFY lifeLeftChanged)
+public:
+ explicit QSGAgeAffector(QSGItem *parent = 0);
-bool QSGKillAffector::affectParticle(QSGParticleData *d, qreal dt)
-{
- Q_UNUSED(dt);
- if (d->stillAlive()){
- d->t -= d->lifeSpan + 1;
- return true;
+ int lifeLeft() const
+ {
+ return m_lifeLeft;
+ }
+
+protected:
+ virtual bool affectParticle(QSGParticleData *d, qreal dt);
+signals:
+ void lifeLeftChanged(int arg);
+
+public slots:
+ void setLifeLeft(int arg)
+ {
+ if (m_lifeLeft != arg) {
+ m_lifeLeft = arg;
+ emit lifeLeftChanged(arg);
+ }
}
- return false;
-}
+
+private:
+
+int m_lifeLeft;
+};
+
QT_END_NAMESPACE
+QT_END_HEADER
+#endif // KILLAFFECTOR_H
diff --git a/src/declarative/particles/qsgangleddirection.cpp b/src/declarative/particles/qsgangledirection.cpp
index ab39b8a575..10a31bf07e 100644
--- a/src/declarative/particles/qsgangleddirection.cpp
+++ b/src/declarative/particles/qsgangledirection.cpp
@@ -39,21 +39,21 @@
**
****************************************************************************/
-#include "qsgangleddirection_p.h"
+#include "qsgangledirection_p.h"
#include <cmath>
QT_BEGIN_NAMESPACE
const qreal CONV = 0.017453292519943295;
/*!
- \qmlclass AngledDirection QSGAngledDirection
+ \qmlclass AngleDirection QSGAngleDirection
\inqmlmodule QtQuick.Particles 2
- \inherits StochasticDirection
- \brief The AngledDirection element allows you to specify a direction that varies in angle
+ \inherits Direction
+ \brief The AngleDirection element allows you to specify a direction that varies in angle
The AngledDirection element allows both the specification of a direction by angle and magnitude,
as well as varying the parameters by angle or magnitude.
*/
/*!
- \qmlproperty real QtQuick.Particles2::AngledDirection::angle
+ \qmlproperty real QtQuick.Particles2::AngleDirection::angle
This property specifies the base angle for the direction.
The angle of this direction will vary by no more than angleVariation
from this angle.
@@ -63,7 +63,7 @@ const qreal CONV = 0.017453292519943295;
The default value is zero.
*/
/*!
- \qmlproperty real QtQuick.Particles2::AngledDirection::magnitude
+ \qmlproperty real QtQuick.Particles2::AngleDirection::magnitude
This property specifies the base magnitude for the direction.
The magnitude of this direction will vary by no more than magnitudeVariation
from this magnitude.
@@ -73,7 +73,7 @@ const qreal CONV = 0.017453292519943295;
The default value is zero.
*/
/*!
- \qmlproperty real QtQuick.Particles2::AngledDirection::angleVariation
+ \qmlproperty real QtQuick.Particles2::AngleDirection::angleVariation
This property specifies the maximum angle variation for the direction.
The angle of the direction will vary by up to angleVariation clockwise
and anticlockwise from the value specified in angle.
@@ -83,7 +83,7 @@ const qreal CONV = 0.017453292519943295;
The default value is zero.
*/
/*!
- \qmlproperty real QtQuick.Particles2::AngledDirection::magnitudeVariation
+ \qmlproperty real QtQuick.Particles2::AngleDirection::magnitudeVariation
This property specifies the base magnitude for the direction.
The magnitude of this direction will vary by no more than magnitudeVariation
from the base magnitude.
@@ -92,8 +92,8 @@ const qreal CONV = 0.017453292519943295;
The default value is zero.
*/
-QSGAngledDirection::QSGAngledDirection(QObject *parent) :
- QSGStochasticDirection(parent)
+QSGAngleDirection::QSGAngleDirection(QObject *parent) :
+ QSGDirection(parent)
, m_angle(0)
, m_magnitude(0)
, m_angleVariation(0)
@@ -102,7 +102,7 @@ QSGAngledDirection::QSGAngledDirection(QObject *parent) :
}
-const QPointF &QSGAngledDirection::sample(const QPointF &from)
+const QPointF &QSGAngleDirection::sample(const QPointF &from)
{
//TODO: Faster
qreal theta = m_angle*CONV - m_angleVariation*CONV + rand()/float(RAND_MAX) * m_angleVariation*CONV * 2;
diff --git a/src/declarative/particles/qsgangleddirection_p.h b/src/declarative/particles/qsgangledirection_p.h
index 4d5522d13c..870a7eb0d9 100644
--- a/src/declarative/particles/qsgangleddirection_p.h
+++ b/src/declarative/particles/qsgangledirection_p.h
@@ -41,14 +41,14 @@
#ifndef QSGANGLEDDIRECTION_H
#define QSGANGLEDDIRECTION_H
-#include "qsgstochasticdirection_p.h"
+#include "qsgdirection_p.h"
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QSGAngledDirection : public QSGStochasticDirection
+class QSGAngleDirection : public QSGDirection
{
Q_OBJECT
Q_PROPERTY(qreal angle READ angle WRITE setAngle NOTIFY angleChanged)
@@ -56,7 +56,7 @@ class QSGAngledDirection : public QSGStochasticDirection
Q_PROPERTY(qreal angleVariation READ angleVariation WRITE setAngleVariation NOTIFY angleVariationChanged)
Q_PROPERTY(qreal magnitudeVariation READ magnitudeVariation WRITE setMagnitudeVariation NOTIFY magnitudeVariationChanged)
public:
- explicit QSGAngledDirection(QObject *parent = 0);
+ explicit QSGAngleDirection(QObject *parent = 0);
const QPointF &sample(const QPointF &from);
qreal angle() const
{
diff --git a/src/declarative/particles/qsgcumulativedirection.cpp b/src/declarative/particles/qsgcumulativedirection.cpp
index 1d7523972b..8e4e6b681d 100644
--- a/src/declarative/particles/qsgcumulativedirection.cpp
+++ b/src/declarative/particles/qsgcumulativedirection.cpp
@@ -45,24 +45,24 @@ QT_BEGIN_NAMESPACE
/*!
\qmlclass CumulativeDirection QSGCumulativeDirection
\inqmlmodule QtQuick.Particles 2
- \inherits StochasticDirection
+ \inherits Direction
\brief The CumulativeDirection element allows you to specify a direction made of other directions
The CumulativeDirection element will act as a direction that sums the directions within it.
*/
-QSGCumulativeDirection::QSGCumulativeDirection(QObject *parent):QSGStochasticDirection(parent)
+QSGCumulativeDirection::QSGCumulativeDirection(QObject *parent):QSGDirection(parent)
{
}
-QDeclarativeListProperty<QSGStochasticDirection> QSGCumulativeDirection::directions()
+QDeclarativeListProperty<QSGDirection> QSGCumulativeDirection::directions()
{
- return QDeclarativeListProperty<QSGStochasticDirection>(this, m_directions);//TODO: Proper list property
+ return QDeclarativeListProperty<QSGDirection>(this, m_directions);//TODO: Proper list property
}
const QPointF &QSGCumulativeDirection::sample(const QPointF &from)
{
QPointF ret;
- foreach (QSGStochasticDirection* dir, m_directions)
+ foreach (QSGDirection* dir, m_directions)
ret += dir->sample(from);
return ret;
}
diff --git a/src/declarative/particles/qsgcumulativedirection_p.h b/src/declarative/particles/qsgcumulativedirection_p.h
index c54a795931..4f93fed1bd 100644
--- a/src/declarative/particles/qsgcumulativedirection_p.h
+++ b/src/declarative/particles/qsgcumulativedirection_p.h
@@ -41,7 +41,7 @@
#ifndef QSGCUMULATIVEDIRECTION_P_H
#define QSGCUMULATIVEDIRECTION_P_H
-#include "qsgstochasticdirection_p.h"
+#include "qsgdirection_p.h"
#include <QDeclarativeListProperty>
QT_BEGIN_HEADER
@@ -49,16 +49,16 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QSGCumulativeDirection : public QSGStochasticDirection
+class QSGCumulativeDirection : public QSGDirection
{
Q_OBJECT
- Q_PROPERTY(QDeclarativeListProperty<QSGStochasticDirection> directions READ directions)
+ Q_PROPERTY(QDeclarativeListProperty<QSGDirection> directions READ directions)
Q_CLASSINFO("DefaultProperty", "directions")
public:
explicit QSGCumulativeDirection(QObject *parent = 0);
- QDeclarativeListProperty<QSGStochasticDirection> directions();
+ QDeclarativeListProperty<QSGDirection> directions();
const QPointF &sample(const QPointF &from);
private:
- QList<QSGStochasticDirection*> m_directions;
+ QList<QSGDirection*> m_directions;
};
#endif // QSGCUMULATIVEDIRECTION_P_H
diff --git a/src/declarative/particles/qsgcustomaffector.cpp b/src/declarative/particles/qsgcustomaffector.cpp
new file mode 100644
index 0000000000..70e1dbe035
--- /dev/null
+++ b/src/declarative/particles/qsgcustomaffector.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Declarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgcustomaffector_p.h"
+#include <QDebug>
+QT_BEGIN_NAMESPACE
+
+//TODO: Move docs (and inherit) to real base when docs can propagate
+//TODO: Document particle 'type'
+/*!
+ \qmlsignal QtQuick.Particles2::Affector::affectParticle(particle, dt)
+
+ This handler is called when particles are selected to be affected.
+
+ dt is the time since the last time it was affected. Use dt to normalize
+ trajectory manipulations to real time.
+
+ Note that JS is slower to execute, so it is not recommended to use this in
+ high-volume particle systems.
+*/
+QSGCustomAffector::QSGCustomAffector(QSGItem *parent) :
+ QSGParticleAffector(parent)
+{
+}
+
+bool QSGCustomAffector::isAffectConnected()
+{
+ static int idx = QObjectPrivate::get(this)->signalIndex("affectParticle(QDeclarativeV8Handle,qreal)");
+ return QObjectPrivate::get(this)->isSignalConnected(idx);
+}
+
+bool QSGCustomAffector::affectParticle(QSGParticleData *d, qreal dt)
+{
+ if (isAffectConnected()){
+ d->update = 0.0;
+ emit affectParticle(d->v8Value(), dt);
+ return d->update == 1.0;
+ }
+ return true;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/particles/qsgkill_p.h b/src/declarative/particles/qsgcustomaffector_p.h
index d1e2292f13..7f39200298 100644
--- a/src/declarative/particles/qsgkill_p.h
+++ b/src/declarative/particles/qsgcustomaffector_p.h
@@ -39,8 +39,12 @@
**
****************************************************************************/
-#ifndef KILLAFFECTOR_H
-#define KILLAFFECTOR_H
+#ifndef CUSTOMAFFECTOR_H
+#define CUSTOMAFFECTOR_H
+
+#include <QObject>
+#include "qsgparticlesystem_p.h"
+#include "qsgparticleextruder_p.h"
#include "qsgparticleaffector_p.h"
QT_BEGIN_HEADER
@@ -49,20 +53,22 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-
-class QSGKillAffector : public QSGParticleAffector
+class QSGCustomAffector : public QSGParticleAffector
{
Q_OBJECT
+
public:
- explicit QSGKillAffector(QSGItem *parent = 0);
-protected:
- virtual bool affectParticle(QSGParticleData *d, qreal dt);
-signals:
+ explicit QSGCustomAffector(QSGItem *parent = 0);
+signals:
+ void affectParticle(QDeclarativeV8Handle particle, qreal dt);
public slots:
-
+protected:
+ bool isAffectConnected();
+ virtual bool affectParticle(QSGParticleData *d, qreal dt);
+private:
};
QT_END_NAMESPACE
QT_END_HEADER
-#endif // KILLAFFECTOR_H
+#endif // CUSTOMAFFECTOR_H
diff --git a/src/declarative/particles/qsgcustomparticle.cpp b/src/declarative/particles/qsgcustomparticle.cpp
index 00e3ec185b..6c95fe66c0 100644
--- a/src/declarative/particles/qsgcustomparticle.cpp
+++ b/src/declarative/particles/qsgcustomparticle.cpp
@@ -47,36 +47,36 @@ QT_BEGIN_NAMESPACE
//Includes comments because the code isn't self explanatory
static const char qt_particles_template_vertex_code[] =
- "attribute highp vec2 vPos; \n"
- "attribute highp vec2 vTex; \n"
- "attribute highp vec4 vData; // x = time, y = lifeSpan, z = size, w = endSize \n"
- "attribute highp vec4 vVec; // x,y = constant speed, z,w = acceleration \n"
- "attribute highp float r; \n"
- "uniform highp mat4 qt_Matrix; \n"
- "uniform highp float timestamp; \n"
- "varying highp vec2 fTex; \n"
- "void defaultMain() { \n"
- " fTex = vTex; \n"
- " highp float size = vData.z; \n"
- " highp float endSize = vData.w; \n"
- " highp float t = (timestamp - vData.x) / vData.y; \n"
- " highp float currentSize = mix(size, endSize, t * t); \n"
- " if (t < 0. || t > 1.) \n"
- " currentSize = 0.; \n"
- " highp vec2 pos = vPos \n"
- " - currentSize / 2. + currentSize * vTex // adjust size \n"
- " + vVec.xy * t * vData.y // apply speed vector.. \n"
- " + 0.5 * vVec.zw * pow(t * vData.y, 2.); \n"
- " gl_Position = qt_Matrix * vec4(pos.x, pos.y, 0, 1); \n"
- "}\n";
+ "attribute highp vec2 qt_ParticlePos;\n"
+ "attribute highp vec2 qt_ParticleTex;\n"
+ "attribute highp vec4 qt_ParticleData; // x = time, y = lifeSpan, z = size, w = endSize\n"
+ "attribute highp vec4 qt_ParticleVec; // x,y = constant speed, z,w = acceleration\n"
+ "attribute highp float qt_ParticleR;\n"
+ "uniform highp mat4 qt_Matrix;\n"
+ "uniform highp float qt_Timestamp;\n"
+ "varying highp vec2 qt_TexCoord0;\n"
+ "void defaultMain() {\n"
+ " qt_TexCoord0 = qt_ParticleTex;\n"
+ " highp float size = qt_ParticleData.z;\n"
+ " highp float endSize = qt_ParticleData.w;\n"
+ " highp float t = (qt_Timestamp - qt_ParticleData.x) / qt_ParticleData.y;\n"
+ " highp float currentSize = mix(size, endSize, t * t);\n"
+ " if (t < 0. || t > 1.)\n"
+ " currentSize = 0.;\n"
+ " highp vec2 pos = qt_ParticlePos\n"
+ " - currentSize / 2. + currentSize * qt_ParticleTex // adjust size\n"
+ " + qt_ParticleVec.xy * t * qt_ParticleData.y // apply speed vector..\n"
+ " + 0.5 * qt_ParticleVec.zw * pow(t * qt_ParticleData.y, 2.);\n"
+ " gl_Position = qt_Matrix * vec4(pos.x, pos.y, 0, 1);\n"
+ "}";
static const char qt_particles_default_vertex_code[] =
"void main() { \n"
" defaultMain(); \n"
"}";
-static const char qt_particles_default_fragment_code[] =//TODO: Default frag requires source?
+static const char qt_particles_default_fragment_code[] =
"uniform sampler2D source; \n"
- "varying highp vec2 fTex; \n"
+ "varying highp vec2 qt_TexCoord0; \n"
"uniform lowp float qt_Opacity; \n"
"void main() { \n"
" gl_FragColor = texture2D(source, fTex) * qt_Opacity; \n"
@@ -150,7 +150,7 @@ void QSGCustomParticle::componentComplete()
This property holds the fragment shader's GLSL source code.
The default shader expects the texture coordinate to be passed from the
- vertex shader as "varying highp vec2 fTex", and it samples from a
+ vertex shader as "varying highp vec2 qt_TexCoord0", and it samples from a
sampler2D named "source".
*/
@@ -171,31 +171,31 @@ void QSGCustomParticle::setFragmentShader(const QByteArray &code)
This property holds the vertex shader's GLSL source code.
The default shader passes the texture coordinate along to the fragment
- shader as "varying highp vec2 fTex".
+ shader as "varying highp vec2 qt_TexCoord0".
To aid writing a particle vertex shader, the following GLSL code is prepended
to your vertex shader:
\code
- attribute highp vec2 vPos;
- attribute highp vec2 vTex;
- attribute highp vec4 vData; // x = time, y = lifeSpan, z = size, w = endSize
- attribute highp vec4 vVec; // x,y = constant speed, z,w = acceleration
- attribute highp float r;
+ attribute highp vec2 qt_ParticlePos;
+ attribute highp vec2 qt_ParticleTex;
+ attribute highp vec4 qt_ParticleData; // x = time, y = lifeSpan, z = size, w = endSize
+ attribute highp vec4 qt_ParticleVec; // x,y = constant speed, z,w = acceleration
+ attribute highp float qt_ParticleR;
uniform highp mat4 qt_Matrix;
- uniform highp float timestamp;
- varying highp vec2 fTex;
+ uniform highp float qt_Timestamp;
+ varying highp vec2 qt_TexCoord0;
void defaultMain() {
- fTex = vTex;
- highp float size = vData.z;
- highp float endSize = vData.w;
- highp float t = (timestamp - vData.x) / vData.y;
+ qt_TexCoord0 = qt_ParticleTex;
+ highp float size = qt_ParticleData.z;
+ highp float endSize = qt_ParticleData.w;
+ highp float t = (qt_Timestamp - qt_ParticleData.x) / qt_ParticleData.y;
highp float currentSize = mix(size, endSize, t * t);
if (t < 0. || t > 1.)
currentSize = 0.;
- highp vec2 pos = vPos
- - currentSize / 2. + currentSize * vTex // adjust size
- + vVec.xy * t * vData.y // apply speed vector..
- + 0.5 * vVec.zw * pow(t * vData.y, 2.);
+ highp vec2 pos = qt_ParticlePos
+ - currentSize / 2. + currentSize * qt_ParticleTex // adjust size
+ + qt_ParticleVec.xy * t * qt_ParticleData.y // apply speed vector..
+ + 0.5 * qt_ParticleVec.zw * pow(t * qt_ParticleData.y, 2.);
gl_Position = qt_Matrix * vec4(pos.x, pos.y, 0, 1);
}
\endcode
@@ -340,7 +340,11 @@ void QSGCustomParticle::updateProperties()
vertexCode = qt_particles_template_vertex_code + vertexCode;
m_source.attributeNames.clear();
- m_source.attributeNames << "vPos" << "vTex" << "vData" << "vVec" << "r";
+ m_source.attributeNames << "qt_ParticlePos"
+ << "qt_ParticleTex"
+ << "qt_ParticleData"
+ << "qt_ParticleVec"
+ << "qt_ParticleR";
lookThroughShaderCode(vertexCode);
lookThroughShaderCode(fragmentCode);
@@ -384,8 +388,8 @@ void QSGCustomParticle::lookThroughShaderCode(const QByteArray &code)
m_source.respectsMatrix = true;
} else if (name == "qt_Opacity") {
m_source.respectsOpacity = true;
- } else if (name == "timestamp") {
- //TODO: Copy the whole thing just because I have one more uniform?
+ } else if (name == "qt_Timestamp") {
+ //Not strictly necessary
} else {
m_source.uniformNames.insert(name);
if (type == "sampler2D") {
@@ -513,12 +517,12 @@ QSGShaderEffectNode* QSGCustomParticle::buildCustomNodes()
return *(m_nodes.begin());
}
-static const QByteArray timestampName("timestamp");
void QSGCustomParticle::buildData()
{
if (!m_rootNode)
return;
+ const QByteArray timestampName("qt_Timestamp");
QVector<QPair<QByteArray, QVariant> > values;
QVector<QPair<QByteArray, QPointer<QSGItem> > > textures;
const QVector<QPair<QByteArray, QPointer<QSGItem> > > &oldTextures = m_material.textureProviders();
diff --git a/src/declarative/particles/qsgstochasticdirection.cpp b/src/declarative/particles/qsgdirection.cpp
index cdbc9f15ad..f233a56f61 100644
--- a/src/declarative/particles/qsgstochasticdirection.cpp
+++ b/src/declarative/particles/qsgdirection.cpp
@@ -39,23 +39,23 @@
**
****************************************************************************/
-#include "qsgstochasticdirection_p.h"
+#include "qsgdirection_p.h"
QT_BEGIN_NAMESPACE
/*!
- \qmlclass StochasticDirection QSGStochasticDirection
+ \qmlclass Direction QSGDirection
\inqmlmodule QtQuick.Particles 2
- \brief The StochasticDirection elements allow you to specify a vector space.
+ \brief The Direction elements allow you to specify a vector space.
*/
-QSGStochasticDirection::QSGStochasticDirection(QObject *parent) :
+QSGDirection::QSGDirection(QObject *parent) :
QObject(parent)
{
}
-const QPointF &QSGStochasticDirection::sample(const QPointF &from)
+const QPointF &QSGDirection::sample(const QPointF &from)
{
return m_ret;
}
diff --git a/src/declarative/particles/qsgstochasticdirection_p.h b/src/declarative/particles/qsgdirection_p.h
index 764937fc00..f64d5644e7 100644
--- a/src/declarative/particles/qsgstochasticdirection_p.h
+++ b/src/declarative/particles/qsgdirection_p.h
@@ -52,11 +52,11 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QSGStochasticDirection : public QObject
+class QSGDirection : public QObject
{
Q_OBJECT
public:
- explicit QSGStochasticDirection(QObject *parent = 0);
+ explicit QSGDirection(QObject *parent = 0);
virtual const QPointF &sample(const QPointF &from);
signals:
diff --git a/src/declarative/particles/qsgimageparticle.cpp b/src/declarative/particles/qsgimageparticle.cpp
index b31d763f82..007cfb98db 100644
--- a/src/declarative/particles/qsgimageparticle.cpp
+++ b/src/declarative/particles/qsgimageparticle.cpp
@@ -608,7 +608,7 @@ void fillUniformArrayFromImage(float* array, const QImage& img, int size)
Acceptable values are
\list
\o None: Particles just appear and disappear.
- \o Fade: Particles fade in from 0. opacity at the start of their life, and fade out to 0. at the end.
+ \o Fade: Particles fade in from 0 opacity at the start of their life, and fade out to 0 at the end.
\o Scale: Particles scale in from 0 size at the start of their life, and scale back to 0 at the end.
\endlist
@@ -812,7 +812,7 @@ void QSGImageParticle::setAutoRotation(bool arg)
reset();
}
-void QSGImageParticle::setXVector(QSGStochasticDirection* arg)
+void QSGImageParticle::setXVector(QSGDirection* arg)
{
if (m_xVector != arg) {
m_xVector = arg;
@@ -822,7 +822,7 @@ void QSGImageParticle::setXVector(QSGStochasticDirection* arg)
reset();
}
-void QSGImageParticle::setYVector(QSGStochasticDirection* arg)
+void QSGImageParticle::setYVector(QSGDirection* arg)
{
if (m_yVector != arg) {
m_yVector = arg;
diff --git a/src/declarative/particles/qsgimageparticle_p.h b/src/declarative/particles/qsgimageparticle_p.h
index eb890e285c..01eacbad99 100644
--- a/src/declarative/particles/qsgimageparticle_p.h
+++ b/src/declarative/particles/qsgimageparticle_p.h
@@ -42,7 +42,7 @@
#ifndef ULTRAPARTICLE_H
#define ULTRAPARTICLE_H
#include "qsgparticlepainter_p.h"
-#include "qsgstochasticdirection_p.h"
+#include "qsgdirection_p.h"
#include <QDeclarativeListProperty>
#include <qsgsimplematerial.h>
@@ -172,9 +172,9 @@ class QSGImageParticle : public QSGParticlePainter
//###Call i/j? Makes more sense to those with vector calculus experience, and I could even add the cirumflex in QML?
//xVector is the vector from the top-left point to the top-right point, and is multiplied by current size
- Q_PROPERTY(QSGStochasticDirection* xVector READ xVector WRITE setXVector NOTIFY xVectorChanged)
+ Q_PROPERTY(QSGDirection* xVector READ xVector WRITE setXVector NOTIFY xVectorChanged)
//yVector is the same, but top-left to bottom-left. The particle is always a parallelogram.
- Q_PROPERTY(QSGStochasticDirection* yVector READ yVector WRITE setYVector NOTIFY yVectorChanged)
+ Q_PROPERTY(QSGDirection* yVector READ yVector WRITE setYVector NOTIFY yVectorChanged)
Q_PROPERTY(QDeclarativeListProperty<QSGSprite> sprites READ sprites)
Q_PROPERTY(EntryEffect entryEffect READ entryEffect WRITE setEntryEffect NOTIFY entryEffectChanged)
@@ -243,9 +243,9 @@ public:
bool autoRotation() const { return m_autoRotation; }
- QSGStochasticDirection* xVector() const { return m_xVector; }
+ QSGDirection* xVector() const { return m_xVector; }
- QSGStochasticDirection* yVector() const { return m_yVector; }
+ QSGDirection* yVector() const { return m_yVector; }
bool bloat() const { return m_bloat; }
@@ -282,9 +282,9 @@ signals:
void autoRotationChanged(bool arg);
- void xVectorChanged(QSGStochasticDirection* arg);
+ void xVectorChanged(QSGDirection* arg);
- void yVectorChanged(QSGStochasticDirection* arg);
+ void yVectorChanged(QSGDirection* arg);
void bloatChanged(bool arg);
@@ -312,9 +312,9 @@ public slots:
void setAutoRotation(bool arg);
- void setXVector(QSGStochasticDirection* arg);
+ void setXVector(QSGDirection* arg);
- void setYVector(QSGStochasticDirection* arg);
+ void setYVector(QSGDirection* arg);
void setBloat(bool arg);
@@ -364,8 +364,8 @@ private:
qreal m_rotationSpeed;
qreal m_rotationSpeedVariation;
bool m_autoRotation;
- QSGStochasticDirection* m_xVector;
- QSGStochasticDirection* m_yVector;
+ QSGDirection* m_xVector;
+ QSGDirection* m_yVector;
QList<QSGSprite*> m_sprites;
QSGSpriteEngine* m_spriteEngine;
diff --git a/src/declarative/particles/qsgmodelparticle.cpp b/src/declarative/particles/qsgmodelparticle.cpp
deleted file mode 100644
index c013d726a3..0000000000
--- a/src/declarative/particles/qsgmodelparticle.cpp
+++ /dev/null
@@ -1,335 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Declarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qsgmodelparticle_p.h"
-#include <QtDeclarative/private/qsgvisualitemmodel_p.h>
-#include <qsgnode.h>
-#include <QTimer>
-#include <QDebug>
-
-QT_BEGIN_NAMESPACE
-/*!
- \qmlclass ModelParticle QSGModelParticle
- \inqmlmodule QtQuick.Particles 2
- \inherits ParticlePainter
- \brief The ModelParticle element allows you to specify a model and delegate pair to paint particles.
-
-*/
-
-
-/*!
- \qmlmethod void QtQuick.Particles2::ModelParticle::freeze(Item item)
-
- Suspends the flow of time for the logical particle which item represents, allowing you to control its movement.
-*/
-
-/*!
- \qmlmethod void QtQuick.Particles2::ModelParticle::unfreeze(Item item)
-
- Restarts the flow of time for the logical particle which item represents, allowing it to be moved by the particle system again.
-*/
-
-/*!
- \qmlproperty bool QtQuick.Particles2::ModelParticle::fade
-
- If true, the item will automatically be faded in and out
- at the ends of its lifetime. If false, you will have to
- implement any entry effect yourself.
-
- Default is true.
-*/
-
-/*!
- \qmlproperty model QtQuick.Particles2::ModelParticle::model
-
- The model to use as a data source. Every time a particle is
- emitted, the next model entry will be used with a delegate
- to visualize it.
-*/
-
-/*!
- \qmlproperty Component QtQuick.Particles2::ModelParticle::delegate
-
- An instance of the delegate will be created for every model
- entry, and moved along with it.
-*/
-
-QSGModelParticle::QSGModelParticle(QSGItem *parent) :
- QSGParticlePainter(parent), m_ownModel(false), m_comp(0), m_model(0), m_fade(true), m_modelCount(0)
-{
- setFlag(QSGItem::ItemHasContents);
- QTimer* manageDelegates = new QTimer(this);//TODO: don't leak
- connect(manageDelegates, SIGNAL(timeout()),
- this, SLOT(processPending()));
- manageDelegates->setInterval(16);
- manageDelegates->setSingleShot(false);
- manageDelegates->start();
-}
-
-QSGModelParticle::~QSGModelParticle()
-{
- if (m_ownModel)
- delete m_model;
-}
-
-QVariant QSGModelParticle::model() const
-{
- return m_dataSource;
-}
-
-void QSGModelParticle::setModel(const QVariant &arg)
-{
- if (arg == m_dataSource)
- return;
- m_dataSource = arg;
- if (qobject_cast<QSGVisualDataModel*>(arg.value<QObject*>())) {
- if (m_ownModel && m_model)
- delete m_model;
- m_model = qobject_cast<QSGVisualDataModel*>(arg.value<QObject*>());
- m_ownModel = false;
- }else{
- if (!m_model || !m_ownModel)
- m_model = new QSGVisualDataModel(qmlContext(this));
- m_model->setModel(m_dataSource);
- m_ownModel = true;
- }
- if (m_comp)
- m_model->setDelegate(m_comp);
- emit modelChanged();
- emit modelCountChanged();
- connect(m_model, SIGNAL(countChanged()),
- this, SIGNAL(modelCountChanged()));
- connect(m_model, SIGNAL(countChanged()),
- this, SLOT(updateCount()));
- updateCount();
-}
-
-void QSGModelParticle::updateCount()
-{
- int newCount = 0;
- if (m_model)
- newCount = m_model->count();
- if (newCount < 0)
- return;//WTF?
- if (m_modelCount == 0 || newCount == 0){
- m_available.clear();
- for (int i=0; i<newCount; i++)
- m_available << i;
- }else if (newCount < m_modelCount){
- for (int i=newCount; i<m_modelCount; i++) //existing ones must leave normally, but aren't readded
- m_available.removeAll(i);
- }else if (newCount > m_modelCount){
- for (int i=m_modelCount; i<newCount; i++)
- m_available << i;
- }
- m_modelCount = newCount;
-}
-
-QDeclarativeComponent *QSGModelParticle::delegate() const
-{
- if (m_model)
- return m_model->delegate();
- return 0;
-}
-
-void QSGModelParticle::setDelegate(QDeclarativeComponent *comp)
-{
- if (QSGVisualDataModel *dataModel = qobject_cast<QSGVisualDataModel*>(m_model))
- if (comp == dataModel->delegate())
- return;
- m_comp = comp;
- if (m_model)
- m_model->setDelegate(comp);
- emit delegateChanged();
-}
-
-int QSGModelParticle::modelCount() const
-{
- if (m_model)
- const_cast<QSGModelParticle*>(this)->updateCount();//TODO: Investigate why this doesn't get called properly
- return m_modelCount;
-}
-
-
-void QSGModelParticle::freeze(QSGItem* item)
-{
- m_stasis << item;
-}
-
-
-void QSGModelParticle::unfreeze(QSGItem* item)
-{
- m_stasis.remove(item);
-}
-
-void QSGModelParticle::initialize(int gIdx, int pIdx)
-{
- if (!m_model || !m_model->count())
- return;
- if (m_available.isEmpty())
- return;
- m_requests << m_system->m_groupData[gIdx]->data[pIdx];
-}
-
-void QSGModelParticle::processPending()
-{//can't create/delete arbitrary items in the render thread
- foreach (QSGItem* item, m_deletables){
- item->setVisible(false);
- if (m_fade)
- item->setOpacity(0.);
- m_model->release(item);
- m_activeCount--;
- }
- m_deletables.clear();
-
- foreach (QSGParticleData* datum, m_requests){
- if (datum->delegate){
- if (m_stasis.contains(datum->delegate))
- qWarning() << "Current model particles prefers overwrite:false";
- //remove old item from the particle that is dying to make room for this one
- m_deletables << datum->delegate;
- m_available << datum->modelIndex;
- datum->modelIndex = -1;
- datum->delegate = 0;
- }
-
- if (!m_available.isEmpty()){
- datum->delegate = m_model->item(m_available.first());
- datum->modelIndex = m_available.first();
- m_available.pop_front();
- QSGModelParticleAttached* mpa = qobject_cast<QSGModelParticleAttached*>(qmlAttachedPropertiesObject<QSGModelParticle>(datum->delegate));
- if (mpa){
- mpa->m_mp = this;
- mpa->attach();
- }
- datum->delegate->setParentItem(this);
- if (m_fade)
- datum->delegate->setOpacity(0.0);
- datum->delegate->setVisible(false);//Will be set to true when we prepare the next frame
- m_activeCount++;
- }
- }
- m_requests.clear();
-}
-
-void QSGModelParticle::commit(int gIdx, int pIdx)
-{
- //No-op unless we start copying the data.
-}
-
-void QSGModelParticle::reset()
-{
- QSGParticlePainter::reset();
- //TODO: Cleanup items?
- //m_available.clear();//Should this be reset too?
- //m_pendingItems.clear();//TODO: Should this be done? If so, Emit signal?
-}
-
-
-QSGNode* QSGModelParticle::updatePaintNode(QSGNode* n, UpdatePaintNodeData* d)
-{
- //Dummy update just to get painting tick
- if (m_pleaseReset){
- m_pleaseReset = false;
- reset();
- }
- prepareNextFrame();
-
- update();//Get called again
- if (n)
- n->markDirty(QSGNode::DirtyMaterial);
- return QSGItem::updatePaintNode(n,d);
-}
-
-void QSGModelParticle::prepareNextFrame()
-{
- if (!m_system)
- return;
- qint64 timeStamp = m_system->systemSync(this);
- qreal curT = timeStamp/1000.0;
- qreal dt = curT - m_lastT;
- m_lastT = curT;
- if (!m_activeCount)
- return;
-
- //TODO: Size, better fade?
- foreach (const QString &str, m_particles){
- int gIdx = m_system->m_groupIds[str];
- int count = m_system->m_groupData[gIdx]->size();
-
- for (int i=0; i<count; i++){
- QSGParticleData* data = m_system->m_groupData[gIdx]->data[i];
- if (!data || !data->delegate)
- continue;
- qreal t = ((timeStamp/1000.0) - data->t) / data->lifeSpan;
- if (m_stasis.contains(data->delegate)) {
- data->t += dt;//Stasis effect
- continue;
- }
- if (t >= 1.0){//Usually happens from load
- m_available << data->modelIndex;
- m_deletables << data->delegate;
- data->modelIndex = -1;
- data->delegate = 0;
- continue;
- }else{//Fade
- data->delegate->setVisible(true);
- if (m_fade){
- qreal o = 1.;
- if (t<0.2)
- o = t*5;
- if (t>0.8)
- o = (1-t)*5;
- data->delegate->setOpacity(o);
- }
- }
- data->delegate->setX(data->curX() - data->delegate->width()/2 - m_systemOffset.x());
- data->delegate->setY(data->curY() - data->delegate->height()/2 - m_systemOffset.y());
- }
- }
-}
-
-QSGModelParticleAttached *QSGModelParticle::qmlAttachedProperties(QObject *object)
-{
- return new QSGModelParticleAttached(object);
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/particles/qsgmodelparticle_p.h b/src/declarative/particles/qsgmodelparticle_p.h
deleted file mode 100644
index c6dd40d51e..0000000000
--- a/src/declarative/particles/qsgmodelparticle_p.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Declarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef DATAPARTICLE_H
-#define DATAPARTICLE_H
-#include "qsgparticlepainter_p.h"
-#include <QPointer>
-#include <QSet>
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-class QSGVisualDataModel;
-class QSGModelParticleAttached;
-
-class QSGModelParticle : public QSGParticlePainter
-{
- Q_OBJECT
-
- Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged)
- Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
- Q_PROPERTY(int modelCount READ modelCount NOTIFY modelCountChanged)
- Q_PROPERTY(bool fade READ fade WRITE setFade NOTIFY fadeChanged)
- Q_CLASSINFO("DefaultProperty", "delegate")
-public:
- explicit QSGModelParticle(QSGItem *parent = 0);
- virtual ~QSGModelParticle();
- QVariant model() const;
- void setModel(const QVariant &);
-
- QDeclarativeComponent *delegate() const;
- void setDelegate(QDeclarativeComponent *);
-
- int modelCount() const;
-
- bool fade() const { return m_fade; }
-
- virtual QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
-
- static QSGModelParticleAttached *qmlAttachedProperties(QObject *object);
-signals:
- void modelChanged();
- void delegateChanged();
- void modelCountChanged();
- void fadeChanged();
-
-public slots:
- void freeze(QSGItem* item);
- void unfreeze(QSGItem* item);
-
- void setFade(bool arg){if (arg == m_fade) return; m_fade = arg; emit fadeChanged();}
-protected:
- virtual void reset();
- virtual void commit(int gIdx, int pIdx);
- virtual void initialize(int gIdx, int pIdx);
- void prepareNextFrame();
-private slots:
- void updateCount();
- void processPending();
-private:
- bool m_ownModel;
- QDeclarativeComponent* m_comp;
- QSGVisualDataModel *m_model;
- QVariant m_dataSource;
- QList<QSGItem*> m_deletables;
- QList< QSGParticleData* > m_requests;
- bool m_fade;
-
- QList<QSGItem*> m_pendingItems;
- QList<int> m_available;
- QSet<QSGItem*> m_stasis;
- qreal m_lastT;
- int m_activeCount;
- int m_modelCount;
-};
-
-class QSGModelParticleAttached : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QSGModelParticle* particle READ particle CONSTANT)
-public:
- QSGModelParticleAttached(QObject* parent)
- : QObject(parent), m_mp(0)
- {;}
- QSGModelParticle* particle() {return m_mp;}
- void detach(){emit detached();}
- void attach(){emit attached();}
-private:
- QSGModelParticle* m_mp;
- friend class QSGModelParticle;
-Q_SIGNALS:
- void detached();
- void attached();
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPEINFO(QSGModelParticle, QML_HAS_ATTACHED_PROPERTIES)
-
-QT_END_HEADER
-#endif // DATAPARTICLE_H
diff --git a/src/declarative/particles/qsgparticleaffector.cpp b/src/declarative/particles/qsgparticleaffector.cpp
index 4a3bba6e6d..3554121a2b 100644
--- a/src/declarative/particles/qsgparticleaffector.cpp
+++ b/src/declarative/particles/qsgparticleaffector.cpp
@@ -73,16 +73,16 @@ QT_BEGIN_NAMESPACE
By default, no groups are specified.
*/
/*!
- \qmlproperty bool QtQuick.Particles2::Affector::active
- If active is set to false, this affector will not affect any particles.
+ \qmlproperty bool QtQuick.Particles2::Affector::enabled
+ If enabled is set to false, this affector will not affect any particles.
Usually this is used to conditionally turn an affector on or off.
Default value is true.
*/
/*!
- \qmlproperty bool QtQuick.Particles2::Affector::onceOff
- If onceOff is set to true, this affector will only affect each particle
+ \qmlproperty bool QtQuick.Particles2::Affector::once
+ If once is set to true, this affector will only affect each particle
once in their lifetimes.
Default value is false.
@@ -93,27 +93,24 @@ QT_BEGIN_NAMESPACE
non-rectangular area.
*/
/*!
- \qmlproperty bool QtQuick.Particles2::Affector::signal
- If this is set to true, then an affected(x,y) signal will be emitted each
- time this affector would affect a particle.
+ \qmlsignal QtQuick.Particles2::Affector::onAffected(x, y)
- For Affector only, this will happen irrespective of whether any changes
- are made to the particle, for other Affectors the signal will only fire
- if the particle is actually affected.
+ This signal is emitted each time the affector actually affects a particle.
- Default value is false.
-*/
+ x,y are the coordinates of the affected particle, relative to the ParticleSystem.
+*/
//TODO: Document particle 'type'
/*!
\qmlsignal QtQuick.Particles2::Affector::affectParticle(particle, dt)
- This handler is called when a particle is selected to be affected.
+ This handler is called when particles are selected to be affected.
dt is the time since the last time it was affected. Use dt to normalize
trajectory manipulations to real time.
- This handler is usually not available on inherited types.
+ Note that JS is slower to execute, so it is not recommended to use this in
+ high-volume particle systems.
*/
/*!
\qmlsignal QtQuick.Particles2::Affector::affected(x, y)
@@ -124,32 +121,32 @@ QT_BEGIN_NAMESPACE
x,y is the particles current position.
*/
QSGParticleAffector::QSGParticleAffector(QSGItem *parent) :
- QSGItem(parent), m_needsReset(false), m_system(0), m_active(true)
- , m_updateIntSet(false), m_shape(new QSGParticleExtruder(this)), m_signal(false)
+ QSGItem(parent), m_needsReset(false), m_system(0), m_enabled(true)
+ , m_updateIntSet(false), m_shape(new QSGParticleExtruder(this))
{
}
-bool QSGParticleAffector::isAffectConnected()
+bool QSGParticleAffector::isAffectedConnected()
{
- static int idx = QObjectPrivate::get(this)->signalIndex("affectParticle(QDeclarativeV8Handle,qreal)");
+ static int idx = QObjectPrivate::get(this)->signalIndex("affected(qreal,qreal)");
return QObjectPrivate::get(this)->isSignalConnected(idx);
}
+
void QSGParticleAffector::componentComplete()
{
if (!m_system && qobject_cast<QSGParticleSystem*>(parentItem()))
setSystem(qobject_cast<QSGParticleSystem*>(parentItem()));
- if (!m_system)
- qWarning() << "Affector created without a particle system specified";//TODO: useful QML warnings, like line number?
QSGItem::componentComplete();
}
void QSGParticleAffector::affectSystem(qreal dt)
{
- if (!m_active)
+ if (!m_enabled)
return;
//If not reimplemented, calls affect particle per particle
//But only on particles in targeted system/area
+ bool affectedConnected = isAffectedConnected();
if (m_updateIntSet){
m_groups.clear();
foreach (const QString &p, m_particles)
@@ -167,16 +164,16 @@ void QSGParticleAffector::affectSystem(qreal dt)
continue;
//Need to have previous location for affected anyways
QPointF curPos;
- if (m_signal || (width() && height()))
+ if (affectedConnected || (width() && height()))
curPos = QPointF(d->curX(), d->curY());
if (width() == 0 || height() == 0
|| m_shape->contains(QRectF(m_offset.x(), m_offset.y(), width(), height()),curPos)){
- if (m_collisionParticles.isEmpty() || isColliding(d)){
+ if (m_whenCollidingWith.isEmpty() || isColliding(d)){
if (affectParticle(d, dt)){
m_system->m_needsReset << d;
if (m_onceOff)
m_onceOffed << qMakePair(d->group, d->index);
- if (m_signal)//###Make signal based on if connected, and then m_signal just affects AffectParticle for base?
+ if (affectedConnected)
emit affected(curPos.x(), curPos.y());
}
}
@@ -188,12 +185,7 @@ void QSGParticleAffector::affectSystem(qreal dt)
bool QSGParticleAffector::affectParticle(QSGParticleData *d, qreal dt)
{
- if (isAffectConnected()){
- d->update = 0.0;
- emit affectParticle(d->v8Value(), dt);
- return d->update == 1.0;
- }
- return m_signal;//If signalling, then we always 'null affect' it.
+ return true;
}
void QSGParticleAffector::reset(QSGParticleData* pd)
@@ -214,7 +206,7 @@ bool QSGParticleAffector::isColliding(QSGParticleData *d)
qreal myCurX = d->curX();
qreal myCurY = d->curY();
qreal myCurSize = d->curSize()/2;
- foreach (const QString &group, m_collisionParticles){
+ foreach (const QString &group, m_whenCollidingWith){
foreach (QSGParticleData* other, m_system->m_groupData[m_system->m_groupIds[group]]->data){
if (!other->stillAlive())
continue;
diff --git a/src/declarative/particles/qsgparticleaffector_p.h b/src/declarative/particles/qsgparticleaffector_p.h
index dd279c07b9..c808ef4e76 100644
--- a/src/declarative/particles/qsgparticleaffector_p.h
+++ b/src/declarative/particles/qsgparticleaffector_p.h
@@ -57,11 +57,10 @@ class QSGParticleAffector : public QSGItem
Q_OBJECT
Q_PROPERTY(QSGParticleSystem* system READ system WRITE setSystem NOTIFY systemChanged)
Q_PROPERTY(QStringList particles READ particles WRITE setParticles NOTIFY particlesChanged)
- Q_PROPERTY(QStringList collisionParticles READ collisionParticles WRITE setCollisionParticles NOTIFY collisionParticlesChanged)
- Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
- Q_PROPERTY(bool onceOff READ onceOff WRITE setOnceOff NOTIFY onceOffChanged)
+ Q_PROPERTY(QStringList whenCollidingWith READ whenCollidingWith WRITE setWhenCollidingWith NOTIFY whenCollidingWithChanged)
+ Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
+ Q_PROPERTY(bool once READ onceOff WRITE setOnceOff NOTIFY onceChanged)
Q_PROPERTY(QSGParticleExtruder* shape READ shape WRITE setShape NOTIFY shapeChanged)
- Q_PROPERTY(bool signal READ signal WRITE setSignal NOTIFY signalChanged)//TODO: Determine by whether it's connected
public:
explicit QSGParticleAffector(QSGItem *parent = 0);
@@ -77,9 +76,9 @@ public:
return m_particles;
}
- bool active() const
+ bool enabled() const
{
- return m_active;
+ return m_enabled;
}
bool onceOff() const
@@ -92,33 +91,26 @@ public:
return m_shape;
}
- bool signal() const
+ QStringList whenCollidingWith() const
{
- return m_signal;
- }
-
- QStringList collisionParticles() const
- {
- return m_collisionParticles;
+ return m_whenCollidingWith;
}
signals:
- void affectParticle(QDeclarativeV8Handle particle, qreal dt);
void systemChanged(QSGParticleSystem* arg);
void particlesChanged(QStringList arg);
- void activeChanged(bool arg);
+ void enabledChanged(bool arg);
- void onceOffChanged(bool arg);
+ void onceChanged(bool arg);
void shapeChanged(QSGParticleExtruder* arg);
void affected(qreal x, qreal y);
- void signalChanged(bool arg);
- void collisionParticlesChanged(QStringList arg);
+ void whenCollidingWithChanged(QStringList arg);
public slots:
void setSystem(QSGParticleSystem* arg)
@@ -139,11 +131,11 @@ void setParticles(QStringList arg)
}
}
-void setActive(bool arg)
+void setEnabled(bool arg)
{
- if (m_active != arg) {
- m_active = arg;
- emit activeChanged(arg);
+ if (m_enabled != arg) {
+ m_enabled = arg;
+ emit enabledChanged(arg);
}
}
@@ -152,7 +144,7 @@ void setOnceOff(bool arg)
if (m_onceOff != arg) {
m_onceOff = arg;
m_needsReset = true;
- emit onceOffChanged(arg);
+ emit onceChanged(arg);
}
}
@@ -164,19 +156,11 @@ void setShape(QSGParticleExtruder* arg)
}
}
-void setSignal(bool arg)
-{
- if (m_signal != arg) {
- m_signal = arg;
- emit signalChanged(arg);
- }
-}
-
-void setCollisionParticles(QStringList arg)
+void setWhenCollidingWith(QStringList arg)
{
- if (m_collisionParticles != arg) {
- m_collisionParticles = arg;
- emit collisionParticlesChanged(arg);
+ if (m_whenCollidingWith != arg) {
+ m_whenCollidingWith = arg;
+ emit whenCollidingWithChanged(arg);
}
}
@@ -187,10 +171,10 @@ protected:
QSGParticleSystem* m_system;
QStringList m_particles;
bool activeGroup(int g) {return m_groups.isEmpty() || m_groups.contains(g);}
- bool m_active;
+ bool m_enabled;
virtual void componentComplete();
QPointF m_offset;
- bool isAffectConnected();
+ bool isAffectedConnected();
private:
QSet<int> m_groups;
QSet<QPair<int, int> > m_onceOffed;
@@ -200,9 +184,7 @@ private:
QSGParticleExtruder* m_shape;
- bool m_signal;
-
- QStringList m_collisionParticles;
+ QStringList m_whenCollidingWith;
bool isColliding(QSGParticleData* d);
private slots:
diff --git a/src/declarative/particles/qsgparticleemitter.cpp b/src/declarative/particles/qsgparticleemitter.cpp
index 6519bf5f9e..d44ad689ee 100644
--- a/src/declarative/particles/qsgparticleemitter.cpp
+++ b/src/declarative/particles/qsgparticleemitter.cpp
@@ -117,21 +117,17 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \qmlproperty int QtQuick.Particles2::Emitter::emitCap
+ \qmlproperty int QtQuick.Particles2::Emitter::maximumEmitted
The maximum number of particles at a time that this emitter will have alive.
This can be set as a performance optimization (when using burst and pulse) or
- to stagger emissions. The default value is emitRate * lifeSpan in seconds, which
- is the number of particles that would be alive at any one time given the default settings.
-*/
-/*!
- \qmlproperty bool QtQuick.Particles2::Emitter::noCap
+ to stagger emissions.
- If set to true, the emitCap will be ignored and this emitter will never skip emitting
- a particle based on how many it has alive.
+ If this is set to a number below zero, then there is no maximum limit on the number
+ of particles this emitter can have alive.
- Default value is false.
+ The default value is -1.
*/
/*!
\qmlproperty int QtQuick.Particles2::Emitter::startTime
@@ -187,19 +183,38 @@ QT_BEGIN_NAMESPACE
*/
//TODO: Document particle 'type'
/*!
- \qmlsignal QtQuick.Particles2::Emitter::emitParticle(particle)
+ \qmlsignal QtQuick.Particles2::Emitter::onEmitParticle(Particle particle)
This handler is called when a particle is emitted. You can modify particle
attributes from within the handler.
+
+ Note that JS is slower to execute, so it is not recommended to use this in
+ high-volume particle systems.
+*/
+
+/*! \qmlmethod QtQuick.Particles2::Emitter::burst(int count)
+
+ Emits count particles from this emitter immediately.
*/
+/*! \qmlmethod QtQuick.Particles2::Emitter::burst(int x, int y, int count)
+
+ Emits count particles from this emitter immediately. The particles are emitted
+ as if the Emitter was positioned at x,y but all other properties are the same.
+*/
+
+/*! \qmlmethod QtQuick.Particles2::Emitter::pulse(real duration)
+
+ If the emitter is not enabled, enables it for duration seconds and then switches
+ it back off.
+*/
QSGParticleEmitter::QSGParticleEmitter(QSGItem *parent) :
QSGItem(parent)
, m_particlesPerSecond(10)
, m_particleDuration(1000)
, m_particleDurationVariation(0)
- , m_emitting(true)
+ , m_enabled(true)
, m_system(0)
, m_extruder(0)
, m_defaultExtruder(0)
@@ -215,11 +230,11 @@ QSGParticleEmitter::QSGParticleEmitter(QSGItem *parent) :
, m_last_timestamp(-1)
, m_last_emission(0)
, m_startTime(0)
- , m_overwrite(false)
+ , m_overwrite(true)
{
//TODO: Reset speed/acc back to null vector? Or allow null pointer?
- connect(this, SIGNAL(maxParticleCountChanged(int)),
+ connect(this, SIGNAL(maximumEmittedChanged(int)),
this, SIGNAL(particleCountChanged()));
connect(this, SIGNAL(particlesPerSecondChanged(qreal)),
this, SIGNAL(particleCountChanged()));
@@ -243,16 +258,14 @@ void QSGParticleEmitter::componentComplete()
{
if (!m_system && qobject_cast<QSGParticleSystem*>(parentItem()))
setSystem(qobject_cast<QSGParticleSystem*>(parentItem()));
- if (!m_system)
- qWarning() << "Emitter created without a particle system specified";//TODO: useful QML warnings, like line number?
QSGItem::componentComplete();
}
-void QSGParticleEmitter::setEmitting(bool arg)
+void QSGParticleEmitter::setEnabled(bool arg)
{
- if (m_emitting != arg) {
- m_emitting = arg;
- emit emittingChanged(arg);
+ if (m_enabled != arg) {
+ m_enabled = arg;
+ emit enabledChanged(arg);
}
}
@@ -270,7 +283,7 @@ void QSGParticleEmitter::pulse(qreal seconds)
{
if (!particleCount())
qWarning() << "pulse called on an emitter with a particle count of zero";
- if (!m_emitting)
+ if (!m_enabled)
m_burstLeft = seconds*1000.0;//TODO: Change name to match
}
@@ -302,8 +315,9 @@ void QSGParticleEmitter::setMaxParticleCount(int arg)
disconnect(this, SIGNAL(particleDurationChanged(int)),
this, SIGNAL(particleCountChanged()));
}
+ m_overwrite = arg < 0;
m_maxParticleCount = arg;
- emit maxParticleCountChanged(arg);
+ emit maximumEmittedChanged(arg);
}
}
@@ -331,7 +345,7 @@ void QSGParticleEmitter::emitWindow(int timeStamp)
{
if (m_system == 0)
return;
- if ((!m_emitting || !m_particlesPerSecond)&& !m_burstLeft && m_burstQueue.isEmpty()){
+ if ((!m_enabled || !m_particlesPerSecond)&& !m_burstLeft && m_burstQueue.isEmpty()){
m_reset_last = true;
return;
}
@@ -339,7 +353,7 @@ void QSGParticleEmitter::emitWindow(int timeStamp)
if (m_reset_last) {
m_last_emitter = m_last_last_emitter = QPointF(x(), y());
if (m_last_timestamp == -1)
- m_last_timestamp = timeStamp/1000. - m_startTime;
+ m_last_timestamp = (timeStamp - m_startTime)/1000.;
else
m_last_timestamp = timeStamp/1000.;
m_last_emission = m_last_timestamp;
@@ -350,12 +364,11 @@ void QSGParticleEmitter::emitWindow(int timeStamp)
if (m_burstLeft){
m_burstLeft -= timeStamp - m_last_timestamp * 1000.;
if (m_burstLeft < 0){
- if (!m_emitting)
+ if (!m_enabled)
timeStamp += m_burstLeft;
m_burstLeft = 0;
}
}
-
qreal time = timeStamp / 1000.;
qreal particleRatio = 1. / m_particlesPerSecond;
qreal pt = m_last_emission;
@@ -379,7 +392,7 @@ void QSGParticleEmitter::emitWindow(int timeStamp)
qreal sizeAtEnd = m_particleEndSize >= 0 ? m_particleEndSize : m_particleSize;
qreal emitter_x_offset = m_last_emitter.x() - x();
qreal emitter_y_offset = m_last_emitter.y() - y();
- if (!m_burstQueue.isEmpty() && !m_burstLeft && !m_emitting)//'outside time' emissions only
+ if (!m_burstQueue.isEmpty() && !m_burstLeft && !m_enabled)//'outside time' emissions only
pt = time;
while ((pt < time && m_emitCap) || !m_burstQueue.isEmpty()) {
//int pos = m_last_particle % m_particle_count;
diff --git a/src/declarative/particles/qsgparticleemitter_p.h b/src/declarative/particles/qsgparticleemitter_p.h
index 9e1fc7a9d8..8ed7ee7053 100644
--- a/src/declarative/particles/qsgparticleemitter_p.h
+++ b/src/declarative/particles/qsgparticleemitter_p.h
@@ -46,7 +46,7 @@
#include <QDebug>
#include "qsgparticlesystem_p.h"
#include "qsgparticleextruder_p.h"
-#include "qsgstochasticdirection_p.h"
+#include "qsgdirection_p.h"
#include <QList>
#include <QPair>
@@ -63,21 +63,20 @@ class QSGParticleEmitter : public QSGItem
Q_PROPERTY(QSGParticleSystem* system READ system WRITE setSystem NOTIFY systemChanged)
Q_PROPERTY(QString particle READ particle WRITE setParticle NOTIFY particleChanged)
Q_PROPERTY(QSGParticleExtruder* shape READ extruder WRITE setExtruder NOTIFY extruderChanged)
- Q_PROPERTY(bool emitting READ emitting WRITE setEmitting NOTIFY emittingChanged)
+ Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(int startTime READ startTime WRITE setStartTime NOTIFY startTimeChanged)
- Q_PROPERTY(bool noCap READ overwrite WRITE setOverWrite NOTIFY overwriteChanged)
Q_PROPERTY(qreal emitRate READ particlesPerSecond WRITE setParticlesPerSecond NOTIFY particlesPerSecondChanged)
Q_PROPERTY(int lifeSpan READ particleDuration WRITE setParticleDuration NOTIFY particleDurationChanged)
Q_PROPERTY(int lifeSpanVariation READ particleDurationVariation WRITE setParticleDurationVariation NOTIFY particleDurationVariationChanged)
- Q_PROPERTY(int emitCap READ maxParticleCount WRITE setMaxParticleCount NOTIFY maxParticleCountChanged)
+ Q_PROPERTY(int maximumEmitted READ maxParticleCount WRITE setMaxParticleCount NOTIFY maximumEmittedChanged)
Q_PROPERTY(qreal size READ particleSize WRITE setParticleSize NOTIFY particleSizeChanged)
Q_PROPERTY(qreal endSize READ particleEndSize WRITE setParticleEndSize NOTIFY particleEndSizeChanged)
Q_PROPERTY(qreal sizeVariation READ particleSizeVariation WRITE setParticleSizeVariation NOTIFY particleSizeVariationChanged)
- Q_PROPERTY(QSGStochasticDirection *speed READ speed WRITE setSpeed NOTIFY speedChanged)
- Q_PROPERTY(QSGStochasticDirection *acceleration READ acceleration WRITE setAcceleration NOTIFY accelerationChanged)
+ Q_PROPERTY(QSGDirection *speed READ speed WRITE setSpeed NOTIFY speedChanged)
+ Q_PROPERTY(QSGDirection *acceleration READ acceleration WRITE setAcceleration NOTIFY accelerationChanged)
Q_PROPERTY(qreal speedFromMovement READ speedFromMovement WRITE setSpeedFromMovement NOTIFY speedFromMovementChanged)
Q_ENUMS(Lifetime)
@@ -90,9 +89,9 @@ public:
InfiniteLife = QSGParticleSystem::maxLife
};
- bool emitting() const
+ bool enabled() const
{
- return m_emitting;
+ return m_enabled;
}
qreal particlesPerSecond() const
@@ -127,7 +126,7 @@ signals:
void emitParticle(QDeclarativeV8Handle particle);
void particlesPerSecondChanged(qreal);
void particleDurationChanged(int);
- void emittingChanged(bool);
+ void enabledChanged(bool);
void systemChanged(QSGParticleSystem* arg);
@@ -143,25 +142,23 @@ signals:
void particleSizeVariationChanged(qreal arg);
- void speedChanged(QSGStochasticDirection * arg);
+ void speedChanged(QSGDirection * arg);
- void accelerationChanged(QSGStochasticDirection * arg);
+ void accelerationChanged(QSGDirection * arg);
- void maxParticleCountChanged(int arg);
+ void maximumEmittedChanged(int arg);
void particleCountChanged();
void speedFromMovementChanged();
void startTimeChanged(int arg);
- void overwriteChanged(bool arg);
-
public slots:
void pulse(qreal seconds);
void burst(int num);
void burst(int num, qreal x, qreal y);
- void setEmitting(bool arg);
+ void setEnabled(bool arg);
void setParticlesPerSecond(qreal arg)
{
@@ -179,95 +176,87 @@ public slots:
}
}
- void setSystem(QSGParticleSystem* arg)
+ void setSystem(QSGParticleSystem* arg)
{
if (m_system != arg) {
m_system = arg;
m_system->registerParticleEmitter(this);
emit systemChanged(arg);
}
- }
-
- void setParticle(QString arg)
- {
- if (m_particle != arg) {
- m_particle = arg;
- emit particleChanged(arg);
- }
- }
+ }
- void setParticleDurationVariation(int arg)
- {
- if (m_particleDurationVariation != arg) {
- m_particleDurationVariation = arg;
- emit particleDurationVariationChanged(arg);
- }
- }
- void setExtruder(QSGParticleExtruder* arg)
- {
- if (m_extruder != arg) {
- m_extruder = arg;
- emit extruderChanged(arg);
- }
- }
+ void setParticle(QString arg)
+ {
+ if (m_particle != arg) {
+ m_particle = arg;
+ emit particleChanged(arg);
+ }
+ }
- void setParticleSize(qreal arg)
- {
- if (m_particleSize != arg) {
- m_particleSize = arg;
- emit particleSizeChanged(arg);
- }
- }
+ void setParticleDurationVariation(int arg)
+ {
+ if (m_particleDurationVariation != arg) {
+ m_particleDurationVariation = arg;
+ emit particleDurationVariationChanged(arg);
+ }
+ }
+ void setExtruder(QSGParticleExtruder* arg)
+ {
+ if (m_extruder != arg) {
+ m_extruder = arg;
+ emit extruderChanged(arg);
+ }
+ }
- void setParticleEndSize(qreal arg)
- {
- if (m_particleEndSize != arg) {
- m_particleEndSize = arg;
- emit particleEndSizeChanged(arg);
- }
- }
+ void setParticleSize(qreal arg)
+ {
+ if (m_particleSize != arg) {
+ m_particleSize = arg;
+ emit particleSizeChanged(arg);
+ }
+ }
- void setParticleSizeVariation(qreal arg)
- {
- if (m_particleSizeVariation != arg) {
- m_particleSizeVariation = arg;
- emit particleSizeVariationChanged(arg);
- }
- }
+ void setParticleEndSize(qreal arg)
+ {
+ if (m_particleEndSize != arg) {
+ m_particleEndSize = arg;
+ emit particleEndSizeChanged(arg);
+ }
+ }
- void setSpeed(QSGStochasticDirection * arg)
- {
- if (m_speed != arg) {
- m_speed = arg;
- emit speedChanged(arg);
- }
- }
+ void setParticleSizeVariation(qreal arg)
+ {
+ if (m_particleSizeVariation != arg) {
+ m_particleSizeVariation = arg;
+ emit particleSizeVariationChanged(arg);
+ }
+ }
- void setAcceleration(QSGStochasticDirection * arg)
- {
- if (m_acceleration != arg) {
- m_acceleration = arg;
- emit accelerationChanged(arg);
- }
- }
+ void setSpeed(QSGDirection * arg)
+ {
+ if (m_speed != arg) {
+ m_speed = arg;
+ emit speedChanged(arg);
+ }
+ }
- void setMaxParticleCount(int arg);
+ void setAcceleration(QSGDirection * arg)
+ {
+ if (m_acceleration != arg) {
+ m_acceleration = arg;
+ emit accelerationChanged(arg);
+ }
+ }
- void setStartTime(int arg)
- {
- if (m_startTime != arg) {
- m_startTime = arg;
- emit startTimeChanged(arg);
- }
- }
+ void setMaxParticleCount(int arg);
- void setOverWrite(bool arg)
- {
- if (m_overwrite != arg) {
- m_overwrite = arg;
- emit overwriteChanged(arg);
- }
- }
+ void setStartTime(int arg)
+ {
+ if (m_startTime != arg) {
+ m_startTime = arg;
+ emit startTimeChanged(arg);
+ }
+ }
virtual void reset();
public:
@@ -293,12 +282,12 @@ public:
return m_particleSizeVariation;
}
- QSGStochasticDirection * speed() const
+ QSGDirection * speed() const
{
return m_speed;
}
- QSGStochasticDirection * acceleration() const
+ QSGDirection * acceleration() const
{
return m_acceleration;
}
@@ -313,23 +302,18 @@ public:
return m_startTime;
}
- bool overwrite() const
- {
- return m_overwrite;
- }
-
protected:
qreal m_particlesPerSecond;
int m_particleDuration;
int m_particleDurationVariation;
- bool m_emitting;
+ bool m_enabled;
QSGParticleSystem* m_system;
QString m_particle;
QSGParticleExtruder* m_extruder;
QSGParticleExtruder* m_defaultExtruder;
QSGParticleExtruder* effectiveExtruder();
- QSGStochasticDirection * m_speed;
- QSGStochasticDirection * m_acceleration;
+ QSGDirection * m_speed;
+ QSGDirection * m_acceleration;
qreal m_particleSize;
qreal m_particleEndSize;
qreal m_particleSizeVariation;
@@ -356,7 +340,7 @@ protected:
bool isEmitConnected();
private:
- QSGStochasticDirection m_nullVector;
+ QSGDirection m_nullVector;
};
diff --git a/src/declarative/particles/qsgparticleextruder.cpp b/src/declarative/particles/qsgparticleextruder.cpp
index a390bb92ac..73c8ce0a66 100644
--- a/src/declarative/particles/qsgparticleextruder.cpp
+++ b/src/declarative/particles/qsgparticleextruder.cpp
@@ -52,30 +52,14 @@ QT_BEGIN_NAMESPACE
*/
QSGParticleExtruder::QSGParticleExtruder(QObject *parent) :
- QObject(parent), m_fill(true)
+ QObject(parent)
{
}
QPointF QSGParticleExtruder::extrude(const QRectF &rect)
{
- if (m_fill)
- return QPointF(((qreal)rand() / RAND_MAX) * rect.width() + rect.x(),
- ((qreal)rand() / RAND_MAX) * rect.height() + rect.y());
- int side = rand() % 4;
- switch (side){//TODO: Doesn't this overlap the corners?
- case 0:
- return QPointF(rect.x(),
- ((qreal)rand() / RAND_MAX) * rect.height() + rect.y());
- case 1:
- return QPointF(rect.width() + rect.x(),
- ((qreal)rand() / RAND_MAX) * rect.height() + rect.y());
- case 2:
- return QPointF(((qreal)rand() / RAND_MAX) * rect.width() + rect.x(),
- rect.y());
- default:
- return QPointF(((qreal)rand() / RAND_MAX) * rect.width() + rect.x(),
- rect.height() + rect.y());
- }
+ return QPointF(((qreal)rand() / RAND_MAX) * rect.width() + rect.x(),
+ ((qreal)rand() / RAND_MAX) * rect.height() + rect.y());
}
bool QSGParticleExtruder::contains(const QRectF &bounds, const QPointF &point)
diff --git a/src/declarative/particles/qsgparticleextruder_p.h b/src/declarative/particles/qsgparticleextruder_p.h
index bb2cc24ac2..b31b80231d 100644
--- a/src/declarative/particles/qsgparticleextruder_p.h
+++ b/src/declarative/particles/qsgparticleextruder_p.h
@@ -55,32 +55,15 @@ QT_MODULE(Declarative)
class QSGParticleExtruder : public QObject
{
Q_OBJECT
- Q_PROPERTY(bool fill READ fill WRITE setFill NOTIFY fillChanged)//###Should this be base class, or a BoxExtruder?
public:
explicit QSGParticleExtruder(QObject *parent = 0);
virtual QPointF extrude(const QRectF &);
- virtual bool contains(const QRectF &bounds, const QPointF &point);//###Needed for follow emitter, but does it belong? Only marginally conceptually valid, and that's from user's perspective
- bool fill() const
- {
- return m_fill;
- }
+ virtual bool contains(const QRectF &bounds, const QPointF &point);
signals:
-
- void fillChanged(bool arg);
-
public slots:
-
- void setFill(bool arg)
- {
- if (m_fill != arg) {
- m_fill = arg;
- emit fillChanged(arg);
- }
- }
protected:
- bool m_fill;
};
QT_END_NAMESPACE
diff --git a/src/declarative/particles/qsgparticlepainter.cpp b/src/declarative/particles/qsgparticlepainter.cpp
index 97333ff20b..f4639c20a2 100644
--- a/src/declarative/particles/qsgparticlepainter.cpp
+++ b/src/declarative/particles/qsgparticlepainter.cpp
@@ -103,12 +103,16 @@ void QSGParticlePainter::setSystem(QSGParticleSystem *arg)
void QSGParticlePainter::load(QSGParticleData* d)
{
+ if (m_pleaseReset)
+ return;
initialize(d->group, d->index);
m_pendingCommits << qMakePair<int, int>(d->group, d->index);
}
void QSGParticlePainter::reload(QSGParticleData* d)
{
+ if (m_pleaseReset)
+ return;
m_pendingCommits << qMakePair<int, int>(d->group, d->index);
}
diff --git a/src/declarative/particles/qsgparticlesmodule.cpp b/src/declarative/particles/qsgparticlesmodule.cpp
index e6076b925f..9fa0ebad97 100644
--- a/src/declarative/particles/qsgparticlesmodule.cpp
+++ b/src/declarative/particles/qsgparticlesmodule.cpp
@@ -39,18 +39,17 @@
**
****************************************************************************/
-#include "qsgangleddirection_p.h"
+#include "qsgangledirection_p.h"
#include "qsgcustomparticle_p.h"
#include "qsgellipseextruder_p.h"
-#include "qsgfollowemitter_p.h"
+#include "qsgtrailemitter_p.h"
#include "qsgfriction_p.h"
#include "qsggravity_p.h"
#include "qsgimageparticle_p.h"
#include "qsgitemparticle_p.h"
-#include "qsgkill_p.h"
+#include "qsgage_p.h"
#include "qsglineextruder_p.h"
#include "qsgmaskextruder_p.h"
-#include "qsgmodelparticle_p.h"
#include "qsgparticleaffector_p.h"
#include "qsgparticleemitter_p.h"
#include "qsgparticleextruder_p.h"
@@ -60,12 +59,14 @@
#include "qsgpointattractor_p.h"
#include "qsgpointdirection_p.h"
#include "qsgspritegoal_p.h"
-#include "qsgstochasticdirection_p.h"
-#include "qsgtargeteddirection_p.h"
+#include "qsgdirection_p.h"
+#include "qsgtargetdirection_p.h"
#include "qsgturbulence_p.h"
#include "qsgwander_p.h"
#include "qsgtargetaffector_p.h"
#include "qsgcumulativedirection_p.h"
+#include "qsgcustomaffector_p.h"
+#include "qsgrectangleextruder_p.h"
QT_BEGIN_NAMESPACE
@@ -78,34 +79,35 @@ void QSGParticlesModule::defineModule()
qmlRegisterType<QSGImageParticle>(uri, 2, 0, "ImageParticle");
qmlRegisterType<QSGCustomParticle>(uri, 2, 0, "CustomParticle");
qmlRegisterType<QSGItemParticle>(uri, 2, 0, "ItemParticle");
- qmlRegisterType<QSGModelParticle>(uri, 2, 0, "ModelParticle");
qmlRegisterType<QSGParticleEmitter>(uri, 2, 0, "Emitter");
- qmlRegisterType<QSGFollowEmitter>(uri, 2, 0, "FollowEmitter");
+ qmlRegisterType<QSGTrailEmitter>(uri, 2, 0, "TrailEmitter");
qmlRegisterType<QSGEllipseExtruder>(uri, 2, 0, "EllipseShape");
+ qmlRegisterType<QSGRectangleExtruder>(uri, 2, 0, "RectangleShape");
qmlRegisterType<QSGLineExtruder>(uri, 2, 0, "LineShape");
qmlRegisterType<QSGMaskExtruder>(uri, 2, 0, "MaskShape");
qmlRegisterType<QSGPointDirection>(uri, 2, 0, "PointDirection");
- qmlRegisterType<QSGAngledDirection>(uri, 2, 0, "AngledDirection");
- qmlRegisterType<QSGTargetedDirection>(uri, 2, 0, "TargetedDirection");
+ qmlRegisterType<QSGAngleDirection>(uri, 2, 0, "AngleDirection");
+ qmlRegisterType<QSGTargetDirection>(uri, 2, 0, "TargetDirection");
qmlRegisterType<QSGCumulativeDirection>(uri, 2, 0, "CumulativeDirection");
- qmlRegisterType<QSGParticleAffector>(uri, 2, 0, "Affector");//useful for the triggered signal
+ qmlRegisterType<QSGCustomAffector>(uri, 2, 0, "Affector");
qmlRegisterType<QSGWanderAffector>(uri, 2, 0, "Wander");
qmlRegisterType<QSGFrictionAffector>(uri, 2, 0, "Friction");
- qmlRegisterType<QSGPointAttractorAffector>(uri, 2, 0, "PointAttractor");
+ qmlRegisterType<QSGAttractorAffector>(uri, 2, 0, "Attractor");
qmlRegisterType<QSGGravityAffector>(uri, 2, 0, "Gravity");
- qmlRegisterType<QSGKillAffector>(uri, 2, 0, "Kill");
+ qmlRegisterType<QSGAgeAffector>(uri, 2, 0, "Age");
qmlRegisterType<QSGSpriteGoalAffector>(uri, 2, 0, "SpriteGoal");
qmlRegisterType<QSGTurbulenceAffector>(uri, 2, 0 , "Turbulence");
qmlRegisterType<QSGTargetAffector>(uri, 2, 0 , "Target");
//Exposed just for completeness
- qmlRegisterType<QSGParticlePainter>(uri, 2, 0, "ParticlePainter");
- qmlRegisterType<QSGParticleExtruder>(uri, 2, 0, "ParticleExtruder");
- qmlRegisterType<QSGStochasticDirection>(uri, 2, 0, "NullVector");
+ qmlRegisterUncreatableType<QSGParticleAffector>(uri, 2, 0, "ParticleAffector", "Abstract type. Use one of the inheriting types instead.");
+ qmlRegisterUncreatableType<QSGParticlePainter>(uri, 2, 0, "ParticlePainter", "Abstract type. Use one of the inheriting types instead.");
+ qmlRegisterUncreatableType<QSGParticleExtruder>(uri, 2, 0, "ParticleExtruder", "Abstract type. Use one of the inheriting types instead.");
+ qmlRegisterUncreatableType<QSGDirection>(uri, 2, 0, "NullVector", "Abstract type. Use one of the inheriting types instead.");
}
QT_END_NAMESPACE
diff --git a/src/declarative/particles/qsgparticlesystem.cpp b/src/declarative/particles/qsgparticlesystem.cpp
index 534b1ca8a1..425df349e5 100644
--- a/src/declarative/particles/qsgparticlesystem.cpp
+++ b/src/declarative/particles/qsgparticlesystem.cpp
@@ -48,7 +48,7 @@
#include "qsgsprite_p.h"
#include "qsgv8particledata_p.h"
-#include "qsgfollowemitter_p.h"//###For auto-follow on states, perhaps should be in emitter?
+#include "qsgtrailemitter_p.h"//###For auto-follow on states, perhaps should be in emitter?
#include <private/qdeclarativeengine_p.h>
#include <cmath>
#include <QDebug>
@@ -99,13 +99,6 @@ DEFINE_BOOL_CONFIG_OPTION(qmlParticlesDebug, QML_PARTICLES_DEBUG)
*/
/*!
- \qmlproperty int QtQuick.Particles2::ParticleSystem::startTime
-
- If start time is specified, then the system will simulate up to this time
- before the system starts playing. This allows you to appear to start with a
- fully populated particle system, instead of starting with no particles visible.
-*/
-/*!
\qmlproperty list<Sprite> QtQuick.Particles2::ParticleSystem::particleStates
You can define a sub-set of particle groups in this property in order to provide them
@@ -113,10 +106,55 @@ DEFINE_BOOL_CONFIG_OPTION(qmlParticlesDebug, QML_PARTICLES_DEBUG)
Each QtQuick2::Sprite in this list is interpreted as corresponding to the particle group
with ths same name. Any transitions defined in these sprites will take effect on the particle
- groups as well. Additionally FollowEmitters, Affectors and ParticlePainters definined
+ groups as well. Additionally TrailEmitters, Affectors and ParticlePainters definined
inside one of these sprites are automatically associated with the corresponding particle group.
*/
+/*!
+ \qmlmethod void QtQuick.Particles2::ParticleSystem::pause
+
+ Pauses the simulation if it is running.
+
+ \sa resume, paused
+*/
+
+/*!
+ \qmlmethod void QtQuick.Particles2::ParticleSystem::resume
+
+ Resumes the simulation if it is paused.
+
+ \sa pause, paused
+*/
+
+/*!
+ \qmlmethod void QtQuick.Particles2::ParticleSystem::start
+
+ Starts the simulation if it has not already running.
+
+ \sa stop, restart, running
+*/
+
+/*!
+ \qmlmethod void QtQuick.Particles2::ParticleSystem::stop
+
+ Stops the simulation if it is running.
+
+ \sa start, restart, running
+*/
+
+/*!
+ \qmlmethod void QtQuick.Particles2::ParticleSystem::restart
+
+ Stops the simulation if it is running, and then starts it.
+
+ \sa stop, restart, running
+*/
+/*!
+ \qmlmethod void QtQuick.Particles2::ParticleSystem::reset
+
+ Discards all currently existing particles.
+
+*/
const qreal EPSILON = 0.001;
//Utility functions for when within 1ms is close enough
bool timeEqualOrGreater(qreal a, qreal b){
@@ -562,8 +600,8 @@ void QSGParticleData::extendLife(float time)
}
QSGParticleSystem::QSGParticleSystem(QSGItem *parent) :
- QSGItem(parent), m_particle_count(0), m_running(true)
- , m_startTime(0), m_nextIndex(0), m_componentComplete(false), m_spriteEngine(0)
+ QSGItem(parent), m_particle_count(0), m_running(true), m_paused(false)
+ , m_nextIndex(0), m_componentComplete(false), m_spriteEngine(0)
{
connect(&m_painterMapper, SIGNAL(mapped(QObject*)),
this, SLOT(loadPainter(QObject*)));
@@ -663,7 +701,7 @@ void QSGParticleSystem::stateRedirect(QDeclarativeListProperty<QObject> *prop, Q
a->setSystem(sys);
return;
}
- QSGFollowEmitter* fe = qobject_cast<QSGFollowEmitter*>(value);
+ QSGTrailEmitter* fe = qobject_cast<QSGTrailEmitter*>(value);
if (fe){
fe->setParentItem(sys);
fe->setFollow(sprite->name());
@@ -726,8 +764,9 @@ void QSGParticleSystem::reset()
//### Do affectors need reset too?
- if (m_animation){//reset restarts animation (if running)
- m_animation->stop();
+ if (m_running) {//reset restarts animation (if running)
+ if ((m_animation->state() == QAbstractAnimation::Running))
+ m_animation->stop();
m_animation->start();
if (m_paused)
m_animation->pause();
@@ -927,7 +966,7 @@ QSGParticleData* QSGParticleSystem::newDatum(int groupId, bool respectLimits, in
if (m_spriteEngine)
m_spriteEngine->startSprite(ret->systemIndex, ret->group);
- m_clear = false;
+ m_empty = false;
return ret;
}
@@ -962,15 +1001,15 @@ void QSGParticleSystem::updateCurrentTime( int currentTime )
//### Elapsed time never shrinks - may cause problems if left emitting for weeks at a time.
qreal dt = m_timeInt / 1000.;
- m_timeInt = currentTime + m_startTime;
+ m_timeInt = currentTime;
qreal time = m_timeInt / 1000.;
dt = time - dt;
m_needsReset.clear();
- bool oldClear = m_clear;
- m_clear = true;
+ bool oldClear = m_empty;
+ m_empty = true;
foreach (QSGParticleGroupData* gd, m_groupData)//Recycle all groups and see if they're out of live particles
- m_clear = m_clear && gd->recycle();
+ m_empty = m_empty && gd->recycle();
if (m_spriteEngine)
m_spriteEngine->updateSprites(m_timeInt);
@@ -986,8 +1025,8 @@ void QSGParticleSystem::updateCurrentTime( int currentTime )
if (p && d)
p->reload(d);
- if (oldClear != m_clear)
- clearChanged(m_clear);
+ if (oldClear != m_empty)
+ emptyChanged(m_empty);
}
int QSGParticleSystem::systemSync(QSGParticlePainter* p)
diff --git a/src/declarative/particles/qsgparticlesystem_p.h b/src/declarative/particles/qsgparticlesystem_p.h
index 17b67d9cce..25a0c87f53 100644
--- a/src/declarative/particles/qsgparticlesystem_p.h
+++ b/src/declarative/particles/qsgparticlesystem_p.h
@@ -222,8 +222,7 @@ class QSGParticleSystem : public QSGItem
Q_OBJECT
Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged)
Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
- Q_PROPERTY(bool clear READ isClear NOTIFY clearChanged)
- Q_PROPERTY(int startTime READ startTime WRITE setStartTime NOTIFY startTimeChanged)
+ Q_PROPERTY(bool empty READ isEmpty NOTIFY emptyChanged)
Q_PROPERTY(QDeclarativeListProperty<QSGSprite> particleStates READ particleStates)
public:
@@ -237,11 +236,6 @@ public:
return m_running;
}
- int startTime() const
- {
- return m_startTime;
- }
-
int count(){ return m_particle_count; }
static const int maxLife = 600000;
@@ -250,13 +244,8 @@ signals:
void systemInitialized();
void runningChanged(bool arg);
-
- void startTimeChanged(int arg);
-
-
void pausedChanged(bool arg);
-
- void clearChanged(bool arg);
+ void emptyChanged(bool arg);
public slots:
void start(){setRunning(true);}
@@ -269,16 +258,6 @@ public slots:
void setRunning(bool arg);
void setPaused(bool arg);
- void setStartTime(int arg)
- {
- m_startTime = arg;
- }
-
- void fastForward(int ms)
- {
- m_startTime += ms;
- }
-
virtual int duration() const { return -1; }
@@ -323,9 +302,9 @@ public://###but only really for related class usage. Perhaps we should all be fr
return m_paused;
}
- bool isClear() const
+ bool isEmpty() const
{
- return m_clear;
+ return m_empty;
}
private:
@@ -336,7 +315,6 @@ private:
QList<QPointer<QSGParticleAffector> > m_affectors;
QList<QPointer<QSGParticlePainter> > m_painters;
QList<QPointer<QSGParticlePainter> > m_syncList;
- qint64 m_startTime;
int m_nextGroupId;
int m_nextIndex;
QSet<int> m_reusableIndexes;
@@ -351,7 +329,7 @@ private:
bool m_paused;
bool m_debugMode;
bool m_allDead;
- bool m_clear;
+ bool m_empty;
};
// Internally, this animation drives all the timing. Painters sync up in their updatePaintNode
diff --git a/src/declarative/particles/qsgpointattractor.cpp b/src/declarative/particles/qsgpointattractor.cpp
index c916e4da94..8c2632f2c8 100644
--- a/src/declarative/particles/qsgpointattractor.cpp
+++ b/src/declarative/particles/qsgpointattractor.cpp
@@ -44,16 +44,16 @@
#include <QDebug>
QT_BEGIN_NAMESPACE
/*!
- \qmlclass PointAttractor QSGPointAttractorAffector
+ \qmlclass Attractor QSGAttractorAffector
\inqmlmodule QtQuick.Particles 2
\inherits Affector
- \brief The PointAttractor allows you to attract particles towards a specific point.
+ \brief The Attractor allows you to attract particles towards a specific point.
Note that the size and position of this element affects which particles it affects.
The size of the point attracted to is always 0x0, and the location of that point
is specified by the pointX and pointY properties.
- Note that PointAttractor has the standard Item x,y,width and height properties.
+ Note that Attractor has the standard Item x,y,width and height properties.
Like other affectors, these represent the affected area. They
do not represent the 0x0 point which is the target of the attraction.
@@ -62,45 +62,57 @@ QT_BEGIN_NAMESPACE
/*!
\qmlproperty real QtQuick.Particles2::PointAttractor::pointX
+
+ The x coordinate of the attracting point. This is relative
+ to the x coordinate of the Attractor.
*/
/*!
\qmlproperty real QtQuick.Particles2::PointAttractor::pointY
+
+ The x coordinate of the attracting point. This is relative
+ to the x coordinate of the Attractor.
*/
/*!
\qmlproperty real QtQuick.Particles2::PointAttractor::strength
+
+ The pull, in units per second, to be exerted on an item one pixel away.
+
+ Depending on how the attraction is proportionalToDistance this may have to
+ be very high or very low to have a reasonable effect on particles at a
+ distance.
*/
/*!
- \qmlproperty PhysicsAffects QtQuick.Particles2::PointAttractor::physics
+ \qmlproperty AffectableParameter QtQuick.Particles2::Attractor::affectedParameter
What attribute of particles is directly affected.
\list
- \o PointAttractor.Position
- \o PointAttractor.Velocity
- \o PointAttractor.Acceleration
+ \o Attractor.Position
+ \o Attractor.Velocity
+ \o Attractor.Acceleration
\endlist
*/
/*!
- \qmlproperty Proportion QtQuick.Particles2::PointAttractor::proportionalToDistance
+ \qmlproperty Proportion QtQuick.Particles2::Attractor::proportionalToDistance
How the distance from the particle to the point affects the strength of the attraction.
\list
- \o PointAttractor.Constant
- \o PointAttractor.Linear
- \o PointAttractor.InverseLinear
- \o PointAttractor.Quadratic
- \o PointAttractor.InverseQuadratic
+ \o Attractor.Constant
+ \o Attractor.Linear
+ \o Attractor.InverseLinear
+ \o Attractor.Quadratic
+ \o Attractor.InverseQuadratic
\endlist
*/
-QSGPointAttractorAffector::QSGPointAttractorAffector(QSGItem *parent) :
+QSGAttractorAffector::QSGAttractorAffector(QSGItem *parent) :
QSGParticleAffector(parent), m_strength(0.0), m_x(0), m_y(0)
, m_physics(Velocity), m_proportionalToDistance(Linear)
{
}
-bool QSGPointAttractorAffector::affectParticle(QSGParticleData *d, qreal dt)
+bool QSGAttractorAffector::affectParticle(QSGParticleData *d, qreal dt)
{
if (m_strength == 0.0)
return false;
diff --git a/src/declarative/particles/qsgpointattractor_p.h b/src/declarative/particles/qsgpointattractor_p.h
index e2cdd0fdca..75dd47e331 100644
--- a/src/declarative/particles/qsgpointattractor_p.h
+++ b/src/declarative/particles/qsgpointattractor_p.h
@@ -49,15 +49,15 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QSGPointAttractorAffector : public QSGParticleAffector
+class QSGAttractorAffector : public QSGParticleAffector
{
Q_OBJECT
Q_PROPERTY(qreal strength READ strength WRITE setStrength NOTIFY strengthChanged)
Q_PROPERTY(qreal pointX READ pointX WRITE setPointX NOTIFY pointXChanged)
Q_PROPERTY(qreal pointY READ pointY WRITE setPointY NOTIFY pointYChanged)
- Q_PROPERTY(PhysicsAffects physics READ physics WRITE setPhysics NOTIFY physicsChanged)
+ Q_PROPERTY(AffectableParameters affectedParameter READ affectedParameter WRITE setAffectedParameter NOTIFY affectedParameterChanged)
Q_PROPERTY(Proportion proportionalToDistance READ proportionalToDistance WRITE setProportionalToDistance NOTIFY proportionalToDistanceChanged)
- Q_ENUMS(PhysicsAffects)
+ Q_ENUMS(AffectableParameters)
Q_ENUMS(Proportion)
public:
@@ -69,13 +69,13 @@ public:
InverseQuadratic
};
- enum PhysicsAffects {
+ enum AffectableParameters {
Position,
Velocity,
Acceleration
};
- explicit QSGPointAttractorAffector(QSGItem *parent = 0);
+ explicit QSGAttractorAffector(QSGItem *parent = 0);
qreal strength() const
{
@@ -92,7 +92,7 @@ public:
return m_y;
}
- PhysicsAffects physics() const
+ AffectableParameters affectedParameter() const
{
return m_physics;
}
@@ -110,7 +110,7 @@ signals:
void pointYChanged(qreal arg);
- void physicsChanged(PhysicsAffects arg);
+ void affectedParameterChanged(AffectableParameters arg);
void proportionalToDistanceChanged(Proportion arg);
@@ -138,11 +138,11 @@ void setPointY(qreal arg)
emit pointYChanged(arg);
}
}
-void setPhysics(PhysicsAffects arg)
+void setAffectedParameter(AffectableParameters arg)
{
if (m_physics != arg) {
m_physics = arg;
- emit physicsChanged(arg);
+ emit affectedParameterChanged(arg);
}
}
@@ -160,7 +160,7 @@ private:
qreal m_strength;
qreal m_x;
qreal m_y;
-PhysicsAffects m_physics;
+AffectableParameters m_physics;
Proportion m_proportionalToDistance;
};
diff --git a/src/declarative/particles/qsgpointdirection.cpp b/src/declarative/particles/qsgpointdirection.cpp
index 7cc0823eec..dc104c1a81 100644
--- a/src/declarative/particles/qsgpointdirection.cpp
+++ b/src/declarative/particles/qsgpointdirection.cpp
@@ -46,7 +46,7 @@ QT_BEGIN_NAMESPACE
/*!
\qmlclass PointDirection QSGPointDirection
\inqmlmodule QtQuick.Particles 2
- \inherits StochasticDirection
+ \inherits Direction
\brief The PointDirection element allows you to specify a direction that varies in x and y components
The PointDirection element allows both the specification of a direction by x and y components,
@@ -66,7 +66,7 @@ QT_BEGIN_NAMESPACE
*/
QSGPointDirection::QSGPointDirection(QObject *parent) :
- QSGStochasticDirection(parent)
+ QSGDirection(parent)
, m_x(0)
, m_y(0)
, m_xVariation(0)
diff --git a/src/declarative/particles/qsgpointdirection_p.h b/src/declarative/particles/qsgpointdirection_p.h
index 6a6beb6623..ca00824a3e 100644
--- a/src/declarative/particles/qsgpointdirection_p.h
+++ b/src/declarative/particles/qsgpointdirection_p.h
@@ -41,7 +41,7 @@
#ifndef POINTVECTOR_H
#define POINTVECTOR_H
-#include "qsgstochasticdirection_p.h"
+#include "qsgdirection_p.h"
QT_BEGIN_HEADER
@@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QSGPointDirection : public QSGStochasticDirection
+class QSGPointDirection : public QSGDirection
{
Q_OBJECT
Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged)
diff --git a/src/declarative/particles/qsgrectangleextruder.cpp b/src/declarative/particles/qsgrectangleextruder.cpp
new file mode 100644
index 0000000000..accc88fcdb
--- /dev/null
+++ b/src/declarative/particles/qsgrectangleextruder.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Declarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsgrectangleextruder_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \qmlclass RectangleShape QSGRectangleExtruder
+ \inqmlmodule QtQuick.Particles 2
+ \brief The RectangleShape element allows you to specify an area for affectors and emitter.
+
+ Just a rectangle.
+*/
+
+QSGRectangleExtruder::QSGRectangleExtruder(QObject *parent) :
+ QObject(parent), m_fill(true)
+{
+}
+
+QPointF QSGRectangleExtruder::extrude(const QRectF &rect)
+{
+ if (m_fill)
+ return QPointF(((qreal)rand() / RAND_MAX) * rect.width() + rect.x(),
+ ((qreal)rand() / RAND_MAX) * rect.height() + rect.y());
+ int side = rand() % 4;
+ switch (side){//TODO: Doesn't this overlap the corners?
+ case 0:
+ return QPointF(rect.x(),
+ ((qreal)rand() / RAND_MAX) * rect.height() + rect.y());
+ case 1:
+ return QPointF(rect.width() + rect.x(),
+ ((qreal)rand() / RAND_MAX) * rect.height() + rect.y());
+ case 2:
+ return QPointF(((qreal)rand() / RAND_MAX) * rect.width() + rect.x(),
+ rect.y());
+ default:
+ return QPointF(((qreal)rand() / RAND_MAX) * rect.width() + rect.x(),
+ rect.height() + rect.y());
+ }
+}
+
+bool QSGRectangleExtruder::contains(const QRectF &bounds, const QPointF &point)
+{
+ return bounds.contains(point);
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/particles/qsgrectangleextruder_p.h b/src/declarative/particles/qsgrectangleextruder_p.h
new file mode 100644
index 0000000000..5795375c84
--- /dev/null
+++ b/src/declarative/particles/qsgrectangleextruder_p.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Declarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef RECTANGLEEXTRUDER_H
+#define RECTANGLEEXTRUDER_H
+
+#include "qsgparticleextruder_p.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QSGRectangleExtruder : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(bool fill READ fill WRITE setFill NOTIFY fillChanged)
+
+public:
+ explicit QSGRectangleExtruder(QObject *parent = 0);
+ virtual QPointF extrude(const QRectF &);
+ virtual bool contains(const QRectF &bounds, const QPointF &point);
+ bool fill() const
+ {
+ return m_fill;
+ }
+
+signals:
+
+ void fillChanged(bool arg);
+
+public slots:
+
+ void setFill(bool arg)
+ {
+ if (m_fill != arg) {
+ m_fill = arg;
+ emit fillChanged(arg);
+ }
+ }
+protected:
+ bool m_fill;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // RectangleEXTRUDER_H
diff --git a/src/declarative/particles/qsgtargeteddirection.cpp b/src/declarative/particles/qsgtargetdirection.cpp
index 696cdfa915..d9a3ce5a74 100644
--- a/src/declarative/particles/qsgtargeteddirection.cpp
+++ b/src/declarative/particles/qsgtargetdirection.cpp
@@ -39,41 +39,41 @@
**
****************************************************************************/
-#include "qsgtargeteddirection_p.h"
+#include "qsgtargetdirection_p.h"
#include "qsgparticleemitter_p.h"
#include <cmath>
#include <QDebug>
QT_BEGIN_NAMESPACE
/*!
- \qmlclass TargetedDirection QSGTargetedDirection
+ \qmlclass TargetDirection QSGTargetDirection
\inqmlmodule QtQuick.Particles 2
- \inherits StochasticDirection
- \brief The TargetedDirection element allows you to specify a direction towards the target point
+ \inherits Direction
+ \brief The TargetDirection element allows you to specify a direction towards the target point
*/
/*!
- \qmlproperty real QtQuick.Particles2::TargetedDirection::targetX
+ \qmlproperty real QtQuick.Particles2::TargetDirection::targetX
*/
/*!
- \qmlproperty real QtQuick.Particles2::TargetedDirection::targetY
+ \qmlproperty real QtQuick.Particles2::TargetDirection::targetY
*/
/*!
- \qmlproperty Item QtQuick.Particles2::TargetedDirection::targetItem
+ \qmlproperty Item QtQuick.Particles2::TargetDirection::targetItem
If specified, this will take precedence over targetX and targetY.
The targeted point will be the center of the specified Item
*/
/*!
- \qmlproperty real QtQuick.Particles2::TargetedDirection::targetVariation
+ \qmlproperty real QtQuick.Particles2::TargetDirection::targetVariation
*/
/*!
- \qmlproperty real QtQuick.Particles2::TargetedDirection::magnitude
+ \qmlproperty real QtQuick.Particles2::TargetDirection::magnitude
*/
/*!
- \qmlproperty real QtQuick.Particles2::TargetedDirection::magnitudeVariation
+ \qmlproperty real QtQuick.Particles2::TargetDirection::magnitudeVariation
*/
/*!
- \qmlproperty bool QtQuick.Particles2::TargetedDirection::proportionalMagnitude
+ \qmlproperty bool QtQuick.Particles2::TargetDirection::proportionalMagnitude
If true, then the value of magnitude and magnitudeVariation shall be interpreted as multiples
of the distance between the source point and the target point, per second.
@@ -82,8 +82,8 @@ QT_BEGIN_NAMESPACE
pixels per second.
*/
-QSGTargetedDirection::QSGTargetedDirection(QObject *parent) :
- QSGStochasticDirection(parent)
+QSGTargetDirection::QSGTargetDirection(QObject *parent) :
+ QSGDirection(parent)
, m_targetX(0)
, m_targetY(0)
, m_targetVariation(0)
@@ -94,7 +94,7 @@ QSGTargetedDirection::QSGTargetedDirection(QObject *parent) :
{
}
-const QPointF &QSGTargetedDirection::sample(const QPointF &from)
+const QPointF &QSGTargetDirection::sample(const QPointF &from)
{
//###This approach loses interpolating the last position of the target (like we could with the emitter) is it worthwhile?
qreal targetX;
diff --git a/src/declarative/particles/qsgtargeteddirection_p.h b/src/declarative/particles/qsgtargetdirection_p.h
index 6fdd3f937d..8f4901a57b 100644
--- a/src/declarative/particles/qsgtargeteddirection_p.h
+++ b/src/declarative/particles/qsgtargetdirection_p.h
@@ -41,7 +41,7 @@
#ifndef DIRECTEDVECTOR_H
#define DIRECTEDVECTOR_H
-#include "qsgstochasticdirection_p.h"
+#include "qsgdirection_p.h"
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
class QSGItem;
-class QSGTargetedDirection : public QSGStochasticDirection
+class QSGTargetDirection : public QSGDirection
{
Q_OBJECT
Q_PROPERTY(qreal targetX READ targetX WRITE setTargetX NOTIFY targetXChanged)
@@ -65,7 +65,7 @@ class QSGTargetedDirection : public QSGStochasticDirection
Q_PROPERTY(qreal magnitudeVariation READ magnitudeVariation WRITE setMagnitudeVariation NOTIFY magnitudeVariationChanged)
public:
- explicit QSGTargetedDirection(QObject *parent = 0);
+ explicit QSGTargetDirection(QObject *parent = 0);
virtual const QPointF &sample(const QPointF &from);
qreal targetX() const
diff --git a/src/declarative/particles/qsgfollowemitter.cpp b/src/declarative/particles/qsgtrailemitter.cpp
index 68f0f6bf75..6bccf3ba8c 100644
--- a/src/declarative/particles/qsgfollowemitter.cpp
+++ b/src/declarative/particles/qsgtrailemitter.cpp
@@ -39,21 +39,20 @@
**
****************************************************************************/
-#include "qsgfollowemitter_p.h"
-#include "qsgparticlepainter_p.h"//TODO: What was this for again?
+#include "qsgtrailemitter_p.h"
#include <cmath>
QT_BEGIN_NAMESPACE
/*!
- \qmlclass FollowEmitter QSGFollowEmitter
+ \qmlclass TrailEmitter QSGTrailEmitter
\inqmlmodule QtQuick.Particles 2
\inherits QSGParticleEmitter
- \brief The FollowEmitter element allows you to emit logical particles from other logical particles.
+ \brief The TrailEmitter element allows you to emit logical particles from other logical particles.
This element emits logical particles into the ParticleSystem, with the
starting positions based on those of other logical particles.
*/
-QSGFollowEmitter::QSGFollowEmitter(QSGItem *parent) :
+QSGTrailEmitter::QSGTrailEmitter(QSGItem *parent) :
QSGParticleEmitter(parent)
, m_particlesPerParticlePerSecond(0)
, m_lastTimeStamp(0)
@@ -73,28 +72,37 @@ QSGFollowEmitter::QSGFollowEmitter(QSGItem *parent) :
}
/*!
- \qmlproperty string QtQuick.Particles2::FollowEmitter::follow
+ \qmlproperty string QtQuick.Particles2::TrailEmitter::follow
The type of logical particle which this is emitting from.
*/
+/*!
+ \qmlproperty qreal QtQuick.Particles2::TrailEmitter::speedFromMovement
+
+ If this value is non-zero, then any movement of the emitter will provide additional
+ starting velocity to the particles based on the movement. The additional vector will be the
+ same angle as the emitter's movement, with a magnitude that is the magnitude of the emitters
+ movement multiplied by speedFromMovement.
+ Default value is 0.
+*/
/*!
- \qmlproperty Shape QtQuick.Particles2::FollowEmitter::emitShape
+ \qmlproperty Shape QtQuick.Particles2::TrailEmitter::emitShape
- As the area of a FollowEmitter is the area it follows, a separate shape can be provided
+ As the area of a TrailEmitter is the area it follows, a separate shape can be provided
to be the shape it emits out of.
*/
/*!
- \qmlproperty real QtQuick.Particles2::FollowEmitter::emitWidth
+ \qmlproperty real QtQuick.Particles2::TrailEmitter::emitWidth
*/
/*!
- \qmlproperty real QtQuick.Particles2::FollowEmitter::emitHeight
+ \qmlproperty real QtQuick.Particles2::TrailEmitter::emitHeight
*/
/*!
- \qmlproperty real QtQuick.Particles2::FollowEmitter::emitRatePerParticle
+ \qmlproperty real QtQuick.Particles2::TrailEmitter::emitRatePerParticle
*/
/*!
- \qmlsignal QtQuick.Particles2::FollowEmitter::emitFollowParticle(particle, followed)
+ \qmlsignal QtQuick.Particles2::TrailEmitter::emitFollowParticle(particle, followed)
This handler is called when a particle is emitted. You can modify particle
attributes from within the handler. followed is the particle that this is being
@@ -103,13 +111,13 @@ QSGFollowEmitter::QSGFollowEmitter(QSGItem *parent) :
If you use this signal handler, emitParticle will not be emitted.
*/
-bool QSGFollowEmitter::isEmitFollowConnected()
+bool QSGTrailEmitter::isEmitFollowConnected()
{
static int idx = QObjectPrivate::get(this)->signalIndex("emitFollowParticle(QDeclarativeV8Handle,QDeclarativeV8Handle)");
return QObjectPrivate::get(this)->isSignalConnected(idx);
}
-void QSGFollowEmitter::recalcParticlesPerSecond(){
+void QSGTrailEmitter::recalcParticlesPerSecond(){
if (!m_system)
return;
m_followCount = m_system->m_groupData[m_system->m_groupIds[m_follow]]->size();
@@ -122,16 +130,16 @@ void QSGFollowEmitter::recalcParticlesPerSecond(){
}
}
-void QSGFollowEmitter::reset()
+void QSGTrailEmitter::reset()
{
m_followCount = 0;
}
-void QSGFollowEmitter::emitWindow(int timeStamp)
+void QSGTrailEmitter::emitWindow(int timeStamp)
{
if (m_system == 0)
return;
- if (!m_emitting && !m_burstLeft && m_burstQueue.isEmpty())
+ if (!m_enabled && !m_burstLeft && m_burstQueue.isEmpty())
return;
if (m_followCount != m_system->m_groupData[m_system->m_groupIds[m_follow]]->size()){
qreal oldPPS = m_particlesPerSecond;
@@ -224,8 +232,8 @@ void QSGFollowEmitter::emitWindow(int timeStamp)
float size = qMax((qreal)0.0, m_particleSize + sizeVariation);
float endSize = qMax((qreal)0.0, sizeAtEnd + sizeVariation);
- datum->size = size * float(m_emitting);
- datum->endSize = endSize * float(m_emitting);
+ datum->size = size * float(m_enabled);
+ datum->endSize = endSize * float(m_enabled);
if (isEmitFollowConnected())
emitFollowParticle(datum->v8Value(), d->v8Value());//A chance for many arbitrary JS changes
diff --git a/src/declarative/particles/qsgfollowemitter_p.h b/src/declarative/particles/qsgtrailemitter_p.h
index d26435df6a..5ab6f24270 100644
--- a/src/declarative/particles/qsgfollowemitter_p.h
+++ b/src/declarative/particles/qsgtrailemitter_p.h
@@ -51,21 +51,20 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QSGFollowEmitter : public QSGParticleEmitter
+class QSGTrailEmitter : public QSGParticleEmitter
{
Q_OBJECT
Q_PROPERTY(QString follow READ follow WRITE setFollow NOTIFY followChanged)
- //### Remove, and just document that particles per second is per particle? But has count issues
Q_PROPERTY(int emitRatePerParticle READ particlesPerParticlePerSecond WRITE setParticlesPerParticlePerSecond NOTIFY particlesPerParticlePerSecondChanged)
- //TODO: Document that FollowEmitter's box is where it follows. It emits in a rect centered on the followed particle
+ //TODO: Document that TrailEmitter's box is where it follows. It emits in a rect centered on the followed particle
//TODO: A set of properties that can involve the particle size of the followed
Q_PROPERTY(QSGParticleExtruder* emitShape READ emissonShape WRITE setEmissionShape NOTIFY emissionShapeChanged)
Q_PROPERTY(qreal emitHeight READ emitterYVariation WRITE setEmitterYVariation NOTIFY emitterYVariationChanged)
Q_PROPERTY(qreal emitWidth READ emitterXVariation WRITE setEmitterXVariation NOTIFY emitterXVariationChanged)
public:
- explicit QSGFollowEmitter(QSGItem *parent = 0);
+ explicit QSGTrailEmitter(QSGItem *parent = 0);
virtual void emitWindow(int timeStamp);
virtual void reset();
diff --git a/src/declarative/particles/qsgturbulence.cpp b/src/declarative/particles/qsgturbulence.cpp
index 003f3c12b6..2caebc7c1f 100644
--- a/src/declarative/particles/qsgturbulence.cpp
+++ b/src/declarative/particles/qsgturbulence.cpp
@@ -138,7 +138,7 @@ void QSGTurbulenceAffector::mapUpdate()
void QSGTurbulenceAffector::affectSystem(qreal dt)
{
- if (!m_system || !m_active)
+ if (!m_system || !m_enabled)
return;
ensureInit();
qreal period = 1.0/m_frequency;
diff --git a/src/declarative/particles/qsgv8particledata.cpp b/src/declarative/particles/qsgv8particledata.cpp
index 72c0b7c2de..d45093c57e 100644
--- a/src/declarative/particles/qsgv8particledata.cpp
+++ b/src/declarative/particles/qsgv8particledata.cpp
@@ -128,7 +128,7 @@ static void particleData_set_ ## VARIABLE (v8::Local<v8::String>, v8::Local<v8::
r->datum-> SETTER ( value->NumberValue() );\
}
-#define FLOAT_REGISTER_ACCESSOR(FT, ENGINE, VARIABLE) FT ->PrototypeTemplate()->SetAccessor( v8::String::New( #VARIABLE ), particleData_get_ ## VARIABLE , particleData_set_ ## VARIABLE , v8::External::Wrap(ENGINE))
+#define FLOAT_REGISTER_ACCESSOR(FT, ENGINE, VARIABLE, NAME) FT ->PrototypeTemplate()->SetAccessor( v8::String::New( #NAME ), particleData_get_ ## VARIABLE , particleData_set_ ## VARIABLE , v8::External::Wrap(ENGINE))
FLOAT_GETTER_AND_SETTER(x)
FLOAT_GETTER_AND_SETTER(y)
@@ -169,34 +169,34 @@ QV8ParticleDataDeletable::QV8ParticleDataDeletable(QV8Engine *engine)
ft->InstanceTemplate()->SetHasExternalResource(true);
ft->PrototypeTemplate()->Set(v8::String::New("discard"), V8FUNCTION(particleData_discard, engine));
ft->PrototypeTemplate()->Set(v8::String::New("lifeLeft"), V8FUNCTION(particleData_lifeLeft, engine));
- ft->PrototypeTemplate()->Set(v8::String::New("curSize"), V8FUNCTION(particleData_curSize, engine));
- FLOAT_REGISTER_ACCESSOR(ft, engine, x);
- FLOAT_REGISTER_ACCESSOR(ft, engine, y);
- FLOAT_REGISTER_ACCESSOR(ft, engine, t);
- FLOAT_REGISTER_ACCESSOR(ft, engine, lifeSpan);
- FLOAT_REGISTER_ACCESSOR(ft, engine, size);
- FLOAT_REGISTER_ACCESSOR(ft, engine, endSize);
- FLOAT_REGISTER_ACCESSOR(ft, engine, vx);
- FLOAT_REGISTER_ACCESSOR(ft, engine, vy);
- FLOAT_REGISTER_ACCESSOR(ft, engine, ax);
- FLOAT_REGISTER_ACCESSOR(ft, engine, ay);
- FLOAT_REGISTER_ACCESSOR(ft, engine, xx);
- FLOAT_REGISTER_ACCESSOR(ft, engine, xy);
- FLOAT_REGISTER_ACCESSOR(ft, engine, rotation);
- FLOAT_REGISTER_ACCESSOR(ft, engine, rotationSpeed);
- FLOAT_REGISTER_ACCESSOR(ft, engine, autoRotate);
- FLOAT_REGISTER_ACCESSOR(ft, engine, animIdx);
- FLOAT_REGISTER_ACCESSOR(ft, engine, frameDuration);
- FLOAT_REGISTER_ACCESSOR(ft, engine, frameCount);
- FLOAT_REGISTER_ACCESSOR(ft, engine, animT);
- FLOAT_REGISTER_ACCESSOR(ft, engine, r);
- FLOAT_REGISTER_ACCESSOR(ft, engine, update);
- FLOAT_REGISTER_ACCESSOR(ft, engine, curX);
- FLOAT_REGISTER_ACCESSOR(ft, engine, curVX);
- FLOAT_REGISTER_ACCESSOR(ft, engine, curAX);
- FLOAT_REGISTER_ACCESSOR(ft, engine, curY);
- FLOAT_REGISTER_ACCESSOR(ft, engine, curVY);
- FLOAT_REGISTER_ACCESSOR(ft, engine, curAY);
+ ft->PrototypeTemplate()->Set(v8::String::New("currentSize"), V8FUNCTION(particleData_curSize, engine));
+ FLOAT_REGISTER_ACCESSOR(ft, engine, x, initialX);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, y, initialY);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, t, t);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, lifeSpan, lifeSpan);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, size, startSize);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, endSize, endSize);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, vx, initialVX);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, vy, initialVY);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, ax, initialAX);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, ay, initialAY);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, xx, xDeformationVector);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, xy, yDeformationVector);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, rotation, rotation);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, rotationSpeed, rotationSpeed);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, autoRotate, autoRotate);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, animIdx, animationIndex);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, frameDuration, frameDuration);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, frameCount, frameCount);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, animT, animationT);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, r, r);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, update, update);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, curX, x);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, curVX, vx);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, curAX, ax);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, curY, y);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, curVY, vy);
+ FLOAT_REGISTER_ACCESSOR(ft, engine, curAY, ay);
constructor = qPersistentNew(ft->GetFunction());
}
diff --git a/src/declarative/particles/qsgwander.cpp b/src/declarative/particles/qsgwander.cpp
index a4a4d2c9c5..d3e87fb241 100644
--- a/src/declarative/particles/qsgwander.cpp
+++ b/src/declarative/particles/qsgwander.cpp
@@ -49,10 +49,39 @@ QT_BEGIN_NAMESPACE
\brief The Wander affector allows particles to randomly vary their trajectory.
*/
+/*!
+ \qmlproperty real QtQuick.Particles2::Wander::pace
+
+ Maximum attribute change per second.
+*/
+/*!
+ \qmlproperty real QtQuick.Particles2::Wander::xVariance
+
+ Maximum attribute x value (as a result of Wander).
+
+ If unset, Wander will not affect x values.
+*/
+/*!
+ \qmlproperty real QtQuick.Particles2::Wander::yVariance
+
+ Maximum attribute y value (as a result of Wander).
+
+ If unset, Wander will not affect y values.
+*/
+/*!
+ \qmlproperty AffectableParameter QtQuick.Particles2::Wander::affectedParameter
+
+ What attribute of particles is directly affected.
+ \list
+ \o PointAttractor.Position
+ \o PointAttractor.Velocity
+ \o PointAttractor.Acceleration
+ \endlist
+*/
QSGWanderAffector::QSGWanderAffector(QSGItem *parent) :
QSGParticleAffector(parent), m_xVariance(0), m_yVariance(0), m_pace(0)
- , m_physics(Velocity)
+ , m_affectedParameter(Velocity)
{
m_needsReset = true;
}
@@ -119,7 +148,7 @@ bool QSGWanderAffector::affectParticle(QSGParticleData* data, qreal dt)
qreal dx = dt * m_pace * (2 * qreal(qrand())/RAND_MAX - 1);
qreal dy = dt * m_pace * (2 * qreal(qrand())/RAND_MAX - 1);
qreal newX, newY;
- switch (m_physics){
+ switch (m_affectedParameter){
case Position:
newX = data->curX() + dx;
if (m_xVariance > qAbs(newX) )
diff --git a/src/declarative/particles/qsgwander_p.h b/src/declarative/particles/qsgwander_p.h
index ae98cf3681..46ad6ea3a2 100644
--- a/src/declarative/particles/qsgwander_p.h
+++ b/src/declarative/particles/qsgwander_p.h
@@ -66,11 +66,11 @@ class QSGWanderAffector : public QSGParticleAffector
Q_PROPERTY(qreal pace READ pace WRITE setPace NOTIFY paceChanged)
Q_PROPERTY(qreal xVariance READ xVariance WRITE setXVariance NOTIFY xVarianceChanged)
Q_PROPERTY(qreal yVariance READ yVariance WRITE setYVariance NOTIFY yVarianceChanged)
- Q_PROPERTY(PhysicsAffects physics READ physics WRITE setPhysics NOTIFY physicsChanged)
- Q_ENUMS(PhysicsAffects)
+ Q_PROPERTY(AffectableParameters affectedParameter READ affectedParameter WRITE setAffectedParameter NOTIFY affectedParameterChanged)
+ Q_ENUMS(AffectableParameters)
public:
- enum PhysicsAffects {
+ enum AffectableParameters {
Position,
Velocity,
Acceleration
@@ -95,9 +95,9 @@ public:
return m_pace;
}
- PhysicsAffects physics() const
+ AffectableParameters affectedParameter() const
{
- return m_physics;
+ return m_affectedParameter;
}
protected:
@@ -111,7 +111,7 @@ signals:
void paceChanged(qreal arg);
- void physicsChanged(PhysicsAffects arg);
+ void affectedParameterChanged(AffectableParameters arg);
public slots:
void setXVariance(qreal arg)
@@ -139,11 +139,11 @@ void setPace(qreal arg)
}
-void setPhysics(PhysicsAffects arg)
+void setAffectedParameter(AffectableParameters arg)
{
- if (m_physics != arg) {
- m_physics = arg;
- emit physicsChanged(arg);
+ if (m_affectedParameter != arg) {
+ m_affectedParameter = arg;
+ emit affectedParameterChanged(arg);
}
}
@@ -153,7 +153,7 @@ private:
qreal m_xVariance;
qreal m_yVariance;
qreal m_pace;
- PhysicsAffects m_physics;
+ AffectableParameters m_affectedParameter;
};
QT_END_NAMESPACE