aboutsummaryrefslogtreecommitdiffstats
path: root/src/particles/qquickparticlesystem_p.h
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@theqtcompany.com>2016-03-01 12:39:09 +0100
committerErik Verbruggen <erik.verbruggen@theqtcompany.com>2016-03-04 10:43:23 +0000
commit554566788f585caaef14d929cee6557ad929e06e (patch)
treea1d571e23933a9f66ed49a789a932a666dc0ed89 /src/particles/qquickparticlesystem_p.h
parent62ecfe55f414d0d04a4344bc6934b4b01408190f (diff)
Particles: inline 4 methods.
And when in the area, remove 3 unused functions. Benchmark: start samegame, click '1 player', quit. Valgrind result: removes/inlines ~90,000 calls. Change-Id: If911b19b46bf163f7fe678623c068f960296f17e Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com> Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Diffstat (limited to 'src/particles/qquickparticlesystem_p.h')
-rw-r--r--src/particles/qquickparticlesystem_p.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/particles/qquickparticlesystem_p.h b/src/particles/qquickparticlesystem_p.h
index 7805f87094..9ddbb2ff38 100644
--- a/src/particles/qquickparticlesystem_p.h
+++ b/src/particles/qquickparticlesystem_p.h
@@ -114,7 +114,9 @@ public:
QQuickParticleGroupData(const QString &name, QQuickParticleSystem* sys);
~QQuickParticleGroupData();
- int size();
+ int size()
+ { return m_size; }
+
QString name();
void setSize(int newSize);
@@ -248,6 +250,9 @@ public:
void clone(const QQuickParticleData& other);//Not =, leaves meta-data like index
QQmlV4Handle v4Value();
void extendLife(float time);
+
+ static inline Q_DECL_CONSTEXPR qreal EPSILON() Q_DECL_NOTHROW { return 0.001; }
+
private:
QQuickV4ParticleData* v8Datum;
};
@@ -396,6 +401,20 @@ private:
QQuickParticleSystem* m_system;
};
+inline bool QQuickParticleData::stillAlive()
+{
+ if (!system)
+ return false;
+ return (t + lifeSpan - EPSILON()) > ((qreal)system->timeInt/1000.0);
+}
+
+inline bool QQuickParticleData::alive()
+{
+ if (!system)
+ return false;
+ qreal st = ((qreal)system->timeInt/1000.0);
+ return (t + EPSILON()) < st && (t + lifeSpan - EPSILON()) > st;
+}
QT_END_NAMESPACE