From f6a312b76c221f4025a6a05b0bda02e55a8bd865 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 30 Aug 2011 11:41:16 +1000 Subject: [PATCH] Fix Attractor affector 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 Reviewed-by: Alan Alpert --- src/declarative/particles/qsgpointattractor.cpp | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/declarative/particles/qsgpointattractor.cpp b/src/declarative/particles/qsgpointattractor.cpp index 1a3c3c2..55b6cb6 100644 --- a/src/declarative/particles/qsgpointattractor.cpp +++ b/src/declarative/particles/qsgpointattractor.cpp @@ -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; -- 1.7.2.5