Update system offset every frame
authorAlan Alpert <alan.alpert@nokia.com>
Thu, 15 Sep 2011 04:04:36 +0000 (14:04 +1000)
committerQt by Nokia <qt-info@nokia.com>
Fri, 16 Sep 2011 01:48:32 +0000 (03:48 +0200)
May be expensive if large systems animate painters, but seems safer than
messing with the tranformation matrix.

Change-Id: Ie5b21e9f238b5305bef44c48027a3337c70b2aaa
Reviewed-on: http://codereview.qt-project.org/4933
Reviewed-by: Martin Jones <martin.jones@nokia.com>

src/declarative/particles/qsgparticlepainter.cpp
src/declarative/particles/qsgparticlepainter_p.h

index aec8690..1b3453a 100644 (file)
@@ -67,12 +67,6 @@ QSGParticlePainter::QSGParticlePainter(QSGItem *parent) :
     QSGItem(parent),
     m_system(0), m_count(0), m_sentinel(new QSGParticleData(0))
 {
-    connect(this, SIGNAL(parentChanged(QSGItem*)),
-            this, SLOT(calcSystemOffset()));
-    connect(this, SIGNAL(xChanged()),
-            this, SLOT(calcSystemOffset()));
-    connect(this, SIGNAL(yChanged()),
-            this, SLOT(calcSystemOffset()));
 }
 
 void QSGParticlePainter::componentComplete()
@@ -91,10 +85,6 @@ void QSGParticlePainter::setSystem(QSGParticleSystem *arg)
         m_system = arg;
         if (m_system){
             m_system->registerParticlePainter(this);
-            connect(m_system, SIGNAL(xChanged()),
-                    this, SLOT(calcSystemOffset()));
-            connect(m_system, SIGNAL(yChanged()),
-                    this, SLOT(calcSystemOffset()));
             reset();
         }
         emit systemChanged(arg);
@@ -118,7 +108,6 @@ void QSGParticlePainter::reload(QSGParticleData* d)
 
 void QSGParticlePainter::reset()
 {
-    calcSystemOffset(true);//In case an ancestor changed in some way
 }
 
 void QSGParticlePainter::setCount(int c)//### TODO: some resizeing so that particles can reallocate on size change instead of recreate
@@ -154,6 +143,7 @@ void QSGParticlePainter::calcSystemOffset(bool resetPending)
 typedef QPair<int,int> intPair;
 void QSGParticlePainter::performPendingCommits()
 {
+    calcSystemOffset();
     foreach (intPair p, m_pendingCommits)
         commit(p.first, p.second);
     m_pendingCommits.clear();
index d469947..4b627e9 100644 (file)
@@ -86,17 +86,16 @@ signals:
     void groupsChanged(QStringList arg);
 
 public slots:
-void setSystem(QSGParticleSystem* arg);
+    void setSystem(QSGParticleSystem* arg);
 
-void setGroups(QStringList arg)
-{
-    if (m_groups != arg) {
-        m_groups = arg;
-        emit groupsChanged(arg);
+    void setGroups(QStringList arg)
+    {
+        if (m_groups != arg) {
+            m_groups = arg;
+            emit groupsChanged(arg);
+        }
     }
-}
 
-private slots:
     void calcSystemOffset(bool resetPending = false);
 
 protected: