From: Alan Alpert Date: Fri, 9 Sep 2011 04:45:20 +0000 (+1000) Subject: Make activeGroups usable. X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=fded142474bcafd3a5a26e93814ff4d36acbda05;p=konrad%2Fqtdeclarative.git Make activeGroups usable. It actually relied on functionality inside the affectSystem method, when it was intended to be used in subclass reimplmentations. That functionality is now in the function itself. Change-Id: Ie01f5a5d18a15ca207422869d221d75d63b17789 Reviewed-on: http://codereview.qt-project.org/4509 Reviewed-by: Qt Sanity Bot Reviewed-by: Martin Jones --- diff --git a/src/declarative/particles/qsgparticleaffector.cpp b/src/declarative/particles/qsgparticleaffector.cpp index 3554121..f637a17 100644 --- a/src/declarative/particles/qsgparticleaffector.cpp +++ b/src/declarative/particles/qsgparticleaffector.cpp @@ -140,6 +140,16 @@ void QSGParticleAffector::componentComplete() QSGItem::componentComplete(); } +bool QSGParticleAffector::activeGroup(int g) { + if (m_updateIntSet){ + m_groups.clear(); + foreach (const QString &p, m_particles) + m_groups << m_system->m_groupIds[p];//###Can this occur before group ids are properly assigned? + m_updateIntSet = false; + } + return m_groups.isEmpty() || m_groups.contains(g); +} + void QSGParticleAffector::affectSystem(qreal dt) { if (!m_enabled) @@ -147,18 +157,12 @@ void QSGParticleAffector::affectSystem(qreal dt) //If not reimplemented, calls affect particle per particle //But only on particles in targeted system/area bool affectedConnected = isAffectedConnected(); - if (m_updateIntSet){ - m_groups.clear(); - foreach (const QString &p, m_particles) - m_groups << m_system->m_groupIds[p];//###Can this occur before group ids are properly assigned? - m_updateIntSet = false; - } updateOffsets();//### Needed if an ancestor is transformed. foreach (QSGParticleGroupData* gd, m_system->m_groupData){ foreach (QSGParticleData* d, gd->data){ if (!d) continue; - if (m_groups.isEmpty() || m_groups.contains(d->group)){ + if (activeGroup(d->group)){ if ((m_onceOff && m_onceOffed.contains(qMakePair(d->group, d->index))) || !d->stillAlive()) continue; diff --git a/src/declarative/particles/qsgparticleaffector_p.h b/src/declarative/particles/qsgparticleaffector_p.h index c808ef4..5700969 100644 --- a/src/declarative/particles/qsgparticleaffector_p.h +++ b/src/declarative/particles/qsgparticleaffector_p.h @@ -170,7 +170,7 @@ protected: bool m_needsReset;//### What is this really saving? QSGParticleSystem* m_system; QStringList m_particles; - bool activeGroup(int g) {return m_groups.isEmpty() || m_groups.contains(g);} + bool activeGroup(int g); bool m_enabled; virtual void componentComplete(); QPointF m_offset;