public Vertex GetLowestRegionCenter(int radius, int offset) { double lowestSum = 100; Vertex lowestRegionCenter = new Vertex(offset, offset, 10); for (int x = offset; x < terrainSize - offset; x += radius) { for (int z = offset; z < terrainSize - offset; z += radius) { double sum = 0; for (int i = x - radius; i < x + radius; i++) { for (int j = z - radius; j < z + radius; j++) { if (CheckBounds(i, j)) sum += vertices[i, j].y; else sum += 1; } } if (sum < lowestSum) { lowestSum = sum; lowestRegionCenter.Rewrite(x, z, vertices[x, z].y); } } } return lowestRegionCenter; }
public Vertex GetLowestPointInArea(int _x, int _z, int area) { Vertex lowestVert = new Vertex(_x, _z, vertices[_x, _z].y); for (int x = _x - area; x <= _x + area; x++) { for (int z = _z - area; z <= _z + area; z++) { if (CheckBounds(x, z) && vertices[x, z].y < lowestVert.height) { lowestVert.Rewrite(x, z, vertices[x, z].y); } } } return lowestVert; }