private void Weather(int width, int height, float T, Vector2[] neighbs, float[,] buffer) { for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { buffer[x, y] = Overworld.Map[x, y].Height * Overworld.Map[x, y].Faults; } } int weatheringIters = 10; for (int iter = 0; iter < weatheringIters; iter++) { for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { Vector2 p = new Vector2(x, y); Vector2 maxDiffNeigh = Vector2.Zero; float maxDiff = 0; float totalDiff = 0; float h = Overworld.GetHeight(buffer, p); float lowestNeighbor = 0.0f; for (int i = 0; i < 4; i++) { float nh = Overworld.GetHeight(buffer, p + neighbs[i]); float diff = h - nh; totalDiff += diff; if (diff > maxDiff) { maxDiffNeigh = neighbs[i]; maxDiff = diff; lowestNeighbor = nh; } } if (maxDiff > T) { Overworld.AddValue(Overworld.Map, p + maxDiffNeigh, Overworld.ScalarFieldType.Weathering, (float)(maxDiff * 0.4f)); Overworld.AddValue(Overworld.Map, p, Overworld.ScalarFieldType.Weathering, (float)(-maxDiff * 0.4f)); } } } for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { Vector2 p = new Vector2(x, y); float w = Overworld.GetValue(Overworld.Map, p, Overworld.ScalarFieldType.Weathering); Overworld.AddHeight(buffer, p, w); Overworld.Map[x, y].Weathering = 0.0f; } } } for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { Overworld.Map[x, y].Weathering = buffer[x, y] - Overworld.Map[x, y].Height * Overworld.Map[x, y].Faults; } } }