mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 10:17:40 +02:00
Merge pull request #4961 from hyperlogic/ajt/particle-net-anim-fix
Particle entities should avoid resetting simulation when setMaxParticles is called
This commit is contained in:
commit
0553f7ca4c
1 changed files with 12 additions and 10 deletions
|
@ -490,19 +490,21 @@ void ParticleEffectEntityItem::stepSimulation(float deltaTime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleEffectEntityItem::setMaxParticles(quint32 maxParticles) {
|
void ParticleEffectEntityItem::setMaxParticles(quint32 maxParticles) {
|
||||||
_maxParticles = maxParticles;
|
if (_maxParticles != maxParticles) {
|
||||||
|
_maxParticles = maxParticles;
|
||||||
|
|
||||||
// TODO: try to do something smart here and preserve the state of existing particles.
|
// TODO: try to do something smart here and preserve the state of existing particles.
|
||||||
|
|
||||||
// resize vectors
|
// resize vectors
|
||||||
_particleLifetimes.resize(_maxParticles);
|
_particleLifetimes.resize(_maxParticles);
|
||||||
_particlePositions.resize(_maxParticles);
|
_particlePositions.resize(_maxParticles);
|
||||||
_particleVelocities.resize(_maxParticles);
|
_particleVelocities.resize(_maxParticles);
|
||||||
|
|
||||||
// effectivly clear all particles and start emitting new ones from scratch.
|
// effectivly clear all particles and start emitting new ones from scratch.
|
||||||
_particleHeadIndex = 0;
|
_particleHeadIndex = 0;
|
||||||
_particleTailIndex = 0;
|
_particleTailIndex = 0;
|
||||||
_timeUntilNextEmit = 0.0f;
|
_timeUntilNextEmit = 0.0f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// because particles are in a ring buffer, this isn't trivial
|
// because particles are in a ring buffer, this isn't trivial
|
||||||
|
|
Loading…
Reference in a new issue