Fix Attractor affector
authorAlan Alpert <alan.alpert@nokia.com>
Tue, 30 Aug 2011 01:41:16 +0000 (11:41 +1000)
committerQt by Nokia <qt-info@nokia.com>
Tue, 30 Aug 2011 07:44:30 +0000 (09:44 +0200)
Wasn't simulating the physics right, interacted wrong with other
attractors when in Velocity mode.

Change-Id: I5883eb748b398494ad552e35f06d1167da6023a6
Reviewed-on: http://codereview.qt.nokia.com/3835
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
src/declarative/particles/qsgpointattractor.cpp

index 1a3c3c2..55b6cb6 100644 (file)
@@ -80,6 +80,7 @@ bool QSGPointAttractorAffector::affectParticle(QSGParticleData *d, qreal dt)
     }
     dx = ds * cos(theta);
     dy = ds * sin(theta);
+    qreal vx,vy;
     switch (m_physics){
     case Position:
         d->x = (d->x + dx);
@@ -91,8 +92,10 @@ bool QSGPointAttractorAffector::affectParticle(QSGParticleData *d, qreal dt)
         break;
     case Velocity: //also default
     default:
-        d->setInstantaneousVX(d->vx + dx);
-        d->setInstantaneousVY(d->vy + dy);
+        vx = d->curVX();
+        vy = d->curVY();
+        d->setInstantaneousVX(vx + dx);
+        d->setInstantaneousVY(vy + dy);
     }
 
     return true;