//method for saving changes to terrain at runtime public void SaveTerrains() { Debug.Log("saved Terrain"); for (int i = 0; i < ActiveChunks.Count; i++) { VoxelChunk chunk = ActiveChunks[i]; if (chunk.HasChanged && chunk.shouldrender) { chunk.SaveVoxels(); } } }
void checkActiveChunks() { if (ActiveChunks.Count > 0) { for (int i = 0; i < ActiveChunks.Count; i++) { VoxelChunk chunk = ActiveChunks[i]; Vector2 chunkpos = new Vector2(chunk.m_pos.x, chunk.m_pos.z) / TriSize[minLod]; Vector2 playerpos = Vector2.zero; if (Vector2.Distance(chunkpos, playerpos) >= distanceToLoad + 25) { if (chunk.HasChanged && chunk.shouldrender) { chunk.SaveVoxels(); } Trash.Enqueue(chunk); m_voxelChunk.Remove(chunk.RealPos * minLod, new Vector3(m_voxelWidthLength, m_voxelHeight, m_voxelWidthLength)); ActiveChunks.Remove(chunk); return; } } } }