Refactor ParticleSystem members
authorAlan Alpert <alan.alpert@nokia.com>
Thu, 29 Sep 2011 01:22:50 +0000 (11:22 +1000)
committerQt by Nokia <qt-info@nokia.com>
Fri, 30 Sep 2011 08:37:05 +0000 (10:37 +0200)
Leave m_ for private members.

Change-Id: Ia20565a7af6c5db45923eb349238b94b88472f7b
Reviewed-on: http://codereview.qt-project.org/5762
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Alan Alpert <alan.alpert@nokia.com>

13 files changed:
src/declarative/particles/qsgage.cpp
src/declarative/particles/qsgcustomaffector.cpp
src/declarative/particles/qsgcustomparticle.cpp
src/declarative/particles/qsgimageparticle.cpp
src/declarative/particles/qsgitemparticle.cpp
src/declarative/particles/qsgparticleaffector.cpp
src/declarative/particles/qsgparticleemitter.cpp
src/declarative/particles/qsgparticlepainter.cpp
src/declarative/particles/qsgparticlesystem.cpp
src/declarative/particles/qsgparticlesystem_p.h
src/declarative/particles/qsgspritegoal.cpp
src/declarative/particles/qsgtrailemitter.cpp
src/declarative/particles/qsgturbulence.cpp

