예제 #1
0
 // Get new meshes from the mesher
 void FetchNewMeshes()
 {
     while (mesher.HasNewMeshes)
     {
         var newMeshes = mesher.Dequeue().Value;
         int block_x   = newMeshes.location.x / blockSize;
         int block_y   = newMeshes.location.y / blockSize;
         int block_z   = newMeshes.location.z;
         if (newMeshes.tiles != null)
         {
             if (blocks[block_x, block_y, block_z] == null)
             {
                 blocks[block_x, block_y, block_z] = new Mesh();
             }
             Mesh tileMesh = blocks[block_x, block_y, block_z];
             tileMesh.Clear();
             newMeshes.tiles.CopyToMesh(tileMesh);
         }
         if (newMeshes.stencilTiles != null)
         {
             if (stencilBlocks[block_x, block_y, block_z] == null)
             {
                 stencilBlocks[block_x, block_y, block_z] = new Mesh();
             }
             Mesh stencilMesh = stencilBlocks[block_x, block_y, block_z];
             stencilMesh.Clear();
             newMeshes.stencilTiles.CopyToMesh(stencilMesh);
         }
         if (newMeshes.water != null)
         {
             if (liquidBlocks[block_x, block_y, block_z, MapDataStore.WATER_INDEX] == null)
             {
                 liquidBlocks[block_x, block_y, block_z, MapDataStore.WATER_INDEX] = new Mesh();
             }
             Mesh waterMesh = liquidBlocks[block_x, block_y, block_z, MapDataStore.WATER_INDEX];
             waterMesh.Clear();
             newMeshes.water.CopyToMesh(waterMesh);
         }
         if (newMeshes.magma != null)
         {
             if (liquidBlocks[block_x, block_y, block_z, MapDataStore.MAGMA_INDEX] == null)
             {
                 liquidBlocks[block_x, block_y, block_z, MapDataStore.MAGMA_INDEX] = new Mesh();
             }
             Mesh magmaMesh = liquidBlocks[block_x, block_y, block_z, MapDataStore.MAGMA_INDEX];
             magmaMesh.Clear();
             newMeshes.magma.CopyToMesh(magmaMesh);
         }
     }
 }