aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/particles/qsgpointattractor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/particles/qsgpointattractor.cpp')
-rw-r--r--src/declarative/particles/qsgpointattractor.cpp28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/declarative/particles/qsgpointattractor.cpp b/src/declarative/particles/qsgpointattractor.cpp
index 1a3c3c25c5..21eaeaac12 100644
--- a/src/declarative/particles/qsgpointattractor.cpp
+++ b/src/declarative/particles/qsgpointattractor.cpp
@@ -65,21 +65,31 @@ bool QSGPointAttractorAffector::affectParticle(QSGParticleData *d, qreal dt)
{
if (m_strength == 0.0)
return false;
- qreal dx = m_y - d->curX();
- qreal dy = m_x - d->curY();
+ qreal dx = m_x - d->curX();
+ qreal dy = m_y - d->curY();
qreal r = sqrt((dx*dx) + (dy*dy));
qreal theta = atan2(dy,dx);
qreal ds = 0;
switch (m_proportionalToDistance){
+ case InverseQuadratic:
+ ds = (m_strength / qMax<qreal>(1.,r*r));
+ break;
+ case InverseLinear:
+ ds = (m_strength / qMax<qreal>(1.,r));
+ break;
case Quadratic:
- ds = (m_strength / qMax<qreal>(1.,r*r)) * dt;
+ ds = (m_strength * qMax<qreal>(1.,r*r));
break;
- case Linear://also default
- default:
- ds = (m_strength / qMax<qreal>(1.,r)) * dt;
+ case Linear:
+ ds = (m_strength * qMax<qreal>(1.,r));
+ break;
+ default: //also Constant
+ ds = m_strength;
}
+ ds *= dt;
dx = ds * cos(theta);
dy = ds * sin(theta);
+ qreal vx,vy;
switch (m_physics){
case Position:
d->x = (d->x + dx);
@@ -91,8 +101,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;