Hi,
While in the process of trying to create a dynamic mesh, one that grows the number of mesh vertices, I have run into a problem with the underlying buffers.
When I use ‘ensureLargeEnough’ to expand the buffer the original content of the buffer is lost
I think this is probably a problem of the underlying direct ShortBuffer, the line in ensureLargeEnough newVerts.put(buffer);
is not doing anything.
Can someone please give me a sanity check that this is happening?
The test case is:
package tsb;
import java.nio.ShortBuffer;
import com.jme3.util.BufferUtils;
public class TestShortBuffer
{
public static void main(String[] args)
{
short[] asi = {1, 1, 2, 3, 5, 8, 13};
ShortBuffer buffer = BufferUtils.createShortBuffer(asi);
buffer = BufferUtils.ensureLargeEnough(buffer, asi.length+3);
buffer.position(asi.length);
buffer.put((short)21);
buffer.put((short)34);
buffer.put((short)55);
for (int iIndex = 0; iIndex<asi.length; ++iIndex)
{
if (asi[iIndex]==buffer.get(iIndex)) continue;
System.out.println(String.format("buffer content different %d %d", asi[iIndex], buffer.get(iIndex)));
return;
}
System.out.println("buffer content same");
return;
}
}
The system output is “buffer content different 1 0”
Thanks for the help
Martin