/// <summary> /// We don't actually generate the mesh, that needs to happen on the main /// Unity thread. But we CAN go ahead and generate the mesh DATA, based on block visiblity. /// </summary> /// <param name="chunk"></param> private void GenerateChunkMeshData(Chunk chunk) { //DateTime start = DateTime.Now; int index = 0; chunk.Vertices = new List <Vector3>(); chunk.Indices = new List <int>(); chunk.Uvs = new List <Vector2>(); chunk.Colors = new List <Color>(); for (int x = 0; x < m_WorldData.ChunkBlockWidth; x++) { int blockX = chunk.X * m_WorldData.ChunkBlockWidth + x; for (int y = 0; y < m_WorldData.ChunkBlockHeight; y++) { int blockY = y + chunk.Y * m_WorldData.ChunkBlockHeight; for (int z = 1; z < m_WorldData.ChunkBlockDepth - 1; z++) { int blockZ = z + chunk.Z * m_WorldData.ChunkBlockDepth; index = CreateDataMeshForBlock(blockX, blockY, blockZ, chunk, x, y, z, index); } } } m_WorldData.AddFinishedChunk(chunk); //Debug.Log("Mesh Data generation took " + (DateTime.Now - start)); }