public void PrepareForDrawing(Camera camera) { Vector2 xZ = camera.ViewPosition.XZ; float num = MathUtils.Sqr(m_subsystemSky.VisibilityRange); BoundingFrustum viewFrustum = camera.ViewFrustum; int gameWidgetIndex = camera.GameWidget.GameWidgetIndex; m_chunksToDraw.Clear(); TerrainChunk[] allocatedChunks = m_subsystemTerrain.Terrain.AllocatedChunks; foreach (TerrainChunk terrainChunk in allocatedChunks) { if (terrainChunk.NewGeometryData) { lock (terrainChunk.Geometry) { if (terrainChunk.NewGeometryData) { terrainChunk.NewGeometryData = false; SetupTerrainChunkGeometryVertexIndexBuffers(terrainChunk); } } } terrainChunk.DrawDistanceSquared = Vector2.DistanceSquared(xZ, terrainChunk.Center); if (terrainChunk.DrawDistanceSquared <= num) { if (viewFrustum.Intersection(terrainChunk.BoundingBox)) { m_chunksToDraw.Add(terrainChunk); } if (terrainChunk.State != TerrainChunkState.Valid) { continue; } float num2 = terrainChunk.FogEnds[gameWidgetIndex]; if (num2 != float.MaxValue) { if (num2 == 0f) { StartChunkFadeIn(camera, terrainChunk); } else { RunChunkFadeIn(camera, terrainChunk); } } } else { terrainChunk.FogEnds[gameWidgetIndex] = 0f; } } ChunksDrawn = 0; ChunkDrawCalls = 0; ChunkTrianglesDrawn = 0; }