mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 14:30:08 +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) {
|
void ParticleEffectEntityItem::stepSimulation(float deltaTime) {
|
||||||
// update particles between head and tail
|
// update particles between head and tail
|
||||||
|
int popCount = 0;
|
||||||
for (Particle& particle : _particles) {
|
for (Particle& particle : _particles) {
|
||||||
particle.lifetime += deltaTime;
|
particle.lifetime += deltaTime;
|
||||||
|
|
||||||
// if particle has died.
|
// if particle has died.
|
||||||
if (particle.lifetime >= _lifespan) {
|
if (particle.lifetime >= _lifespan) {
|
||||||
// move head forward
|
// move head forward
|
||||||
_particles.pop_front();
|
popCount++;
|
||||||
} else {
|
} else {
|
||||||
// Otherwise update it
|
// Otherwise update it
|
||||||
integrateParticle(particle, deltaTime);
|
integrateParticle(particle, deltaTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < popCount; i++) {
|
||||||
|
_particles.pop_front();
|
||||||
|
}
|
||||||
|
|
||||||
// emit new particles, but only if we are emmitting
|
// emit new particles, but only if we are emmitting
|
||||||
if (getIsEmitting() && _emitRate > 0.0f && _lifespan > 0.0f && _polarStart <= _polarFinish) {
|
if (getIsEmitting() && _emitRate > 0.0f && _lifespan > 0.0f && _polarStart <= _polarFinish) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue