public static void CreateWorldMesh(int width, int height, int chunkWidth, int chunkHeight) { mapWidth = width; mapHeight = height; WorldMesh.chunkWidth = chunkWidth; WorldMesh.chunkHeight = chunkHeight; chunkXCount = width / chunkWidth; chunkYCount = height / chunkHeight; minVertHeight = float.MaxValue; maxVertHeight = float.MinValue; Log.InfoSet("Mesh map size"); SetEmptyVerticesMap(); SetEmptyColorMap(); SetEmptyOriantationMap(); chunkMeshMap = new ChunkMesh[chunkXCount, chunkYCount]; for (int x = 0; x < chunkXCount; x++) { for (int y = 0; y < chunkYCount; y++) { chunkMeshMap[x, y] = new ChunkMesh(chunkWidth, chunkHeight, x, y); } } Log.InfoSet("Chunk mesh map"); }
public Chunk(ChunkObject terrain, Transform parent, bool visible, ChunkMesh meshData) { this.meshData = meshData; CreateChunkObject(terrain, parent); DrawMesh(); UpdateMeshCollider(); SetVisible(visible); meshData.ConnectChunk(this); }
public static void SetEditedPosition(int x, int y) { Vector2Int pos = VertexPosToQuadPos(new Vector2Int(x, y)); ChunkMesh chunkMesh = GetChunkMesh(pos.x, pos.y);; if (!editedChunks.ContainsKey(chunkMesh)) { editedChunks[chunkMesh] = new List <Vector2Int>(); } editedChunks[chunkMesh].Add(new Vector2Int(x % chunkWidth, y % chunkHeight)); }