aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2011-09-30 18:25:17 +1000
committerQt by Nokia <qt-info@nokia.com>2011-10-03 04:53:54 +0200
commite59fbf997ece61b36180eb21f9c2cd6ea895b88f (patch)
treec4d206ea4eadaf33b1ed0cbe1a9c5baae6fbd33f /src
parent69e925444ecebd352462f742d894b326d4cc9a72 (diff)
Initial commit of particle system autotests
Just some basic autotests for most of the elements. Change-Id: I2d289f38f362a38c69e03ff92154c98db3c4c486 Reviewed-on: http://codereview.qt-project.org/5844 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/declarative/particles/qsgcustomparticle.cpp2
-rw-r--r--src/declarative/particles/qsgfriction.cpp17
-rw-r--r--src/declarative/particles/qsgparticlesystem_p.h6
-rw-r--r--src/declarative/particles/qsgrectangleextruder.cpp2
-rw-r--r--src/declarative/particles/qsgrectangleextruder_p.h2
5 files changed, 21 insertions, 8 deletions
diff --git a/src/declarative/particles/qsgcustomparticle.cpp b/src/declarative/particles/qsgcustomparticle.cpp
index 5aad023da4..89e465b58a 100644
--- a/src/declarative/particles/qsgcustomparticle.cpp
+++ b/src/declarative/particles/qsgcustomparticle.cpp
@@ -79,7 +79,7 @@ static const char qt_particles_default_fragment_code[] =
"varying highp vec2 qt_TexCoord0; \n"
"uniform lowp float qt_Opacity; \n"
"void main() { \n"
- " gl_FragColor = texture2D(source, fTex) * qt_Opacity; \n"
+ " gl_FragColor = texture2D(source, qt_TexCoord0) * qt_Opacity; \n"
"}";
static QSGGeometry::Attribute PlainParticle_Attributes[] = {
diff --git a/src/declarative/particles/qsgfriction.cpp b/src/declarative/particles/qsgfriction.cpp
index 031fc896bf..44b08e3dc0 100644
--- a/src/declarative/particles/qsgfriction.cpp
+++ b/src/declarative/particles/qsgfriction.cpp
@@ -54,6 +54,10 @@ QT_BEGIN_NAMESPACE
A drag will be applied to moving objects which is this factor of their current velocity.
*/
+static qreal sign(qreal a)
+{
+ return a >= 0 ? 1 : -1;
+}
QSGFrictionAffector::QSGFrictionAffector(QSGItem *parent) :
QSGParticleAffector(parent), m_factor(0.0)
@@ -66,8 +70,17 @@ bool QSGFrictionAffector::affectParticle(QSGParticleData *d, qreal dt)
return false;
qreal curVX = d->curVX();
qreal curVY = d->curVY();
- d->setInstantaneousVX(curVX + (curVX * m_factor * -1 * dt));
- d->setInstantaneousVY(curVY + (curVY * m_factor * -1 * dt));
+ qreal newVX = curVX + (curVX * m_factor * -1 * dt);
+ qreal newVY = curVY + (curVY * m_factor * -1 * dt);
+
+ //Since we're modelling a continuous function, it will never pass 0.
+ if (sign(curVX) != sign(newVX))
+ newVX = 0;
+ if (sign(curVY) != sign(newVY))
+ newVY = 0;
+
+ d->setInstantaneousVX(newVX);
+ d->setInstantaneousVY(newVY);
return true;
}
QT_END_NAMESPACE
diff --git a/src/declarative/particles/qsgparticlesystem_p.h b/src/declarative/particles/qsgparticlesystem_p.h
index 084409f3ef..5dd93d244e 100644
--- a/src/declarative/particles/qsgparticlesystem_p.h
+++ b/src/declarative/particles/qsgparticlesystem_p.h
@@ -103,7 +103,7 @@ private:
QHash<int,int> m_lookups;
};
-class QSGParticleGroupData{
+class Q_AUTOTEST_EXPORT QSGParticleGroupData {
public:
QSGParticleGroupData(int id, QSGParticleSystem* sys);
~QSGParticleGroupData();
@@ -143,7 +143,7 @@ struct Color4ub {
uchar a;
};
-class QSGParticleData{
+class Q_AUTOTEST_EXPORT QSGParticleData {
public:
//TODO: QObject like memory management (without the cost, just attached to system)
QSGParticleData(QSGParticleSystem* sys);
@@ -225,7 +225,7 @@ private:
QSGV8ParticleData* v8Datum;
};
-class QSGParticleSystem : public QSGItem
+class Q_AUTOTEST_EXPORT QSGParticleSystem : public QSGItem
{
Q_OBJECT
Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged)
diff --git a/src/declarative/particles/qsgrectangleextruder.cpp b/src/declarative/particles/qsgrectangleextruder.cpp
index accc88fcdb..fde227c5b8 100644
--- a/src/declarative/particles/qsgrectangleextruder.cpp
+++ b/src/declarative/particles/qsgrectangleextruder.cpp
@@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE
*/
QSGRectangleExtruder::QSGRectangleExtruder(QObject *parent) :
- QObject(parent), m_fill(true)
+ QSGParticleExtruder(parent), m_fill(true)
{
}
diff --git a/src/declarative/particles/qsgrectangleextruder_p.h b/src/declarative/particles/qsgrectangleextruder_p.h
index 5795375c84..9cc51b2cb7 100644
--- a/src/declarative/particles/qsgrectangleextruder_p.h
+++ b/src/declarative/particles/qsgrectangleextruder_p.h
@@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QSGRectangleExtruder : public QObject
+class QSGRectangleExtruder : public QSGParticleExtruder
{
Q_OBJECT
Q_PROPERTY(bool fill READ fill WRITE setFill NOTIFY fillChanged)