Minecraft-like terrain (needs optimization)

Hey everyone, I’ve been trying to create minecraft like terrain in JME for a while now and it seems like I can still optimize my code majorly.

Each block has a Node with up to 6 geometries attached (each containing one static final custom mesh and a static final material also), the sides visible are determined by whether a block is adjacent to the face or not.

I then use GeometryBatchFactory.optimize() on the node for that block. (these blocks are only regenerated when a face is changed)

Then after the meshes for all of the blocks are generated I do another GeometryBatchFactory.optimize() on the entire terrain, thus combining all the blocks into one mesh.

The problem with this approach is that when I try to remove a block from the chunk of earth, I have to rebuild the mesh (I tried to optimize it by saving the Mesh of each block within itself and only updating the blocks which need to be, but then I need to clone the node before I GeometryBatchFactory.optimize() or else I lose it anyway).

I’m really lost on how I can make this run faster :confused: if anyone can help I would appreciate it.

Search “voxel” or “bloxel” on the forums. A completely different implementation than blocks and nodes is needed.