For my Voxel like game I need to generate terrain meshes from an array of ids. Because of that I have no idea how big the final vertex array will be.
Currently I'm doing like this: generate mesh and save to arrayList, then in a few lines of code I convert the arrayList to a primitive array. This is working fine, but it's just really SLOW.
So now my question is is there a way I can use a primitive array, without knowing it's final size? If not is there a fast way I can take an array with a lot of empty elements, and then shrink it?
Edit: Heres how I convert it:
List <Float> vertices = new ArrayList <Float> (); //Generating mesh float doneVertices = new float[vertices.size()]; for(int i = 0; i < vertices.size(); i++) doneVertices[i] = vertices.get(i);