private void FreeVegetationTile(VegetationTile tile) { if (tile != null) { tile.Dispose(); } }
private void NewCameraPage(PageCoord newPage) { if (enabled && TerrainManager.Instance.CameraSet) { // free the old vegetation tiles VegetationTile[,] newVegetationTiles = new VegetationTile[3, 3]; if (vegetationTiles != null) { foreach (VegetationTile tile in vegetationTiles) { PageCoord pc = tile.pc; int x = pc.X - (newPage.X - 1); int z = pc.Z - (newPage.Z - 1); if ((x >= 0) && (x < 3) && (z >= 0) && (z < 3)) { newVegetationTiles[x, z] = tile; } else { FreeVegetationTile(tile); } } } vegetationTiles = newVegetationTiles; for (int x = 0; x < 3; x++) { for (int z = 0; z < 3; z++) { if (vegetationTiles[x, z] == null) { vegetationTiles[x, z] = new VegetationTile(parentSceneNode, vegetationBoundaries, x, z, newPage, blockSize, roadClearRadius, detailVegImageSet, rand); } } } cameraPage = newPage; } }