summaryrefslogtreecommitdiffstats
path: root/src/imports
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-06-04 03:18:14 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2010-06-04 04:34:33 (GMT)
commit312152dafde1dbe5824f0af0a649918c5ebcab5e (patch)
tree2d376da6e3fe42262fe3386c5c51ebf2efc6aa32 /src/imports
parent523b6a0da134700cead707530149067286228858 (diff)
downloadQt-312152dafde1dbe5824f0af0a649918c5ebcab5e.zip
Qt-312152dafde1dbe5824f0af0a649918c5ebcab5e.tar.gz
Qt-312152dafde1dbe5824f0af0a649918c5ebcab5e.tar.bz2
Ensure ParticleMotionGravity always pulls in the right direction.
Diffstat (limited to 'src/imports')
-rw-r--r--src/imports/particles/qdeclarativeparticles.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/imports/particles/qdeclarativeparticles.cpp b/src/imports/particles/qdeclarativeparticles.cpp
index 56b89b5..630c068 100644
--- a/src/imports/particles/qdeclarativeparticles.cpp
+++ b/src/imports/particles/qdeclarativeparticles.cpp
@@ -241,11 +241,13 @@ void QDeclarativeParticleMotionGravity::setAcceleration(qreal accel)
void QDeclarativeParticleMotionGravity::advance(QDeclarativeParticle &p, int interval)
{
- qreal xdiff = p.x - _xAttr;
- qreal ydiff = p.y - _yAttr;
+ qreal xdiff = _xAttr - p.x;
+ qreal ydiff = _yAttr - p.y;
+ qreal absXdiff = qAbs(xdiff);
+ qreal absYdiff = qAbs(ydiff);
- qreal xcomp = xdiff / (xdiff + ydiff);
- qreal ycomp = ydiff / (xdiff + ydiff);
+ qreal xcomp = xdiff / (absXdiff + absYdiff);
+ qreal ycomp = ydiff / (absXdiff + absYdiff);
p.x_velocity += xcomp * _accel * interval;
p.y_velocity += ycomp * _accel * interval;