From 0f76dc2cbd29be8463160d1527d714782a9bb6d9 Mon Sep 17 00:00:00 2001 From: Phr00t Date: Sun, 1 Jun 2014 16:46:52 -0400 Subject: [PATCH 1/2] Ability to emit a certain number of particles --- .../java/com/jme3/effect/ParticleEmitter.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/jme3-core/src/main/java/com/jme3/effect/ParticleEmitter.java b/jme3-core/src/main/java/com/jme3/effect/ParticleEmitter.java index f68f574aa..418810bdd 100644 --- a/jme3-core/src/main/java/com/jme3/effect/ParticleEmitter.java +++ b/jme3-core/src/main/java/com/jme3/effect/ParticleEmitter.java @@ -896,6 +896,40 @@ public class ParticleEmitter extends Geometry { vars.release(); } + /** + * Instantly emits available particles, up to num. + */ + public void emitParticles(int num) { + // Force world transform to update + this.getWorldTransform(); + + TempVars vars = TempVars.get(); + + BoundingBox bbox = (BoundingBox) this.getMesh().getBound(); + + Vector3f min = vars.vect1; + Vector3f max = vars.vect2; + + bbox.getMin(min); + bbox.getMax(max); + + if (!Vector3f.isValidVector(min)) { + min.set(Vector3f.POSITIVE_INFINITY); + } + if (!Vector3f.isValidVector(max)) { + max.set(Vector3f.NEGATIVE_INFINITY); + } + + for(int i=0;i Date: Mon, 2 Jun 2014 09:12:39 -0400 Subject: [PATCH 2/2] reduced code duplication --- .../java/com/jme3/effect/ParticleEmitter.java | 27 +------------------ 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/effect/ParticleEmitter.java b/jme3-core/src/main/java/com/jme3/effect/ParticleEmitter.java index 418810bdd..9de88a545 100644 --- a/jme3-core/src/main/java/com/jme3/effect/ParticleEmitter.java +++ b/jme3-core/src/main/java/com/jme3/effect/ParticleEmitter.java @@ -868,32 +868,7 @@ public class ParticleEmitter extends Geometry { * which are currently inactive will be spawned immediately. */ public void emitAllParticles() { - // Force world transform to update - this.getWorldTransform(); - - TempVars vars = TempVars.get(); - - BoundingBox bbox = (BoundingBox) this.getMesh().getBound(); - - Vector3f min = vars.vect1; - Vector3f max = vars.vect2; - - bbox.getMin(min); - bbox.getMax(max); - - if (!Vector3f.isValidVector(min)) { - min.set(Vector3f.POSITIVE_INFINITY); - } - if (!Vector3f.isValidVector(max)) { - max.set(Vector3f.NEGATIVE_INFINITY); - } - - while (emitParticle(min, max) != null); - - bbox.setMinMax(min, max); - this.setBoundRefresh(); - - vars.release(); + emitParticles(particles.length); } /**