Skip to content

Commit 04f771f

Browse files
richardTinglestephengold
authored andcommitted
Issue 1113. Allow for Particle emitters that constantly have their particlesPerSec set to still emit (#1114)
Previously if particlesPerSec was constantly set timeDifference could never grow large enough to emit a particle as timeDifference was reset to zero each time. This fixes that problem while still ensuring that timeDifference can't have grown very very large (leading to huge numbers of particles being emitted) by capping the timeDifference at the point where its just about to emit a particle. Discussed at https://hub.jmonkeyengine.org/t/particle-emitter-cannot-emit-particles-if-its-emissions-per-second-is-updated-every-frame/41930/2
1 parent f8dae05 commit 04f771f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

jme3-core/src/main/java/com/jme3/effect/ParticleEmitter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ public float getParticlesPerSec() {
783783
*/
784784
public void setParticlesPerSec(float particlesPerSec) {
785785
this.particlesPerSec = particlesPerSec;
786-
timeDifference = 0;
786+
timeDifference = Math.min(timeDifference,1f / particlesPerSec); //prevent large accumulated timeDifference from causing a huge number of particles to be emitted
787787
}
788788

789789
/**

0 commit comments

Comments
 (0)