[SOLVED] Particle Emitter issue (happens intermittently)

[java]Aug 3, 2012 4:44:15 PM com.jme3.app.Application handleError

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

java.nio.BufferOverflowException

at java.nio.Buffer.nextPutIndex(Buffer.java:495)

at java.nio.DirectFloatBufferU.put(DirectFloatBufferU.java:250)

at com.jme3.effect.ParticleTriMesh.updateParticleData(ParticleTriMesh.java:228)

at com.jme3.effect.ParticleEmitter.renderFromControl(ParticleEmitter.java:1083)

at com.jme3.effect.ParticleEmitter.access$000(ParticleEmitter.java:74)

at com.jme3.effect.ParticleEmitter$ParticleEmitterControl.render(ParticleEmitter.java:142)

at com.jme3.scene.Spatial.runControlRender(Spatial.java:560)

at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:784)

at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:794)

at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:794)

at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:794)

at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:794)

at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1117)

at com.jme3.renderer.RenderManager.render(RenderManager.java:1168)

at com.jme3.app.SimpleApplication.update(SimpleApplication.java:254)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:149)

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:182)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:223)

at java.lang.Thread.run(Thread.java:619)

[/java]



I guess it is worth mentioning that I AM changing the particle count now and then (from 0 to 20, from 20 to 0).



Just an FYI

I can’t reproduce this issue. I changed TestMovingParticle so it changes particle count from 0 to 20 on key press and it always worked.

Could you be changing the particle count from outside of the render thread introducing a race condition?

1 Like
@Momoko_Fan said:
I can't reproduce this issue. I changed TestMovingParticle so it changes particle count from 0 to 20 on key press and it always worked.


It's an odd one. I can go for hours without it happening. But, eventually, it does. I wish there was a way for me to narrow it down a little more.

@zarch said:
Could you be changing the particle count from outside of the render thread introducing a race condition?


All emitters are handled by controls in my game. I suppose I could flag the change and ensure that the call to update the emitter is made during the update loop of the control. I assumed that the emitter would do this automatically... probably a bad assumption on my part.

I'll give it a go and post back once I know for sure that it is/isn't happening anymore.

I looked over the code a couple of times. setNumParticles() always results in two things: particle array is resized to proper number of particles, and for ParticleTriMesh, the internal buffers of the mesh are resized to proper number of particles and always start at position zero because new buffers are created on resize.

This means the bug you mentioned cannot happen unless the resize occurs from another thread, it can only happen if the particle array is suddenly larger than the mesh buffers which given the current design, cannot happen normally.

1 Like
@Momoko_Fan said:
I looked over the code a couple of times. setNumParticles() always results in two things: particle array is resized to proper number of particles, and for ParticleTriMesh, the internal buffers of the mesh are resized to proper number of particles and always start at position zero because new buffers are created on resize.
This means the bug you mentioned cannot happen unless the resize occurs from another thread, it can only happen if the particle array is suddenly larger than the mesh buffers which given the current design, cannot happen normally.


Awesome... then this should fix the issue. I'm actually surprised I wasn't seeing this more often, being that this is what is happening.
@t0neg0d said:
Awesome... then this should fix the issue. I'm actually surprised I wasn't seeing this more often, being that this is what is happening.

So ... what was the problem exactly?