aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/particles/qsgtargetaffector.cpp
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2011-07-22 17:45:59 +1000
committerQt by Nokia <qt-info@nokia.com>2011-07-28 11:27:26 +0200
commite57189d3bbac058a3ddea567a6e487be65cdde5a (patch)
treef3019565789a11704b6644f3c7ab912fe9343efe /src/declarative/particles/qsgtargetaffector.cpp
parent0511dfc0b8851baf84df73780e770f1025261068 (diff)
Add some more properties to JS particle type
Adds the current position, velocity and acceleration. While we're at it, renaming the velocity vars from sx,sy to vx,vy Change-Id: I87f582169c7873c45a6fd453052b25c4dc940f3e Reviewed-on: http://codereview.qt.nokia.com/2021 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src/declarative/particles/qsgtargetaffector.cpp')
-rw-r--r--src/declarative/particles/qsgtargetaffector.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/declarative/particles/qsgtargetaffector.cpp b/src/declarative/particles/qsgtargetaffector.cpp
index c5b5b074b5..e7bbebe6db 100644
--- a/src/declarative/particles/qsgtargetaffector.cpp
+++ b/src/declarative/particles/qsgtargetaffector.cpp
@@ -66,8 +66,8 @@ bool QSGTargetAffector::affectParticle(QSGParticleData *d, qreal dt)
qreal t = tt - (d->lifeSpan - d->lifeLeft());
if (t <= 0)
return false;
- qreal tx = d->x + d->sx * tt + 0.5 * d->ax * tt * tt;
- qreal ty = d->y + d->sy * tt + 0.5 * d->ay * tt * tt;
+ qreal tx = d->x + d->vx * tt + 0.5 * d->ax * tt * tt;
+ qreal ty = d->y + d->vy * tt + 0.5 * d->ay * tt * tt;
if (QPointF(tx,ty) == target)
return false;
@@ -77,14 +77,14 @@ bool QSGTargetAffector::affectParticle(QSGParticleData *d, qreal dt)
qreal w = 1 - (t / tt) + 0.05;
w = qMin(w, 1.0);
- qreal wvX = vX * w + d->sx * (1 - w);
- qreal wvY = vY * w + d->sy * (1 - w);
+ qreal wvX = vX * w + d->vx * (1 - w);
+ qreal wvY = vY * w + d->vy * (1 - w);
//Screws with the acceleration so that the given start pos with the chosen weighted velocity will still end at the target coordinates
qreal ax = (2*(target.x() - d->x - wvX*tt)) / (tt*tt);
qreal ay = (2*(target.y() - d->y - wvY*tt)) / (tt*tt);
- d->sx = wvX;
- d->sy = wvY;
+ d->vx = wvX;
+ d->vy = wvY;
d->ax = ax;
d->ay = ay;