So I got an odd (maybe) problem on my hands. I have a bunch of geometries attached to a batch node which is .batch()ed when they’re all added.
Then later on I’d like to modify the mesh vertex data buffer (and keep the number of vertices the same, just change the positions) like so:
Mesh m = ((Geometry)s).getMesh();
m.setBuffer(Type.Position, 3, new float[]{0,0,0, fin.x,fin.y,fin.z,});
m.updateBound();
But then for some reason the BatchNode decides that things are getting weird and triggers an overflow.
Oct 17, 2016 8:18:29 PM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.nio.BufferOverflowException
at java.nio.DirectFloatBufferU.put(Unknown Source)
at com.jme3.scene.BatchNode.doTransforms(BatchNode.java:637)
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.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.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(Unknown Source)
Which points to the marked line (from 3.0 source):
vars.release();
bufPos.position(offset);
bufPos.put(tmpFloat, 0, length); //<-- this one
bufNorm.position(offset);
bufNorm.put(tmpFloatN, 0, length);
I’m not sure how the BatchNode works so I’m kind of clueless on how to fix it. @nehon I see you’re the author, got any ideas?