private void LoadChunkAt(float x, float y) { int grid_x, grid_y; GetGridStartAt(x, y, out grid_x, out grid_y); if (chunks.IsSet(grid_x, grid_y)) { return; } EvictIfNeeded(); TriangleCollection tc = new TriangleCollection(this.logger); float min_x, max_x, min_y, max_y; GetGridLimits(grid_x, grid_y, out min_x, out min_y, out max_x, out max_y); Console.WriteLine("Got asked for triangles at " + x + ", " + y); Console.WriteLine("Need triangles grid (" + min_x + " , " + min_y + ") - (" + max_x + ", " + max_y); tc.SetLimits(min_x - 1, min_y - 1, -1E30f, max_x + 1, max_y + 1, 1E30f); foreach (TriangleSupplier s in suppliers) { s.GetTriangles(tc, min_x, min_y, max_x, max_y); } tc.CompactVertices(); tc.ClearVertexMatrix(); // not needed anymore tc.base_x = grid_x; tc.base_y = grid_y; Console.WriteLine(" it got " + tc.GetNumberOfTriangles() + " triangles and " + tc.GetNumberOfVertices() + " vertices"); loadedChunks.Add(tc); NotifyChunkAdded?.Invoke(new ChunkAddedEventArgs(tc)); System.Threading.Thread.Sleep(1000); chunks.Set(grid_x, grid_y, tc); Console.WriteLine("Got triangles grid (" + tc.min_x + " , " + tc.min_y + ") - (" + tc.max_x + ", " + tc.max_y); m_Updated = true; }
private void LoadChunkAt(float x, float y) { int grid_x, grid_y; GetGridStartAt(x, y, out grid_x, out grid_y); if (chunks.IsSet(grid_x, grid_y)) { return; } EvictIfNeeded(); var tc = new TriangleCollection(); float min_x, max_x, min_y, max_y; GetGridLimits(grid_x, grid_y, out min_x, out min_y, out max_x, out max_y); PathGraph.Log("Got asked for triangles at " + x + ", " + y); PathGraph.Log("Need triangles grid (" + min_x + " , " + min_y + ") - (" + max_x + ", " + max_y); tc.SetLimits(min_x - 1, min_y - 1, -1E30f, max_x + 1, max_y + 1, 1E30f); foreach (TriangleSupplier s in suppliers) { s.GetTriangles(tc, min_x, min_y, max_x, max_y); } tc.CompactVertices(); tc.ClearVertexMatrix(); // not needed anymore tc.base_x = grid_x; tc.base_y = grid_y; PathGraph.Log(" it got " + tc.GetNumberOfTriangles() + " triangles and " + tc.GetNumberOfVertices() + " vertices"); loadedChunks.Add(tc); chunks.Set(grid_x, grid_y, tc); PathGraph.Log("Got triangles grid (" + tc.min_x + " , " + tc.min_y + ") - (" + tc.max_x + ", " + tc.max_y); }