index 0caa8be..da7736a 100644 (file)
@@ -86,7 +86,7 @@ bool QSGAgeAffector::affectParticle(QSGParticleData *d, qreal dt)
 {
     Q_UNUSED(dt);
     if (d->stillAlive()){
-        qreal curT = (qreal)m_system->m_timeInt/1000.0;
+        qreal curT = (qreal)m_system->timeInt/1000.0;
         qreal ttl = (qreal)m_lifeLeft/1000.0;
         if (!m_advancePosition && ttl > 0){
             qreal x = d->curX();
index 77da5c5..9f8db2c 100644 (file)
@@ -81,8 +81,8 @@ void QSGCustomAffector::affectSystem(qreal dt)
     updateOffsets();
 
     QList<QSGParticleData*> toAffect;
-    foreach (QSGParticleGroupData* gd, m_system->m_groupData)
-        if (activeGroup(m_system->m_groupData.key(gd)))
+    foreach (QSGParticleGroupData* gd, m_system->groupData)
+        if (activeGroup(m_system->groupData.key(gd)))
             foreach (QSGParticleData* d, gd->data)
                 if (shouldAffect(d))
                     toAffect << d;
index 5580a48..5aad023 100644 (file)
@@ -477,8 +477,8 @@ QSGShaderEffectNode* QSGCustomParticle::buildCustomNodes()
     s.vertexCode = qt_particles_template_vertex_code + s.vertexCode;
     m_material->setProgramSource(s);
     foreach (const QString &str, m_groups){
-        int gIdx = m_system->m_groupIds[str];
-        int count = m_system->m_groupData[gIdx]->size();
+        int gIdx = m_system->groupIds[str];
+        int count = m_system->groupData[gIdx]->size();
 
         QSGShaderEffectNode* node = new QSGShaderEffectNode();
         m_nodes.insert(gIdx, node);
@@ -566,7 +566,7 @@ void QSGCustomParticle::buildData()
 
 void QSGCustomParticle::initialize(int gIdx, int pIdx)
 {
-    QSGParticleData* datum = m_system->m_groupData[gIdx]->data[pIdx];
+    QSGParticleData* datum = m_system->groupData[gIdx]->data[pIdx];
     datum->r = rand()/(qreal)RAND_MAX;
 }
 
@@ -575,7 +575,7 @@ void QSGCustomParticle::commit(int gIdx, int pIdx)
     if (m_nodes[gIdx] == 0)
         return;
 
-    QSGParticleData* datum = m_system->m_groupData[gIdx]->data[pIdx];
+    QSGParticleData* datum = m_system->groupData[gIdx]->data[pIdx];
     PlainVertices *particles = (PlainVertices *) m_nodes[gIdx]->geometry()->vertexData();
     PlainVertex *vertices = (PlainVertex *)&particles[pIdx];
     for (int i=0; i<4; ++i) {
index 7632384..c6b5138 100644 (file)
@@ -888,7 +888,7 @@ void QSGImageParticle::resetColor()
 {
     m_explicitColor = false;
     foreach (const QString &str, m_groups)
-        foreach (QSGParticleData* d, m_system->m_groupData[m_system->m_groupIds[str]]->data)
+        foreach (QSGParticleData* d, m_system->groupData[m_system->groupIds[str]]->data)
             if (d->colorOwner == this)
                 d->colorOwner = 0;
     m_color = QColor();
@@ -904,7 +904,7 @@ void QSGImageParticle::resetRotation()
 {
     m_explicitRotation = false;
     foreach (const QString &str, m_groups)
-        foreach (QSGParticleData* d, m_system->m_groupData[m_system->m_groupIds[str]]->data)
+        foreach (QSGParticleData* d, m_system->groupData[m_system->groupIds[str]]->data)
             if (d->rotationOwner == this)
                 d->rotationOwner = 0;
     m_rotation = 0;
@@ -918,7 +918,7 @@ void QSGImageParticle::resetDeformation()
 {
     m_explicitDeformation = false;
     foreach (const QString &str, m_groups)
-        foreach (QSGParticleData* d, m_system->m_groupData[m_system->m_groupIds[str]]->data)
+        foreach (QSGParticleData* d, m_system->groupData[m_system->groupIds[str]]->data)
             if (d->deformationOwner == this)
                 d->deformationOwner = 0;
     if (m_xVector)
@@ -1021,7 +1021,7 @@ void QSGImageParticle::clearShadows()
 //Only call if you need to, may initialize the whole array first time
 QSGParticleData* QSGImageParticle::getShadowDatum(QSGParticleData* datum)
 {
-    QSGParticleGroupData* gd = m_system->m_groupData[datum->group];
+    QSGParticleGroupData* gd = m_system->groupData[datum->group];
     if (!m_shadowData.contains(datum->group)) {
         QVector<QSGParticleData*> data;
         for (int i=0; i<gd->size(); i++){
@@ -1065,8 +1065,8 @@ QSGGeometryNode* QSGImageParticle::buildParticleNodes()
     }
 
     foreach (const QString &str, m_groups){//For sharing higher levels, need to have highest used so it renders
-        int gIdx = m_system->m_groupIds[str];
-        foreach (QSGParticlePainter* p, m_system->m_groupData[gIdx]->painters){
+        int gIdx = m_system->groupIds[str];
+        foreach (QSGParticlePainter* p, m_system->groupData[gIdx]->painters){
             QSGImageParticle* other = qobject_cast<QSGImageParticle*>(p);
             if (other){
                 if (other->perfLevel > perfLevel) {
@@ -1144,8 +1144,8 @@ QSGGeometryNode* QSGImageParticle::buildParticleNodes()
     }
 
     foreach (const QString &str, m_groups){
-        int gIdx = m_system->m_groupIds[str];
-        int count = m_system->m_groupData[gIdx]->size();
+        int gIdx = m_system->groupIds[str];
+        int count = m_system->groupData[gIdx]->size();
         QSGGeometryNode* node = new QSGGeometryNode();
         node->setMaterial(m_material);
         node->markDirty(QSGNode::DirtyMaterial);
@@ -1257,8 +1257,8 @@ void QSGImageParticle::prepareNextFrame()
             qDebug() << "QSGImageParticle Nodes: ";
             int count = 0;
             foreach(int i, m_nodes.keys()){
-                qDebug() << "Group " << i << " (" << m_system->m_groupData[i]->size() << " particles)";
-                count += m_system->m_groupData[i]->size();
+                qDebug() << "Group " << i << " (" << m_system->groupData[i]->size() << " particles)";
+                count += m_system->groupData[i]->size();
             }
             qDebug() << "Total count: " << count;
         }
@@ -1273,8 +1273,8 @@ void QSGImageParticle::prepareNextFrame()
         getState<ImageMaterialData>(m_material)->animcount = m_spriteEngine->spriteCount();
         m_spriteEngine->updateSprites(timeStamp);
         foreach (const QString &str, m_groups){
-            int gIdx = m_system->m_groupIds[str];
-            int count = m_system->m_groupData[gIdx]->size();
+            int gIdx = m_system->groupIds[str];
+            int count = m_system->groupData[gIdx]->size();
 
             Vertices<SpriteVertex>* particles = (Vertices<SpriteVertex> *) m_nodes[gIdx]->geometry()->vertexData();
             for (int i=0; i < count; i++){
@@ -1311,7 +1311,7 @@ void QSGImageParticle::reloadColor(const Color4ub &c, QSGParticleData* d)
 void QSGImageParticle::initialize(int gIdx, int pIdx)
 {
     Color4ub color;
-    QSGParticleData* datum = m_system->m_groupData[gIdx]->data[pIdx];
+    QSGParticleData* datum = m_system->groupData[gIdx]->data[pIdx];
     qreal redVariation = m_color_variation + m_redVariation;
     qreal greenVariation = m_color_variation + m_greenVariation;
     qreal blueVariation = m_color_variation + m_blueVariation;
@@ -1410,7 +1410,7 @@ void QSGImageParticle::commit(int gIdx, int pIdx)
     QSGGeometryNode *node = m_nodes[gIdx];
     if (!node)
         return;
-    QSGParticleData* datum = m_system->m_groupData[gIdx]->data[pIdx];
+    QSGParticleData* datum = m_system->groupData[gIdx]->data[pIdx];
     node->setFlag(QSGNode::OwnsGeometry, false);
     SpriteVertex *spriteVertices = (SpriteVertex *) node->geometry()->vertexData();
     DeformableVertex *deformableVertices = (DeformableVertex *) node->geometry()->vertexData();
index 2572d67..19e64b2 100644 (file)
@@ -138,7 +138,7 @@ void QSGItemParticle::give(QSGItem *item)
 
 void QSGItemParticle::initialize(int gIdx, int pIdx)
 {
-    m_loadables << m_system->m_groupData[gIdx]->data[pIdx];//defer to other thread
+    m_loadables << m_system->groupData[gIdx]->data[pIdx];//defer to other thread
 }
 
 void QSGItemParticle::commit(int, int)
@@ -227,11 +227,11 @@ void QSGItemParticle::prepareNextFrame()
 
     //TODO: Size, better fade?
     foreach (const QString &str, m_groups){
-        int gIdx = m_system->m_groupIds[str];
-        int count = m_system->m_groupData[gIdx]->size();
+        int gIdx = m_system->groupIds[str];
+        int count = m_system->groupData[gIdx]->size();
 
         for (int i=0; i<count; i++){
-            QSGParticleData* data = m_system->m_groupData[gIdx]->data[i];
+            QSGParticleData* data = m_system->groupData[gIdx]->data[i];
             QSGItem* item = data->delegate;
             if (!item)
                 continue;
index 12b8135..66cbba7 100644 (file)
@@ -150,7 +150,7 @@ bool QSGParticleAffector::activeGroup(int g) {
     if (m_updateIntSet){
         m_groupIds.clear();
         foreach (const QString &p, m_groups)
-            m_groupIds << m_system->m_groupIds[p];//###Can this occur before group ids are properly assigned?
+            m_groupIds << m_system->groupIds[p];//###Can this occur before group ids are properly assigned?
         m_updateIntSet = false;
     }
     return m_groupIds.isEmpty() || m_groupIds.contains(g);
@@ -178,7 +178,7 @@ bool QSGParticleAffector::shouldAffect(QSGParticleData* d)
 
 void QSGParticleAffector::postAffect(QSGParticleData* d)
 {
-    m_system->m_needsReset << d;
+    m_system->needsReset << d;
     if (m_onceOff)
         m_onceOffed << qMakePair(d->group, d->index);
     if (isAffectedConnected())
@@ -192,8 +192,8 @@ void QSGParticleAffector::affectSystem(qreal dt)
     //If not reimplemented, calls affect particle per particle
     //But only on particles in targeted system/area
     updateOffsets();//### Needed if an ancestor is transformed.
-    foreach (QSGParticleGroupData* gd, m_system->m_groupData)
-        if (activeGroup(m_system->m_groupData.key(gd)))
+    foreach (QSGParticleGroupData* gd, m_system->groupData)
+        if (activeGroup(m_system->groupData.key(gd)))
             foreach (QSGParticleData* d, gd->data)
                 if (shouldAffect(d))
                     if (affectParticle(d, dt))
@@ -224,7 +224,7 @@ bool QSGParticleAffector::isColliding(QSGParticleData *d)
     qreal myCurY = d->curY();
     qreal myCurSize = d->curSize()/2;
     foreach (const QString &group, m_whenCollidingWith){
-        foreach (QSGParticleData* other, m_system->m_groupData[m_system->m_groupIds[group]]->data){
+        foreach (QSGParticleData* other, m_system->groupData[m_system->groupIds[group]]->data){
             if (!other->stillAlive())
                 continue;
             qreal otherCurX = other->curX();
index bdd008a..51cfb07 100644 (file)
@@ -402,7 +402,7 @@ void QSGParticleEmitter::emitWindow(int timeStamp)
 
     while ((pt < time && m_emitCap) || !m_burstQueue.isEmpty()) {
         //int pos = m_last_particle % m_particle_count;
-        QSGParticleData* datum = m_system->newDatum(m_system->m_groupIds[m_group], !m_overwrite);
+        QSGParticleData* datum = m_system->newDatum(m_system->groupIds[m_group], !m_overwrite);
         if (datum){//actually emit(otherwise we've been asked to skip this one)
             datum->e = this;//###useful?
             qreal t = 1 - (pt - opt) / dt;
index fe689ee..4f6b18c 100644 (file)
@@ -132,8 +132,8 @@ void QSGParticlePainter::calcSystemOffset(bool resetPending)
     if (lastOffset != m_systemOffset && !resetPending){
         //Reload all particles//TODO: Necessary?
         foreach (const QString &g, m_groups){
-            int gId = m_system->m_groupIds[g];
-            foreach (QSGParticleData* d, m_system->m_groupData[gId]->data)
+            int gId = m_system->groupIds[g];
+            foreach (QSGParticleData* d, m_system->groupData[gId]->data)
                 reload(d);
         }
     }
index f886865..78e37e7 100644 (file)
@@ -300,7 +300,7 @@ int QSGParticleGroupData::size()
 
 QString QSGParticleGroupData::name()//### Worth caching as well?
 {
-    return m_system->m_groupIds.key(index);
+    return m_system->groupIds.key(index);
 }
 
 void QSGParticleGroupData::setSize(int newSize){
@@ -358,7 +358,7 @@ QSGParticleData* QSGParticleGroupData::newDatum(bool respectsLimits)
 
 bool QSGParticleGroupData::recycle()
 {
-    while (dataHeap.top() <= m_system->m_timeInt){
+    while (dataHeap.top() <= m_system->timeInt){
         foreach (QSGParticleData* datum, dataHeap.pop()){
             if (!datum->stillAlive()){
                 reusableIndexes << datum->index;
@@ -376,7 +376,7 @@ void QSGParticleGroupData::prepareRecycler(QSGParticleData* d){
     if (d->lifeSpan*1000 < m_system->maxLife){
         dataHeap.insert(d);
     } else {
-        while ((roundedTime(d->t) + 2*m_system->maxLife/3) <= m_system->m_timeInt)
+        while ((roundedTime(d->t) + 2*m_system->maxLife/3) <= m_system->timeInt)
             d->extendLife(m_system->maxLife/3000.0);
         dataHeap.insertTimed(d, roundedTime(d->t) + 2*m_system->maxLife/3);
     }
@@ -470,7 +470,7 @@ QDeclarativeV8Handle QSGParticleData::v8Value()
 //sets the x accleration without affecting the instantaneous x velocity or position
 void QSGParticleData::setInstantaneousAX(qreal ax)
 {
-    qreal t = (system->m_timeInt / 1000.0) - this->t;
+    qreal t = (system->timeInt / 1000.0) - this->t;
     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;
@@ -483,7 +483,7 @@ void QSGParticleData::setInstantaneousAX(qreal ax)
 //sets the x velocity without affecting the instantaneous x postion
 void QSGParticleData::setInstantaneousVX(qreal vx)
 {
-    qreal t = (system->m_timeInt / 1000.0) - this->t;
+    qreal t = (system->timeInt / 1000.0) - this->t;
     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;
@@ -495,14 +495,14 @@ void QSGParticleData::setInstantaneousVX(qreal vx)
 //sets the instantaneous x postion
 void QSGParticleData::setInstantaneousX(qreal x)
 {
-    qreal t = (system->m_timeInt / 1000.0) - this->t;
+    qreal t = (system->timeInt / 1000.0) - this->t;
     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 t = (system->timeInt / 1000.0) - this->t;
     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;
@@ -515,7 +515,7 @@ void QSGParticleData::setInstantaneousAY(qreal ay)
 //sets the y velocity without affecting the instantaneous y position
 void QSGParticleData::setInstantaneousVY(qreal vy)
 {
-    qreal t = (system->m_timeInt / 1000.0) - this->t;
+    qreal t = (system->timeInt / 1000.0) - this->t;
     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;
@@ -527,31 +527,31 @@ void QSGParticleData::setInstantaneousVY(qreal vy)
 //sets the instantaneous Y position
 void QSGParticleData::setInstantaneousY(qreal y)
 {
-    qreal t = (system->m_timeInt / 1000.0) - this->t;
+    qreal t = (system->timeInt / 1000.0) - this->t;
     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;
+    qreal t = (system->timeInt / 1000.0) - this->t;
     return this->x + this->vx * t + 0.5 * this->ax * t * t;
 }
 
 qreal QSGParticleData::curVX() const
 {
-    qreal t = (system->m_timeInt / 1000.0) - this->t;
+    qreal t = (system->timeInt / 1000.0) - this->t;
     return this->vx + t*this->ax;
 }
 
 qreal QSGParticleData::curY() const
 {
-    qreal t = (system->m_timeInt / 1000.0) - this->t;
+    qreal t = (system->timeInt / 1000.0) - this->t;
     return y + vy * t + 0.5 * ay * t * t;
 }
 
 qreal QSGParticleData::curVY() const
 {
-    qreal t = (system->m_timeInt / 1000.0) - this->t;
+    qreal t = (system->timeInt / 1000.0) - this->t;
     return vy + t*ay;
 }
 
@@ -562,14 +562,14 @@ void QSGParticleData::debugDump()
              << "Vel: " << vx << "," << vy
              << "Acc: " << ax << "," << ay
              << "Size: " << size << "," << endSize
-             << "Time: " << t << "," <<lifeSpan << ";" << (system->m_timeInt / 1000.0) ;
+             << "Time: " << t << "," <<lifeSpan << ";" << (system->timeInt / 1000.0) ;
 }
 
 bool QSGParticleData::stillAlive()
 {
     if (!system)
         return false;
-    return (t + lifeSpan - EPSILON) > ((qreal)system->m_timeInt/1000.0);
+    return (t + lifeSpan - EPSILON) > ((qreal)system->timeInt/1000.0);
 }
 
 float QSGParticleData::curSize()
@@ -583,7 +583,7 @@ float QSGParticleData::lifeLeft()
 {
     if (!system)
         return 0.0f;
-    return (t + lifeSpan) - (system->m_timeInt/1000.0);
+    return (t + lifeSpan) - (system->timeInt/1000.0);
 }
 
 void QSGParticleData::extendLife(float time)
@@ -596,7 +596,7 @@ void QSGParticleData::extendLife(float time)
     t += time;
     animT += time;
 
-    qreal elapsed = (system->m_timeInt / 1000.0) - t;
+    qreal elapsed = (system->timeInt / 1000.0) - t;
     qreal evy = newVY - elapsed*ay;
     qreal ey = newY - elapsed*evy - 0.5 * elapsed*elapsed*ay;
     qreal evx = newVX - elapsed*ax;
@@ -609,8 +609,8 @@ void QSGParticleData::extendLife(float time)
 }
 
 QSGParticleSystem::QSGParticleSystem(QSGItem *parent) :
-    QSGItem(parent), m_particle_count(0), m_running(true), m_paused(false)
-  , m_nextIndex(0), m_componentComplete(false), m_stateEngine(0)
+    QSGItem(parent), particleCount(0), m_running(true), m_paused(false)
+  , m_nextIndex(0), m_componentComplete(false), stateEngine(0)
 {
     connect(&m_painterMapper, SIGNAL(mapped(QObject*)),
             this, SLOT(loadPainter(QObject*)));
@@ -620,7 +620,7 @@ QSGParticleSystem::QSGParticleSystem(QSGItem *parent) :
 
 QSGParticleSystem::~QSGParticleSystem()
 {
-    foreach (QSGParticleGroupData* gd, m_groupData)
+    foreach (QSGParticleGroupData* gd, groupData)
         delete gd;
 }
 
@@ -629,13 +629,13 @@ void QSGParticleSystem::initGroups()
     m_reusableIndexes.clear();
     m_nextIndex = 0;
 
-    qDeleteAll(m_groupData);
-    m_groupData.clear();
-    m_groupIds.clear();
+    qDeleteAll(groupData);
+    groupData.clear();
+    groupIds.clear();
 
     QSGParticleGroupData* gd = new QSGParticleGroupData(0, this);//Default group
-    m_groupData.insert(0,gd);
-    m_groupIds.insert("",0);
+    groupData.insert(0,gd);
+    groupIds.insert("",0);
     m_nextGroupId = 1;
 }
 
@@ -754,14 +754,14 @@ void QSGParticleSystem::reset()
     if (!m_componentComplete)
         return;
 
-    m_timeInt = 0;
+    timeInt = 0;
     //Clear guarded pointers which have been deleted
     int cleared = 0;
     cleared += m_emitters.removeAll(0);
     cleared += m_painters.removeAll(0);
     cleared += m_affectors.removeAll(0);
 
-    m_bySysIdx.resize(0);
+    bySysIdx.resize(0);
     initGroups();//Also clears all logical particles
 
     if (!m_running)
@@ -786,7 +786,7 @@ void QSGParticleSystem::reset()
         if (m_paused)
             m_animation->pause();
     }
-    m_initialized = true;
+    initialized = true;
 }
 
 
@@ -797,25 +797,25 @@ void QSGParticleSystem::loadPainter(QObject *p)
 
     QSGParticlePainter* painter = qobject_cast<QSGParticlePainter*>(p);
     Q_ASSERT(painter);//XXX
-    foreach (QSGParticleGroupData* sg, m_groupData)
+    foreach (QSGParticleGroupData* sg, groupData)
         sg->painters.remove(painter);
     int particleCount = 0;
     if (painter->groups().isEmpty()){//Uses default particle
         QStringList def;
         def << "";
         painter->setGroups(def);
-        particleCount += m_groupData[0]->size();
-        m_groupData[0]->painters << painter;
+        particleCount += groupData[0]->size();
+        groupData[0]->painters << painter;
     }else{
         foreach (const QString &group, painter->groups()){
-            if (group != QLatin1String("") && !m_groupIds[group]){//new group
+            if (group != QLatin1String("") && !groupIds[group]){//new group
                 int id = m_nextGroupId++;
                 QSGParticleGroupData* gd = new QSGParticleGroupData(id, this);
-                m_groupIds.insert(group, id);
-                m_groupData.insert(id, gd);
+                groupIds.insert(group, id);
+                groupData.insert(id, gd);
             }
-            particleCount += m_groupData[m_groupIds[group]]->size();
-            m_groupData[m_groupIds[group]]->painters << painter;
+            particleCount += groupData[groupIds[group]]->size();
+            groupData[groupIds[group]]->painters << painter;
         }
     }
     painter->setCount(particleCount);
@@ -834,36 +834,36 @@ void QSGParticleSystem::emittersChanged()
     QList<int> previousSizes;
     QList<int> newSizes;
     for (int i=0; i<m_nextGroupId; i++){
-        previousSizes << m_groupData[i]->size();
+        previousSizes << groupData[i]->size();
         newSizes << 0;
     }
 
     foreach (QSGParticleEmitter* e, m_emitters){//Populate groups and set sizes.
-        if (!m_groupIds.contains(e->group())
-                || (!e->group().isEmpty() && !m_groupIds[e->group()])){//or it was accidentally inserted by a failed lookup earlier
+        if (!groupIds.contains(e->group())
+                || (!e->group().isEmpty() && !groupIds[e->group()])){//or it was accidentally inserted by a failed lookup earlier
             int id = m_nextGroupId++;
             QSGParticleGroupData* gd = new QSGParticleGroupData(id, this);
-            m_groupIds.insert(e->group(), id);
-            m_groupData.insert(id, gd);
+            groupIds.insert(e->group(), id);
+            groupData.insert(id, gd);
             previousSizes << 0;
             newSizes << 0;
         }
-        newSizes[m_groupIds[e->group()]] += e->particleCount();
+        newSizes[groupIds[e->group()]] += e->particleCount();
         //###: Cull emptied groups?
     }
 
     //TODO: Garbage collection?
-    m_particle_count = 0;
+    particleCount = 0;
     for (int i=0; i<m_nextGroupId; i++){
-        m_groupData[i]->setSize(qMax(newSizes[i], previousSizes[i]));
-        m_particle_count += m_groupData[i]->size();
+        groupData[i]->setSize(qMax(newSizes[i], previousSizes[i]));
+        particleCount += groupData[i]->size();
     }
 
     if (m_debugMode)
-        qDebug() << "Particle system emitters changed. New particle count: " << m_particle_count;
+        qDebug() << "Particle system emitters changed. New particle count: " << particleCount;
 
-    if (m_particle_count > m_bySysIdx.size())//New datum requests haven't updated it
-        m_bySysIdx.resize(m_particle_count);
+    if (particleCount > bySysIdx.size())//New datum requests haven't updated it
+        bySysIdx.resize(particleCount);
 
     foreach (QSGParticlePainter *p, m_painters)
         loadPainter(p);
@@ -877,19 +877,19 @@ void QSGParticleSystem::createEngine()
 {
     if (!m_componentComplete)
         return;
-    if (m_stateEngine && m_debugMode)
+    if (stateEngine && m_debugMode)
         qDebug() << "Resetting Existing Sprite Engine...";
     //### Solve the losses if size/states go down
     foreach (QSGParticleGroup* group, m_groups){
         bool exists = false;
-        foreach (const QString &name, m_groupIds.keys())
+        foreach (const QString &name, groupIds.keys())
             if (group->name() == name)
                 exists = true;
         if (!exists){
             int id = m_nextGroupId++;
             QSGParticleGroupData* gd = new QSGParticleGroupData(id, this);
-            m_groupIds.insert(group->name(), id);
-            m_groupData.insert(id, gd);
+            groupIds.insert(group->name(), id);
+            groupData.insert(id, gd);
         }
     }
 
@@ -898,7 +898,7 @@ void QSGParticleSystem::createEngine()
         QList<QSGParticleGroup*> newList;
         for (int i=0; i<m_nextGroupId; i++){
             bool exists = false;
-            QString name = m_groupData[i]->name();
+            QString name = groupData[i]->name();
             foreach (QSGParticleGroup* existing, m_groups){
                 if (existing->name() == name){
                     newList << existing;
@@ -915,25 +915,25 @@ void QSGParticleSystem::createEngine()
         foreach (QSGParticleGroup* g, m_groups)
             states << (QSGStochasticState*)g;
 
-        if (!m_stateEngine)
-            m_stateEngine = new QSGStochasticEngine(this);
-        m_stateEngine->setCount(m_particle_count);
-        m_stateEngine->m_states = states;
+        if (!stateEngine)
+            stateEngine = new QSGStochasticEngine(this);
+        stateEngine->setCount(particleCount);
+        stateEngine->m_states = states;
 
-        connect(m_stateEngine, SIGNAL(stateChanged(int)),
+        connect(stateEngine, SIGNAL(stateChanged(int)),
                 this, SLOT(particleStateChange(int)));
 
     }else{
-        if (m_stateEngine)
-            delete m_stateEngine;
-        m_stateEngine = 0;
+        if (stateEngine)
+            delete stateEngine;
+        stateEngine = 0;
     }
 
 }
 
 void QSGParticleSystem::particleStateChange(int idx)
 {
-    moveGroups(m_bySysIdx[idx], m_stateEngine->curState(idx));
+    moveGroups(bySysIdx[idx], stateEngine->curState(idx));
 }
 
 void QSGParticleSystem::moveGroups(QSGParticleData *d, int newGIdx)
@@ -946,7 +946,7 @@ void QSGParticleSystem::moveGroups(QSGParticleData *d, int newGIdx)
     finishNewDatum(pd);
 
     d->systemIndex = -1;
-    m_groupData[d->group]->kill(d);
+    groupData[d->group]->kill(d);
 }
 
 int QSGParticleSystem::nextSystemIndex()
@@ -956,10 +956,10 @@ int QSGParticleSystem::nextSystemIndex()
         m_reusableIndexes.remove(ret);
         return ret;
     }
-    if (m_nextIndex >= m_bySysIdx.size()){
-        m_bySysIdx.resize(m_bySysIdx.size() < 10 ? 10 : m_bySysIdx.size()*1.1);//###+1,10%,+10? Choose something non-arbitrarily
-        if (m_stateEngine)
-            m_stateEngine->setCount(m_bySysIdx.size());
+    if (m_nextIndex >= bySysIdx.size()){
+        bySysIdx.resize(bySysIdx.size() < 10 ? 10 : bySysIdx.size()*1.1);//###+1,10%,+10? Choose something non-arbitrarily
+        if (stateEngine)
+            stateEngine->setCount(bySysIdx.size());
 
     }
     return m_nextIndex++;
@@ -967,9 +967,9 @@ int QSGParticleSystem::nextSystemIndex()
 
 QSGParticleData* QSGParticleSystem::newDatum(int groupId, bool respectLimits, int sysIndex)
 {
-    Q_ASSERT(groupId < m_groupData.count());//XXX shouldn't really be an assert
+    Q_ASSERT(groupId < groupData.count());//XXX shouldn't really be an assert
 
-    QSGParticleData* ret = m_groupData[groupId]->newDatum(respectLimits);
+    QSGParticleData* ret = groupData[groupId]->newDatum(respectLimits);
     if (!ret){
         return 0;
     }
@@ -978,17 +978,17 @@ QSGParticleData* QSGParticleSystem::newDatum(int groupId, bool respectLimits, in
             ret->systemIndex = nextSystemIndex();
     }else{
         if (ret->systemIndex != -1){
-            if (m_stateEngine)
-                m_stateEngine->stop(ret->systemIndex);
+            if (stateEngine)
+                stateEngine->stop(ret->systemIndex);
             m_reusableIndexes << ret->systemIndex;
-            m_bySysIdx[ret->systemIndex] = 0;
+            bySysIdx[ret->systemIndex] = 0;
         }
         ret->systemIndex = sysIndex;
     }
-    m_bySysIdx[ret->systemIndex] = ret;
+    bySysIdx[ret->systemIndex] = ret;
 
-    if (m_stateEngine)
-        m_stateEngine->start(ret->systemIndex, ret->group);
+    if (stateEngine)
+        stateEngine->start(ret->systemIndex, ret->group);
 
     m_empty = false;
     return ret;
@@ -1008,44 +1008,44 @@ void QSGParticleSystem::emitParticle(QSGParticleData* pd)
 
 void QSGParticleSystem::finishNewDatum(QSGParticleData *pd){
     Q_ASSERT(pd);
-    m_groupData[pd->group]->prepareRecycler(pd);
+    groupData[pd->group]->prepareRecycler(pd);
 
     foreach (QSGParticleAffector *a, m_affectors)
         if (a && a->m_needsReset)
             a->reset(pd);
-    foreach (QSGParticlePainter* p, m_groupData[pd->group]->painters)
+    foreach (QSGParticlePainter* p, groupData[pd->group]->painters)
         if (p)
             p->load(pd);
 }
 
 void QSGParticleSystem::updateCurrentTime( int currentTime )
 {
-    if (!m_initialized)
+    if (!initialized)
         return;//error in initialization
 
     //### Elapsed time never shrinks - may cause problems if left emitting for weeks at a time.
-    qreal dt = m_timeInt / 1000.;
-    m_timeInt = currentTime;
-    qreal time =  m_timeInt / 1000.;
+    qreal dt = timeInt / 1000.;
+    timeInt = currentTime;
+    qreal time =  timeInt / 1000.;
     dt = time - dt;
-    m_needsReset.clear();
+    needsReset.clear();
 
     bool oldClear = m_empty;
     m_empty = true;
-    foreach (QSGParticleGroupData* gd, m_groupData)//Recycle all groups and see if they're out of live particles
+    foreach (QSGParticleGroupData* gd, groupData)//Recycle all groups and see if they're out of live particles
         m_empty = gd->recycle() && m_empty;
 
-    if (m_stateEngine)
-        m_stateEngine->updateSprites(m_timeInt);
+    if (stateEngine)
+        stateEngine->updateSprites(timeInt);
 
     foreach (QSGParticleEmitter* emitter, m_emitters)
         if (emitter)
-            emitter->emitWindow(m_timeInt);
+            emitter->emitWindow(timeInt);
     foreach (QSGParticleAffector* a, m_affectors)
         if (a)
             a->affectSystem(dt);
-    foreach (QSGParticleData* d, m_needsReset)
-        foreach (QSGParticlePainter* p, m_groupData[d->group]->painters)
+    foreach (QSGParticleData* d, needsReset)
+        foreach (QSGParticlePainter* p, groupData[d->group]->painters)
             if (p && d)
                 p->reload(d);
 
@@ -1057,10 +1057,10 @@ int QSGParticleSystem::systemSync(QSGParticlePainter* p)
 {
     if (!m_running)
         return 0;
-    if (!m_initialized)
+    if (!initialized)
         return 0;//error in initialization
     p->performPendingCommits();
-    return m_timeInt;
+    return timeInt;
 }
 
 
index d17a46f..084409f 100644 (file)
@@ -242,7 +242,7 @@ public:
         return m_running;
     }
 
-    int count(){ return m_particle_count; }
+    int count(){ return particleCount; }
 
     static const int maxLife = 600000;
 
@@ -277,7 +277,7 @@ private slots:
     void createEngine(); //### method invoked by sprite list changing (in engine.h) - pretty nasty
     void particleStateChange(int idx);
 
-public://###but only really for related class usage. Perhaps we should all be friends?
+public:
     //These can be called multiple times per frame, performance critical
     void emitParticle(QSGParticleData* p);
     QSGParticleData* newDatum(int groupId, bool respectLimits = true, int sysIdx = -1);//TODO: implement respectLimits in emitters (which means interacting with maxCount?)
@@ -288,21 +288,22 @@ public://###but only really for related class usage. Perhaps we should all be fr
     //This one only once per painter per frame
     int systemSync(QSGParticlePainter* p);
 
-    QSet<QSGParticleData*> m_needsReset;
-    QVector<QSGParticleData*> m_bySysIdx; //Another reference to the data (data owned by group), but by sysIdx
-    QHash<QString, int> m_groupIds;
-    QHash<int, QSGParticleGroupData*> m_groupData;
-    QSGStochasticEngine* m_stateEngine;
+    //Data members here for ease of related class and auto-test usage. Not "public" API.
+    QSet<QSGParticleData*> needsReset;
+    QVector<QSGParticleData*> bySysIdx; //Another reference to the data (data owned by group), but by sysIdx
+    QHash<QString, int> groupIds;
+    QHash<int, QSGParticleGroupData*> groupData;
+    QSGStochasticEngine* stateEngine;
 
-    int m_timeInt;
-    bool m_initialized;
+    int timeInt;
+    bool initialized;
+    int particleCount;
 
     void registerParticlePainter(QSGParticlePainter* p);
     void registerParticleEmitter(QSGParticleEmitter* e);
     void registerParticleAffector(QSGParticleAffector* a);
     void registerParticleGroup(QSGParticleGroup* g);
 
-    int m_particle_count;
     static void statePropertyRedirect(QDeclarativeListProperty<QObject> *prop, QObject *value);
     static void stateRedirect(QSGParticleGroup* group, QSGParticleSystem* sys, QObject *value);
     bool isPaused() const
index ec2be02..fd919e8 100644 (file)
@@ -72,7 +72,7 @@ QSGSpriteGoalAffector::QSGSpriteGoalAffector(QSGItem *parent) :
 void QSGSpriteGoalAffector::updateStateIndex(QSGStochasticEngine* e)
 {
     if (m_systemStates){
-        m_goalIdx = m_system->m_groupIds[m_goalState];
+        m_goalIdx = m_system->groupIds[m_goalState];
     }else{
         m_lastEngine = e;
         for (int i=0; i<e->stateCount(); i++){
@@ -103,11 +103,11 @@ bool QSGSpriteGoalAffector::affectParticle(QSGParticleData *d, qreal dt)
     QSGStochasticEngine *engine = 0;
     if (!m_systemStates){
         //TODO: Affect all engines
-        foreach (QSGParticlePainter *p, m_system->m_groupData[d->group]->painters)
+        foreach (QSGParticlePainter *p, m_system->groupData[d->group]->painters)
             if (qobject_cast<QSGImageParticle*>(p))
                 engine = qobject_cast<QSGImageParticle*>(p)->spriteEngine();
     }else{
-        engine = m_system->m_stateEngine;
+        engine = m_system->stateEngine;
         if (!engine)
             m_notUsingEngine = true;
     }
index 51d9875..f813e78 100644 (file)
@@ -120,7 +120,7 @@ bool QSGTrailEmitter::isEmitFollowConnected()
 void QSGTrailEmitter::recalcParticlesPerSecond(){
     if (!m_system)
         return;
-    m_followCount = m_system->m_groupData[m_system->m_groupIds[m_follow]]->size();
+    m_followCount = m_system->groupData[m_system->groupIds[m_follow]]->size();
     if (!m_followCount){
         setParticlesPerSecond(1);//XXX: Fix this horrendous hack, needed so they aren't turned off from start (causes crashes - test that when gone you don't crash with 0 PPPS)
     }else{
@@ -141,7 +141,7 @@ void QSGTrailEmitter::emitWindow(int timeStamp)
         return;
     if (!m_enabled && !m_pulseLeft && m_burstQueue.isEmpty())
         return;
-    if (m_followCount != m_system->m_groupData[m_system->m_groupIds[m_follow]]->size()){
+    if (m_followCount != m_system->groupData[m_system->groupIds[m_follow]]->size()){
         qreal oldPPS = m_particlesPerSecond;
         recalcParticlesPerSecond();
         if (m_particlesPerSecond != oldPPS)
@@ -165,9 +165,9 @@ void QSGTrailEmitter::emitWindow(int timeStamp)
     QPointF offset = m_system->mapFromItem(this, QPointF(0, 0));
     qreal sizeAtEnd = m_particleEndSize >= 0 ? m_particleEndSize : m_particleSize;
 
-    int gId = m_system->m_groupIds[m_follow];
-    int gId2 = m_system->m_groupIds[m_group];
-    foreach (QSGParticleData *d, m_system->m_groupData[gId]->data){
+    int gId = m_system->groupIds[m_follow];
+    int gId2 = m_system->groupIds[m_group];
+    foreach (QSGParticleData *d, m_system->groupData[gId]->data){
         if (!d || !d->stillAlive()){
             m_lastEmission[d->index] = time; //Should only start emitting when it returns to life
             continue;
index ac1306b..a5a2410 100644 (file)
@@ -185,8 +185,8 @@ void QSGTurbulenceAffector::affectSystem(qreal dt)
     updateOffsets();//### Needed if an ancestor is transformed.
 
     QRect boundsRect(0,0,m_gridSize,m_gridSize);
-    foreach (QSGParticleGroupData *gd, m_system->m_groupData){
-        if (!activeGroup(m_system->m_groupData.key(gd)))
+    foreach (QSGParticleGroupData *gd, m_system->groupData){
+        if (!activeGroup(m_system->groupData.key(gd)))
             continue;
         foreach (QSGParticleData *d, gd->data){
             if (!shouldAffect(d))