Hello
I had a simple VoxelWorld. I build it like in this tutorial http://alexstv.com/index.php/category/voxels .
In short: I create a Mesh for one Chunk, based on the Blockdata in the Chunk. The Chunk is 32x1x32. I need the possibility to hide every Blocklayer in the y Axsis (thats why the Chunk has only y = 1). On every Frame i call Graphics.drawMesh() from MinY to the Blocklayer i want to see. Because of this i dont need GameObjects for the Rendering Meshes.
For the Physics i need to create one Gameobject for every Chunk with a Mesh-Collider.
The biggest Problem ocours when i want to set a new Block. If i am setting a new Block i have to recalculate the hole Chunk.(and the Chunk over and the Chunk topsy the Manipulated Block). If I set a one Block in the World this is not a problem. But if i am setting 20 Blocks (in different Chunks) i need to calculate 20*3 = 60 Chunks (Maybe more if the Block is at the X or Z edge of the Chunk)
- How i can manipulate the Mesh of the Chunk with the new Block without creating it from the scratch?
My idea was to Manipulate the Mesh.vertices directly. Or to do the Calculation of the Mesh in a thread. But the Code to assign the Manipulated Mesh have to run in Main Thread.
mesh.vertices = ManipulatedVertices; (and this will copy the hole array)
For The Physics i have to do the same but assigning a new Mesh to a MeshCollider is a very slow operation.
Maybe i could creating a simple Physics Script that dont allow other Objects to move to near to a Voxel.
Maybe I could use another system for the hole thing?