Fixed large burst of particles when dramatically increasing the emission rate of a ParticleSystem. (fixes #1169)

This commit is contained in:
Bart van Strien
2016-06-21 15:48:49 +02:00
parent b328049517
commit debea1192b
2 changed files with 4 additions and 3 deletions
+3 -3
View File
@@ -437,6 +437,9 @@ void ParticleSystem::setEmissionRate(float rate)
if (rate < 0.0f)
throw love::Exception("Invalid emission rate");
emissionRate = rate;
// Prevent an explosion when dramatically increasing the rate
emitCounter = std::min(emitCounter, 1.0f/rate);
}
float ParticleSystem::getEmissionRate() const
@@ -932,9 +935,6 @@ void ParticleSystem::update(float dt)
addParticle(1.0f - (emitCounter - rate) / total);
emitCounter -= rate;
}
/*int particles = (int)(emissionRate * dt);
for (int i = 0; i != particles; i++)
add();*/
life -= dt;
if (lifetime != -1 && life < 0)