Add some more properties to JS particle type
authorAlan Alpert <alan.alpert@nokia.com>
Fri, 22 Jul 2011 07:45:59 +0000 (17:45 +1000)
committerQt by Nokia <qt-info@nokia.com>
Thu, 28 Jul 2011 09:27:26 +0000 (11:27 +0200)
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>
15 files changed:
examples/declarative/particles/custom/fallingleaves.qml
src/declarative/particles/qsgcustomemitter.cpp
src/declarative/particles/qsgcustomparticle.cpp
src/declarative/particles/qsgemitter.cpp
src/declarative/particles/qsgfollowemitter.cpp
src/declarative/particles/qsgfriction.cpp
src/declarative/particles/qsgimageparticle.cpp
src/declarative/particles/qsgimageparticle_p.h
src/declarative/particles/qsgparticlesystem.cpp
src/declarative/particles/qsgparticlesystem_p.h
src/declarative/particles/qsgpointattractor.cpp
src/declarative/particles/qsgtargetaffector.cpp
src/declarative/particles/qsgturbulence.cpp
src/declarative/particles/qsgv8particledata.cpp
src/declarative/particles/qsgwander.cpp

index e41d214..1d1282e 100644 (file)
@@ -13,21 +13,24 @@ Item {
     Emitter{
         system: sys
         width: parent.width
-        emitRate: 6
-        lifeSpan: 12000
+        emitRate: 4
+        lifeSpan: 14000
         size: 80
         speed: PointDirection{ y: 60 }
     }
     Wander {
         system: sys
         anchors.fill: parent
+        anchors.bottomMargin: 100
         xVariance: 60
         pace: 60
     }
     CustomAffector{
         system: sys
-        property real coefficient: 0.5
-        property real speed: 10.0
+        property real coefficient: 0.1
+        property real speed: 1.5
+        width: parent.width
+        height: parent.height - 100
         onAffectParticle:{
         /*  //Linear movement
             if (particle.r == 0){
@@ -53,6 +56,27 @@ Item {
         }
     }
 
+    CustomAffector{//Custom Friction, adds some 'randomness'
+        system: sys
+        //onceOff: true
+        x: -60
+        width: parent.width + 120
+        height: 100
+        anchors.bottom: parent.bottom
+        onAffectParticle:{
+            var pseudoRand = (Math.floor(particle.t*1327) % 10) + 1;
+            var yslow = pseudoRand * 0.001 + 1.01;
+            var xslow = pseudoRand * 0.0005 + 1.0;
+            if (particle.curVY < 1)
+                particle.curVY == 0;
+            else
+                particle.curVY = (particle.curVY / yslow);
+            if (particle.curVX < 1)
+                particle.curVX == 0;
+            else
+                particle.curVX = (particle.curVX / xslow);
+        }
+    }
     ImageParticle{
         anchors.fill: parent
         id: particles
index 4a379a3..0500e0c 100644 (file)
@@ -147,8 +147,8 @@ void QSGCustomEmitter::emitWindow(int timeStamp)
 
             // Particle speed
             const QPointF &speed = m_speed->sample(newPos);
-            datum->sx = speed.x();
-            datum->sy = speed.y();
+            datum->vx = speed.x();
+            datum->vy = speed.y();
 
             // Particle acceleration
             const QPointF &accel = m_acceleration->sample(newPos);
index f1477f6..1ce8e43 100644 (file)
@@ -105,8 +105,8 @@ struct PlainVertex {
     float lifeSpan;
     float size;
     float endSize;
-    float sx;
-    float sy;
+    float vx;
+    float vy;
     float ax;
     float ay;
     float r;
@@ -535,8 +535,8 @@ void QSGCustomParticle::commit(int gIdx, int pIdx)
         vertices[i].lifeSpan = datum->lifeSpan;
         vertices[i].size = datum->size;
         vertices[i].endSize = datum->endSize;
-        vertices[i].sx = datum->sx;
-        vertices[i].sy = datum->sy;
+        vertices[i].vx = datum->vx;
+        vertices[i].vy = datum->vy;
         vertices[i].ax = datum->ax;
         vertices[i].ay = datum->ay;
         vertices[i].r = datum->r;
index f05ee6a..10d59df 100644 (file)
@@ -220,9 +220,9 @@ void QSGBasicEmitter::emitWindow(int timeStamp)
 
             // Particle speed
             const QPointF &speed = m_speed->sample(newPos);
-            datum->sx = speed.x()
+            datum->vx = speed.x()
                     + m_speed_from_movement * vx;
-            datum->sy = speed.y()
+            datum->vy = speed.y()
                     + m_speed_from_movement * vy;
 
             // Particle acceleration
index ff9f83d..0d4e7f7 100644 (file)
@@ -220,12 +220,12 @@ void QSGFollowEmitter::emitWindow(int timeStamp)
                 qreal sizeOffset = d->size/2;//TODO: Current size? As an option
                 //TODO: Set variations
                 //Subtract offset, because PS expects this in emitter coordinates
-                QRectF boundsRect(d->x - offset.x() + d->sx * followT + d->ax * followT2 - m_emitterXVariation/2,
-                                  d->y - offset.y() + d->sy * followT + d->ay * followT2 - m_emitterYVariation/2,
+                QRectF boundsRect(d->x - offset.x() + d->vx * followT + d->ax * followT2 - m_emitterXVariation/2,
+                                  d->y - offset.y() + d->vy * followT + d->ay * followT2 - m_emitterYVariation/2,
                                   m_emitterXVariation,
                                   m_emitterYVariation);
-    //            QRectF boundsRect(d->x + d->sx * followT + d->ax * followT2 + offset.x() - sizeOffset,
-    //                              d->y + d->sy * followT + d->ay * followT2 + offset.y() - sizeOffset,
+    //            QRectF boundsRect(d->x + d->vx * followT + d->ax * followT2 + offset.x() - sizeOffset,
+    //                              d->y + d->vy * followT + d->ay * followT2 + offset.y() - sizeOffset,
     //                              sizeOffset*2,
     //                              sizeOffset*2);
 
@@ -236,8 +236,8 @@ void QSGFollowEmitter::emitWindow(int timeStamp)
 
                 // Particle speed
                 const QPointF &speed = m_speed->sample(newPos);
-                datum->sx = speed.x();
-                datum->sy = speed.y();
+                datum->vx = speed.x();
+                datum->vy = speed.y();
 
                 // Particle acceleration
                 const QPointF &accel = m_acceleration->sample(newPos);
index fcd43a5..e6a4301 100644 (file)
@@ -63,10 +63,10 @@ bool QSGFrictionAffector::affectParticle(QSGParticleData *d, qreal dt)
 {
     if (!m_factor)
         return false;
-    qreal curSX = d->curSX();
-    qreal curSY = d->curSY();
-    d->setInstantaneousSX(curSX + (curSX * m_factor * -1 * dt));
-    d->setInstantaneousSY(curSY + (curSY * m_factor * -1 * dt));
+    qreal curVX = d->curVX();
+    qreal curVY = d->curVY();
+    d->setInstantaneousVX(curVX + (curVX * m_factor * -1 * dt));
+    d->setInstantaneousVY(curVY + (curVY * m_factor * -1 * dt));
     return true;
 }
 QT_END_NAMESPACE
index e4ba67f..52e94b1 100644 (file)
@@ -985,8 +985,8 @@ void QSGImageParticle::commit(int gIdx, int pIdx)
             ultraVertices[i].lifeSpan = datum->lifeSpan;
             ultraVertices[i].size = datum->size;
             ultraVertices[i].endSize = datum->endSize;
-            ultraVertices[i].sx = datum->sx;
-            ultraVertices[i].sy = datum->sy;
+            ultraVertices[i].vx = datum->vx;
+            ultraVertices[i].vy = datum->vy;
             ultraVertices[i].ax = datum->ax;
             ultraVertices[i].ay = datum->ay;
             ultraVertices[i].xx = datum->xx;
@@ -1018,8 +1018,8 @@ void QSGImageParticle::commit(int gIdx, int pIdx)
             simpleVertices[i].lifeSpan = datum->lifeSpan;
             simpleVertices[i].size = datum->size;
             simpleVertices[i].endSize = datum->endSize;
-            simpleVertices[i].sx = datum->sx;
-            simpleVertices[i].sy = datum->sy;
+            simpleVertices[i].vx = datum->vx;
+            simpleVertices[i].vy = datum->vy;
             simpleVertices[i].ax = datum->ax;
             simpleVertices[i].ay = datum->ay;
         }
index ed9db52..1ac840c 100644 (file)
@@ -66,8 +66,8 @@ struct SimpleVertex {
     float lifeSpan;
     float size;
     float endSize;
-    float sx;
-    float sy;
+    float vx;
+    float vy;
     float ax;
     float ay;
 };
@@ -88,8 +88,8 @@ struct UltraVertex {
     float lifeSpan;
     float size;
     float endSize;
-    float sx;
-    float sy;
+    float vx;
+    float vy;
     float ax;
     float ay;
     Color4ub color;
index 6f4a617..f481563 100644 (file)
@@ -306,8 +306,8 @@ QSGParticleData::QSGParticleData(QSGParticleSystem* sys)
     lifeSpan = 0;
     size = 0;
     endSize = 0;
-    sx = 0;
-    sy = 0;
+    vx = 0;
+    vy = 0;
     ax = 0;
     ay = 0;
     xx = 1;
@@ -338,8 +338,8 @@ void QSGParticleData::clone(const QSGParticleData& other)
     lifeSpan = other.lifeSpan;
     size = other.size;
     endSize = other.endSize;
-    sx = other.sx;
-    sy = other.sy;
+    vx = other.vx;
+    vy = other.vy;
     ax = other.ax;
     ay = other.ay;
     xx = other.xx;
@@ -372,24 +372,24 @@ QDeclarativeV8Handle QSGParticleData::v8Value()
 void QSGParticleData::setInstantaneousAX(qreal ax)
 {
     qreal t = (system->m_timeInt / 1000.0) - this->t;
-    qreal sx = (this->sx + t*this->ax) - t*ax;
-    qreal ex = this->x + this->sx * t + 0.5 * this->ax * t * t;
-    qreal x = ex - t*sx - 0.5 * t*t*ax;
+    qreal vx = (this->vx + t*this->ax) - t*ax;
+    qreal ex = this->x + this->vx * t + 0.5 * this->ax * t * t;
+    qreal x = ex - t*vx - 0.5 * t*t*ax;
 
     this->ax = ax;
-    this->sx = sx;
+    this->vx = vx;
     this->x = x;
 }
 
 //sets the x velocity without affecting the instantaneous x postion
-void QSGParticleData::setInstantaneousSX(qreal vx)
+void QSGParticleData::setInstantaneousVX(qreal vx)
 {
     qreal t = (system->m_timeInt / 1000.0) - this->t;
-    qreal sx = vx - t*this->ax;
-    qreal ex = this->x + this->sx * t + 0.5 * this->ax * t * t;
-    qreal x = ex - t*sx - 0.5 * t*t*this->ax;
+    qreal evx = vx - t*this->ax;
+    qreal ex = this->x + this->vx * t + 0.5 * this->ax * t * t;
+    qreal x = ex - t*evx - 0.5 * t*t*this->ax;
 
-    this->sx = sx;
+    this->vx = evx;
     this->x = x;
 }
 
@@ -397,31 +397,31 @@ void QSGParticleData::setInstantaneousSX(qreal vx)
 void QSGParticleData::setInstantaneousX(qreal x)
 {
     qreal t = (system->m_timeInt / 1000.0) - this->t;
-    this->x = x - t*this->sx - 0.5 * t*t*this->ax;
+    this->x = x - t*this->vx - 0.5 * t*t*this->ax;
 }
 
 //sets the y accleration without affecting the instantaneous y velocity or position
 void QSGParticleData::setInstantaneousAY(qreal ay)
 {
     qreal t = (system->m_timeInt / 1000.0) - this->t;
-    qreal sy = (this->sy + t*this->ay) - t*ay;
-    qreal ey = this->y + this->sy * t + 0.5 * this->ay * t * t;
-    qreal y = ey - t*sy - 0.5 * t*t*ay;
+    qreal vy = (this->vy + t*this->ay) - t*ay;
+    qreal ey = this->y + this->vy * t + 0.5 * this->ay * t * t;
+    qreal y = ey - t*vy - 0.5 * t*t*ay;
 
     this->ay = ay;
-    this->sy = sy;
+    this->vy = vy;
     this->y = y;
 }
 
 //sets the y velocity without affecting the instantaneous y position
-void QSGParticleData::setInstantaneousSY(qreal vy)
+void QSGParticleData::setInstantaneousVY(qreal vy)
 {
     qreal t = (system->m_timeInt / 1000.0) - this->t;
-    qreal sy = vy - t*this->ay;
-    qreal ey = this->y + this->sy * t + 0.5 * this->ay * t * t;
-    qreal y = ey - t*sy - 0.5 * t*t*this->ay;
+    qreal evy = vy - t*this->ay;
+    qreal ey = this->y + this->vy * t + 0.5 * this->ay * t * t;
+    qreal y = ey - t*evy - 0.5 * t*t*this->ay;
 
-    this->sy = sy;
+    this->vy = evy;
     this->y = y;
 }
 
@@ -429,38 +429,38 @@ void QSGParticleData::setInstantaneousSY(qreal vy)
 void QSGParticleData::setInstantaneousY(qreal y)
 {
     qreal t = (system->m_timeInt / 1000.0) - this->t;
-    this->y = y - t*this->sy - 0.5 * t*t*this->ay;
+    this->y = y - t*this->vy - 0.5 * t*t*this->ay;
 }
 
 qreal QSGParticleData::curX() const
 {
     qreal t = (system->m_timeInt / 1000.0) - this->t;
-    return this->x + this->sx * t + 0.5 * this->ax * t * t;
+    return this->x + this->vx * t + 0.5 * this->ax * t * t;
 }
 
-qreal QSGParticleData::curSX() const
+qreal QSGParticleData::curVX() const
 {
     qreal t = (system->m_timeInt / 1000.0) - this->t;
-    return this->sx + t*this->ax;
+    return this->vx + t*this->ax;
 }
 
 qreal QSGParticleData::curY() const
 {
     qreal t = (system->m_timeInt / 1000.0) - this->t;
-    return y + sy * t + 0.5 * ay * t * t;
+    return y + vy * t + 0.5 * ay * t * t;
 }
 
-qreal QSGParticleData::curSY() const
+qreal QSGParticleData::curVY() const
 {
     qreal t = (system->m_timeInt / 1000.0) - this->t;
-    return sy + t*ay;
+    return vy + t*ay;
 }
 
 void QSGParticleData::debugDump()
 {
     qDebug() << "Particle" << systemIndex << group << "/" << index << stillAlive()
              << "Pos: " << x << "," << y
-             //<< "Vel: " << sx << "," << sy
+             //<< "Vel: " << vx << "," << sy
              //<< "Acc: " << ax << "," << ay
              << "Size: " << size << "," << endSize
              << "Time: " << t << "," <<lifeSpan << ";" << (system->m_timeInt / 1000.0) ;
index fd46ee2..9f4020d 100644 (file)
@@ -150,21 +150,23 @@ public:
     //sets the x accleration without affecting the instantaneous x velocity or position
     void setInstantaneousAX(qreal ax);
     //sets the x velocity without affecting the instantaneous x postion
-    void setInstantaneousSX(qreal vx);
+    void setInstantaneousVX(qreal vx);
     //sets the instantaneous x postion
     void setInstantaneousX(qreal x);
     //sets the y accleration without affecting the instantaneous y velocity or position
     void setInstantaneousAY(qreal ay);
     //sets the y velocity without affecting the instantaneous y postion
-    void setInstantaneousSY(qreal vy);
+    void setInstantaneousVY(qreal vy);
     //sets the instantaneous Y postion
     void setInstantaneousY(qreal y);
 
     //TODO: Slight caching?
     qreal curX() const;
-    qreal curSX() const;
+    qreal curVX() const;
+    qreal curAX() const { return ax; }
     qreal curY() const;
-    qreal curSY() const;
+    qreal curVY() const;
+    qreal curAY() const { return ay; }
 
     int group;
     QSGParticleEmitter* e;//### Needed?
@@ -179,8 +181,8 @@ public:
     float lifeSpan;
     float size;
     float endSize;
-    float sx;
-    float sy;
+    float vx;
+    float vy;
     float ax;
     float ay;
 
index 6be61aa..cc4cac6 100644 (file)
@@ -92,8 +92,8 @@ bool QSGPointAttractorAffector::affectParticle(QSGParticleData *d, qreal dt)
         break;
     case Velocity: //also default
     default:
-        d->setInstantaneousSX(d->sx + dx);
-        d->setInstantaneousSY(d->sy + dy);
+        d->setInstantaneousVX(d->vx + dx);
+        d->setInstantaneousVY(d->vy + dy);
     }
 
     return true;
index c5b5b07..e7bbebe 100644 (file)
@@ -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;
 
index c846f15..e9812d7 100644 (file)
@@ -173,8 +173,8 @@ void QSGTurbulenceAffector::affectSystem(qreal dt)
                 fy += m_field[p.first][p.second].y() * ((m_magSum - dist)/m_magSum);
             }
             if (fx || fy){
-                d->setInstantaneousSX(d->curSX()+ fx * dt);
-                d->setInstantaneousSY(d->curSY()+ fy * dt);
+                d->setInstantaneousVX(d->curVX()+ fx * dt);
+                d->setInstantaneousVY(d->curVY()+ fy * dt);
                 m_system->m_needsReset << d;
             }
         }
index 6b31e37..b3ff482 100644 (file)
@@ -110,6 +110,24 @@ static void particleData_set_ ## VARIABLE (v8::Local<v8::String>, v8::Local<v8::
     r->datum-> VARIABLE = value->NumberValue();\
 }
 
+#define FAKE_FLOAT_GETTER_AND_SETTER(VARIABLE, GETTER, SETTER) static v8::Handle<v8::Value> particleData_get_ ## VARIABLE (v8::Local<v8::String>, const v8::AccessorInfo &info) \
+{ \
+    QV8ParticleDataResource *r = v8_resource_cast<QV8ParticleDataResource>(info.This()); \
+    if (!r || !r->datum) \
+        V8THROW_ERROR("Not a valid ParticleData object"); \
+\
+    return v8::Number::New(r->datum-> GETTER ());\
+}\
+\
+static void particleData_set_ ## VARIABLE (v8::Local<v8::String>, v8::Local<v8::Value> value, const v8::AccessorInfo &info)\
+{\
+    QV8ParticleDataResource *r = v8_resource_cast<QV8ParticleDataResource>(info.This());\
+    if (!r || !r->datum)\
+        V8THROW_ERROR_SETTER("Not a valid ParticleData object");\
+\
+    r->datum-> SETTER ( value->NumberValue() );\
+}
+
 #define FLOAT_REGISTER_ACCESSOR(FT, ENGINE, VARIABLE) FT ->PrototypeTemplate()->SetAccessor( v8::String::New( #VARIABLE ), particleData_get_ ## VARIABLE , particleData_set_ ## VARIABLE , v8::External::Wrap(ENGINE))
 
 FLOAT_GETTER_AND_SETTER(x)
@@ -118,8 +136,8 @@ FLOAT_GETTER_AND_SETTER(t)
 FLOAT_GETTER_AND_SETTER(lifeSpan)
 FLOAT_GETTER_AND_SETTER(size)
 FLOAT_GETTER_AND_SETTER(endSize)
-FLOAT_GETTER_AND_SETTER(sx)
-FLOAT_GETTER_AND_SETTER(sy)
+FLOAT_GETTER_AND_SETTER(vx)
+FLOAT_GETTER_AND_SETTER(vy)
 FLOAT_GETTER_AND_SETTER(ax)
 FLOAT_GETTER_AND_SETTER(ay)
 FLOAT_GETTER_AND_SETTER(xx)
@@ -132,6 +150,12 @@ FLOAT_GETTER_AND_SETTER(frameDuration)
 FLOAT_GETTER_AND_SETTER(frameCount)
 FLOAT_GETTER_AND_SETTER(animT)
 FLOAT_GETTER_AND_SETTER(r)
+FAKE_FLOAT_GETTER_AND_SETTER(curX, curX, setInstantaneousX)
+FAKE_FLOAT_GETTER_AND_SETTER(curVX, curVX, setInstantaneousVX)
+FAKE_FLOAT_GETTER_AND_SETTER(curAX, curAX, setInstantaneousAX)
+FAKE_FLOAT_GETTER_AND_SETTER(curY, curY, setInstantaneousY)
+FAKE_FLOAT_GETTER_AND_SETTER(curVY, curVY, setInstantaneousVY)
+FAKE_FLOAT_GETTER_AND_SETTER(curAY, curAY, setInstantaneousAY)
 
 //TODO: Non-floats (color) and special floats (curX) once basic floats are working well
 
@@ -151,8 +175,8 @@ QV8ParticleDataDeletable::QV8ParticleDataDeletable(QV8Engine *engine)
     FLOAT_REGISTER_ACCESSOR(ft, engine, lifeSpan);
     FLOAT_REGISTER_ACCESSOR(ft, engine, size);
     FLOAT_REGISTER_ACCESSOR(ft, engine, endSize);
-    FLOAT_REGISTER_ACCESSOR(ft, engine, sx);
-    FLOAT_REGISTER_ACCESSOR(ft, engine, sy);
+    FLOAT_REGISTER_ACCESSOR(ft, engine, vx);
+    FLOAT_REGISTER_ACCESSOR(ft, engine, vy);
     FLOAT_REGISTER_ACCESSOR(ft, engine, ax);
     FLOAT_REGISTER_ACCESSOR(ft, engine, ay);
     FLOAT_REGISTER_ACCESSOR(ft, engine, xx);
@@ -165,6 +189,12 @@ QV8ParticleDataDeletable::QV8ParticleDataDeletable(QV8Engine *engine)
     FLOAT_REGISTER_ACCESSOR(ft, engine, frameCount);
     FLOAT_REGISTER_ACCESSOR(ft, engine, animT);
     FLOAT_REGISTER_ACCESSOR(ft, engine, r);
+    FLOAT_REGISTER_ACCESSOR(ft, engine, curX);
+    FLOAT_REGISTER_ACCESSOR(ft, engine, curVX);
+    FLOAT_REGISTER_ACCESSOR(ft, engine, curAX);
+    FLOAT_REGISTER_ACCESSOR(ft, engine, curY);
+    FLOAT_REGISTER_ACCESSOR(ft, engine, curVY);
+    FLOAT_REGISTER_ACCESSOR(ft, engine, curAY);
 
     constructor = qPersistentNew(ft->GetFunction());
 }
index 849f288..2d04d62 100644 (file)
@@ -131,12 +131,12 @@ bool QSGWanderAffector::affectParticle(QSGParticleData* data, qreal dt)
         break;
     default:
     case Velocity:
-        newX = data->curSX() + dx;
+        newX = data->curVX() + dx;
         if (m_xVariance > qAbs(newX) )
-            data->setInstantaneousSX(newX);
-        newY = data->curSY() + dy;
+            data->setInstantaneousVX(newX);
+        newY = data->curVY() + dy;
         if (m_yVariance > qAbs(newY) )
-            data->setInstantaneousSY(newY);
+            data->setInstantaneousVY(newY);
         break;
     case Acceleration:
         newX = data->ax + dx;