Potential bug in Mesh.updateCounts()

I have a buffer with capacity 3000.

i fill the first 300 elements, so the new limit becomes 300.

limit: 3000 becomes 300

i call Mesh.updateCounts()

vertex count : 3000 becomes 3000

[java]if (pb != null){

vertCount = pb.getData().capacity() / pb.getNumComponents();


Should become :

[java]if (pb != null){

vertCount = pb.getData().limit() / pb.getNumComponents();


This bug makes jme read after buffer limit which is illegal

Screenshot of jme reading beyond limit();



To see if this bug is really a jme bug i do the following, ( i hack jme to allow me to run my code with reflection).


VertexBuffer pb = mesh.getBuffer(VertexBuffer.Type.Position);



Field field = mesh.getClass().getDeclaredField(“vertCount”);


field.set(mesh, pb.getData().limit() / pb.getNumComponents());


catch (Exception e)





Result :

limit: 3000 becomes 300

vertex count : 3000 becomes 300

Outcome :


Unsure if I should ask how long it took you to find the problem… :wink: Must have been a great hunt. lol

Good catch there.

I spend 2 days searching my code, testing if i somehow forgot to call a method, or if it was my bug.

today i inspected every jme method that i used, to see if something strange is happening under the hood.