When spliting the simulation into multiple parts, do not simulate for
times before the particle was born. Otherwise huge simulation times lead
to huge effects even on particles with a simulated birth of near the end
of that time.
Change-Id: I7ff507b27bf819dbebd61934b9523b23316b5e80
Reviewed-by: Martin Jones <martin.jones@nokia.com>
m_system->timeInt -= myDt * 1000.0;
while (myDt > simulationDelta) {
m_system->timeInt += simulationDelta * 1000.0;
- affected = affectParticle(d, simulationDelta) || affected;
+ if (d->alive())//Only affect during the parts it was alive for
+ affected = affectParticle(d, simulationDelta) || affected;
myDt -= simulationDelta;
}
m_system->timeInt = realTime;
return (t + lifeSpan - EPSILON) > ((qreal)system->timeInt/1000.0);
}
+bool QQuickParticleData::alive()
+{
+ if (!system)
+ return false;
+ qreal st = ((qreal)system->timeInt/1000.0);
+ return (t + EPSILON) < st && (t + lifeSpan - EPSILON) > st;
+}
+
float QQuickParticleData::curSize()
{
if (!system || !lifeSpan)
QQuickImageParticle* animationOwner;
void debugDump();
- bool stillAlive();
+ bool stillAlive();//Only checks end, because usually that's all you need and it's a little faster.
+ bool alive();
float lifeLeft();
float curSize();
void clone(const QQuickParticleData& other);//Not =, leaves meta-data like index