Update particles to use QElapsedTimer
authorAlan Alpert <alan.alpert@nokia.com>
Wed, 27 Apr 2011 01:19:24 +0000 (11:19 +1000)
committerAlan Alpert <alan.alpert@nokia.com>
Wed, 27 Apr 2011 23:53:07 +0000 (09:53 +1000)
Step one of fixing the limited lifetime bug. As this step should also
increase the lifetime 'a lot' step two may take a while.

Change-Id: I87bbe762803451f751e23d4bf8559c662fdf57a3
(cherry picked from commit 9cf15c135373f8190bf2cb62f9f99890cacf7d88)

src/imports/particles/coloredparticle.cpp
src/imports/particles/deformableparticle.cpp
src/imports/particles/modelparticle.cpp
src/imports/particles/particlesystem.cpp
src/imports/particles/particlesystem.h
src/imports/particles/spriteparticle.cpp
src/imports/particles/spriteparticle.h

index 7d0ec4c..449c6b2 100644 (file)
@@ -466,7 +466,7 @@ void ColoredParticle::prepareNextFrame()
         if(m_node == 0)
             return;
     }
-    uint timeStamp = m_system->systemSync(this);
+    qint64 timeStamp = m_system->systemSync(this);
 
     qreal time = timeStamp / 1000.;
     m_material->timestamp = time;
index 69de693..176ef2b 100644 (file)
@@ -364,7 +364,7 @@ void DeformableParticle::prepareNextFrame()
         if(m_node == 0)
             return;
     }
-    uint timeStamp = m_system->systemSync(this);
+    qint64 timeStamp = m_system->systemSync(this);
 
     qreal time = timeStamp / 1000.;
     m_material->timestamp = time;
index d1034a4..0d9b5dd 100644 (file)
@@ -230,7 +230,7 @@ QSGNode* ModelParticle::updatePaintNode(QSGNode* n, UpdatePaintNodeData* d)
 
 void ModelParticle::prepareNextFrame()
 {
-    uint timeStamp = m_system->systemSync(this);
+    qint64 timeStamp = m_system->systemSync(this);
     qreal curT = timeStamp/1000.0;
     qreal dt = curT - m_lastT;
     m_lastT = curT;
index 1cb7d11..571d33c 100644 (file)
@@ -252,7 +252,7 @@ void ParticleSystem::emitParticle(ParticleData* pd)
 
 
 
-uint ParticleSystem::systemSync(ParticleType* p)
+qint64 ParticleSystem::systemSync(ParticleType* p)
 {
     if (!m_running)
         return 0;
index 36ac8ed..896f215 100644 (file)
@@ -43,7 +43,7 @@
 #define PARTICLESYSTEM_H
 
 #include <QSGItem>
-#include <QTime>
+#include <QElapsedTimer>
 #include <QVector>
 #include <QHash>
 #include <QPointer>
@@ -126,13 +126,13 @@ private slots:
 public://but only really for related class usage. Perhaps we should all be friends?
     void emitParticle(ParticleData* p);
     ParticleData* newDatum(int groupId);
-    uint systemSync(ParticleType* p);
-    QTime m_timestamp;
+    qint64 systemSync(ParticleType* p);
+    QElapsedTimer m_timestamp;
     QVector<ParticleData*> m_data;
     QSet<ParticleData*> m_needsReset;
     QHash<QString, int> m_groupIds;
     QHash<int, GroupData*> m_groupData;//id, size, start
-    uint m_timeInt;
+    qint64 m_timeInt;
     bool m_initialized;
 
     void registerParticleType(ParticleType* p);
@@ -151,7 +151,7 @@ private:
     QList<QPointer<ParticleAffector> > m_affectors;
     QList<QPointer<ParticleType> > m_particles;
     QList<QPointer<ParticleType> > m_syncList;
-    int m_startTime;
+    qint64 m_startTime;
     int m_nextGroupId;
     bool m_overwrite;
 };
index dcd8f4a..84f2db0 100644 (file)
@@ -419,7 +419,7 @@ void SpriteParticle::prepareNextFrame()
         if(m_node == 0)
             return;
     }
-    uint timeStamp = m_system->systemSync(this);
+    qint64 timeStamp = m_system->systemSync(this);
 
 
     qreal time =  timeStamp / 1000.;
index ed861f5..f28d198 100644 (file)
@@ -85,7 +85,6 @@ private:
 
     int m_particle_duration;
     int m_last_particle;
-    QTime m_timestamp;
 
     QList<SpriteState*> m_sprites;
     SpriteEngine* m_spriteEngine;