mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-08 14:42:09 +02:00
ParticleEffectEntityItem: fix for invalid iterator increment
Was causing an assert in debug, due to calling ++ on an invalid iterator. In release this might lead to memory corruption.
This commit is contained in:
parent
29516619ee
commit
1b08563079
1 changed files with 6 additions and 1 deletions
|
@ -595,19 +595,24 @@ void ParticleEffectEntityItem::integrateParticle(Particle& particle, float delta
|
|||
|
||||
void ParticleEffectEntityItem::stepSimulation(float deltaTime) {
|
||||
// update particles between head and tail
|
||||
int popCount = 0;
|
||||
for (Particle& particle : _particles) {
|
||||
particle.lifetime += deltaTime;
|
||||
|
||||
// if particle has died.
|
||||
if (particle.lifetime >= _lifespan) {
|
||||
// move head forward
|
||||
_particles.pop_front();
|
||||
popCount++;
|
||||
} else {
|
||||
// Otherwise update it
|
||||
integrateParticle(particle, deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < popCount; i++) {
|
||||
_particles.pop_front();
|
||||
}
|
||||
|
||||
// emit new particles, but only if we are emmitting
|
||||
if (getIsEmitting() && _emitRate > 0.0f && _lifespan > 0.0f && _polarStart <= _polarFinish) {
|
||||
|
||||
|
|
Loading…
Reference in a new issue