diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2011-07-04 18:15:28 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-07-06 10:09:09 +0200 |
commit | 29c4b643272a43022081cce063394bac823ab529 (patch) | |
tree | 10e4fe15bdf68dec90edac0d67b949a92d9204d5 /src/declarative/particles/qsgwander.cpp | |
parent | 87822d24df32311a50dc87ded55ad4d17e8226f0 (diff) |
Squashed Particle System Stateful Rewrite
Add TargetAffector
Fix for ParticlePainter offsets
Adds a particleStates property to ParticleSystem
Augment SpriteGoal to change system states as well
Also add 'collidingParticles' list to affector.
Particle Stochastic States Now actually working, and you can put
emitters, affectors and painters inside their targeted state.
Fireworks example uses states instead of delegates.
Replaced the delegate example with a text thing.
The examples launcher now also contains all the custom examples.
Adds CumulativeDirection and working null Affector (for affected
signal).
Add spaces after all flow control keywords.
Change-Id: I77b7e3044a9800dbfff6db833914d63127602cf5
Reviewed-on: http://codereview.qt.nokia.com/968
Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
Diffstat (limited to 'src/declarative/particles/qsgwander.cpp')
-rw-r--r-- | src/declarative/particles/qsgwander.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/declarative/particles/qsgwander.cpp b/src/declarative/particles/qsgwander.cpp index 26bea4ee04..c7e17c556b 100644 --- a/src/declarative/particles/qsgwander.cpp +++ b/src/declarative/particles/qsgwander.cpp @@ -52,14 +52,14 @@ QSGWanderAffector::QSGWanderAffector(QSGItem *parent) : QSGWanderAffector::~QSGWanderAffector() { - for(QHash<int, WanderData*>::const_iterator iter=m_wanderData.constBegin(); + for (QHash<int, WanderData*>::const_iterator iter=m_wanderData.constBegin(); iter != m_wanderData.constEnd(); iter++) delete (*iter); } WanderData* QSGWanderAffector::getData(int idx) { - if(m_wanderData.contains(idx)) + if (m_wanderData.contains(idx)) return m_wanderData[idx]; WanderData* d = new WanderData; d->x_vel = 0; @@ -75,7 +75,7 @@ WanderData* QSGWanderAffector::getData(int idx) void QSGWanderAffector::reset(int systemIdx) { - if(m_wanderData.contains(systemIdx)) + if (m_wanderData.contains(systemIdx)) delete m_wanderData[systemIdx]; m_wanderData.remove(systemIdx); } @@ -112,30 +112,30 @@ bool QSGWanderAffector::affectParticle(QSGParticleData* data, qreal dt) qreal dx = dt * m_pace * (2 * qreal(qrand())/RAND_MAX - 1); qreal dy = dt * m_pace * (2 * qreal(qrand())/RAND_MAX - 1); qreal newX, newY; - switch(m_physics){ + switch (m_physics){ case Position: newX = data->curX() + dx; - if(m_xVariance > qAbs(newX) ) + if (m_xVariance > qAbs(newX) ) data->x += dx; newY = data->curY() + dy; - if(m_yVariance > qAbs(newY) ) + if (m_yVariance > qAbs(newY) ) data->y += dy; break; default: case Velocity: newX = data->curSX() + dx; - if(m_xVariance > qAbs(newX) ) + if (m_xVariance > qAbs(newX) ) data->setInstantaneousSX(newX); newY = data->curSY() + dy; - if(m_yVariance > qAbs(newY) ) + if (m_yVariance > qAbs(newY) ) data->setInstantaneousSY(newY); break; case Acceleration: newX = data->ax + dx; - if(m_xVariance > qAbs(newX) ) + if (m_xVariance > qAbs(newX) ) data->setInstantaneousAX(newX); newY = data->ay + dy; - if(m_yVariance > qAbs(newY) ) + if (m_yVariance > qAbs(newY) ) data->setInstantaneousAY(newY); break; } |