Make activeGroups usable.
authorAlan Alpert <alan.alpert@nokia.com>
Fri, 9 Sep 2011 04:45:20 +0000 (14:45 +1000)
committerQt by Nokia <qt-info@nokia.com>
Mon, 12 Sep 2011 23:43:37 +0000 (01:43 +0200)
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 <qt_sanity_bot@ovi.com>
Reviewed-by: Martin Jones <martin.jones@nokia.com>

src/declarative/particles/qsgparticleaffector.cpp
src/declarative/particles/qsgparticleaffector_p.h

index 3554121..f637a17 100644 (file)
@@ -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;
index c808ef4..5700969 100644 (file)
@@ -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;