BatchNode: How to update changed scenes correctly?

@normen

Thank you for the info, I changed the code and and I’ll keep it in mind.
However, this wasn’t the cause of the problem as well.

I think I might have an idea. Do you remember this post from page 1?

I explained that there might be an issue with unBatch() not being called for the geometries which are not removed from the BatchNode directly, but rather removed from a chlid of the BatchNode.

This could be an issue, since I remove Geometry from the BatchNode and reattach it later. The geometry therefore thinks it’s already batched even tough it isn’t.

If you take another look at the exception…
[java]
java.lang.IndexOutOfBoundsException
at java.nio.Buffer.checkBounds(Buffer.java:559)
at java.nio.DirectFloatBufferU.get(DirectFloatBufferU.java:259)
at com.jme3.scene.BatchNode.doTransforms(BatchNode.java:611)
at com.jme3.scene.BatchNode.updateSubBatch(BatchNode.java:172)
at com.jme3.scene.Geometry.updateWorldTransforms(Geometry.java:286)
at com.jme3.scene.Spatial.updateGeometricState(Spatial.java:713)
at com.jme3.scene.Node.updateGeometricState(Node.java:175)
at com.jme3.scene.Node.updateGeometricState(Node.java:175)
at com.jme3.scene.Node.updateGeometricState(Node.java:175)
at com.jme3.scene.BatchNode.updateGeometricState(BatchNode.java:120)
at com.jme3.scene.Node.updateGeometricState(Node.java:175)
at com.jme3.scene.Node.updateGeometricState(Node.java:175)
at com.jme3.scene.Node.updateGeometricState(Node.java:175)
at com.jme3.scene.Node.updateGeometricState(Node.java:175)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:247)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
at java.lang.Thread.run(Thread.java:744)
[/java]
you can see that updateWorldTransforms() is called on a Geometry object. The Geometry thinks it’s batched and calls batchNode.updateSubBatch(this).
This could lead to the exception.

Opinions?