ParticleMesh BoundingVolume hang


noob here so this issue may of been encountered before but i looked in the archives and couldn't find it so my apologies if it's a known problem…

i may be omitting a step in the ParticleMesh initialisation code but nonetheless, when i create more than one particle mesh and assign a bounding sphere as model bounds to the mesh it causes a hang…

on stepping through the code i found that it was hanging in the new particle mesh's updateGeometricState method…

once i removed the bounding volume assignment it worked fine…

should there even be bounds for a particle mesh, honest noob question???

here's the code, press i to generate the explosion;

import com.jme.bounding.BoundingSphere;
import com.jme.image.Texture;
import com.jme.input.KeyBindingManager;
import com.jme.input.KeyInput;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.Controller;
import com.jme.scene.state.AlphaState;
import com.jme.scene.state.TextureState;
import com.jme.scene.state.ZBufferState;
import com.jme.util.TextureManager;
import com.jmex.effects.particles.ParticleControllerListener;
import com.jmex.effects.particles.ParticleFactory;
import com.jmex.effects.particles.ParticleGeometry;
import com.jmex.effects.particles.ParticleMesh;

public class SimpleParticlesTesterAsGame extends SimpleGame implements ParticleControllerListener
   public   Texture            mcl_explosionTexture;
   int      mi_cnt = 0;
   protected void simpleUpdate()

   public    SimpleParticlesTesterAsGame()
   public   void processMyInput()
      if(KeyBindingManager.getKeyBindingManager().isValidCommand("startParticles", false))
         ParticleMesh   lcl_pM = buildParticles();
         lcl_pM.setOriginOffset(new Vector3f(mi_cnt * 10f, 0, 0));

   protected void    simpleInitGame()
      KeyBindingManager.getKeyBindingManager().set("startParticles", KeyInput.KEY_I);
   public   void initExplostionTexture()
      mcl_explosionTexture = TextureManager.loadTexture("misc/test/flaresmall.jpg", Texture.MM_LINEAR_LINEAR, Texture.FM_LINEAR);
   public   AlphaState buildAlphaState()
      AlphaState      lcl_as = display.getRenderer().createAlphaState();
      return lcl_as;
   public   TextureState buildTextureState()
      TextureState   lcl_ts = display.getRenderer().createTextureState();
      return lcl_ts;
   public   ZBufferState buildZBufferState()
      ZBufferState      lcl_zs = display.getRenderer().createZBufferState();
      return lcl_zs;
   public   ParticleMesh buildParticles()
      // init particle mesh
      ParticleMesh   lcl_pMesh = ParticleFactory.buildParticles("bang" + mi_cnt, 100);
      lcl_pMesh.setEmissionDirection(new Vector3f(0,1,0));
       lcl_pMesh.setStartColor(new ColorRGBA(1, 0, 0, 1));
       lcl_pMesh.setEndColor(new ColorRGBA(1, 1, 0, 0));
       lcl_pMesh.setModelBound(new BoundingSphere());

       return lcl_pMesh;

   public static void main(String[] args)
      SimpleParticlesTesterAsGame         lcl_main = new SimpleParticlesTesterAsGame();

   public void onDead(ParticleGeometry cl_geom)


this was run on java version 1.5.0_07-87 using jme checked out on 9 march 07 on an 1GHz emac (don't laugh) with 768 MB ram running mac os x 1.4.8....
You wouldn't happen to have some code to test this with, would you?

Sorry, I was in a hurry when I wrote that..  I plead sleepiness.  :oops:

Anyhow, I've looked more into this and it turns out to be a bug with BoundingSphere.  I'm working on a fix.  In the meantime, use BoundingBox.

You should be able to use bounding volumes with particles without issue.  If not, it's a bug.  Maybe it's doing bounds generation with all 0s in the vert buffer or something.  Can't think of a good reason it would hang though (nor have I seen this before.)

on going through this a bit more indepth the problem is with the update particle model bounds in the ParticleController class update method…

the hang occurs at

// If we have a bound and any live particles, update it
            if (particles.getBatch(0).getModelBound() != null && anyAlive) {

i traced it with system outs and i got this

rootNode : update geometric state
rootNode : update world data call
bang0 : update geometric state
bang0 : update world data call
bang0 : controller update call
updateRotMat ok!
while (i < particles.getNumParticles()) ok!
listeners handle ok!
world bounds process ok!
bang0 : controller update ok
bang0 : update world data call OK!!!
bang0 : update world bound call
bang0 : update world bound call OK!!!
bang1 : update geometric state
bang1 : update world data call
bang1 : controller update call
updateRotMat ok!
while (i < particles.getNumParticles()) ok!
listeners handle ok!
HANG!!! here

obviously the world bounds update for the particles is hanging....
don't know enough to go messing with the particles....
hope that helps....

Thanks for the data.  You wouldn't happen to have some code to test this with, would you?  You can just send it to my email <---- if you do.

i sent you a mail with the code…did you get it?

Yep, then I came back to the thread and saw it was in your first post…  Thus the oops.

I've tracked down a bug in BoundingSphere calcs and fixed it.  I've also fixed an issue with Particles where the bounding volume always included the origin at first.  That said, the  fix only works (and really only can work) if you warmup the particle system after attaching the particle system to your scenegraph.

These things will be in cvs sometime soon.


thanks for the help…

That's cool, I've also been having odd stuff with particle bounds, I'll give this a go. If you remember, way back in the mists of time I had a similar issue, which I thought had been fixed by that patch to change the particle controller slightly (I can't remember how :wink: ).

[Edit] Actually, I was just looking at my code, and I don't warm up before attaching the particles, but since warmUp just calls update(0.1) repeatedly, I assume that the important thing is not to call warmUp OR update before attaching to a scenegraph? Are there any other methods that shouldn't be called, like forceRespawn etc.? At the moment I get really odd bounds on particles, which seem far too large, so I want to make sure that I get the effect of the fix :slight_smile:

Well, you won't get any affect from the fix until it gets from the codeshare at work to jme's cvs :P    But yeah, I'd probably attach it, warm it up, then set my model bound and update the bound.