public void FloodEffect(ITerrainChannel map, UUID userID, float north, float west, float south, float east, float strength) { float area = strength; float step = strength / 4; for (int x = (int)west; x < (int)east; x++) { for (int y = (int)south; y < (int)north; y++) { if (!map.Scene.Permissions.CanTerraformLand(userID, new Vector3(x, y, 0))) { continue; } float average = 0; int avgsteps = 0; float n; for (n = 0 - area; n < area; n += step) { float l; for (l = 0 - area; l < area; l += step) { avgsteps++; average += TerrainUtil.GetBilinearInterpolate(x + n, y + l, map); } } map[x, y] = average / avgsteps; } } }
public void PaintEffect(ITerrainChannel map, UUID userID, float rx, float ry, float rz, float strength, float duration, float BrushSize) { int n = (int)(BrushSize + 0.5f); if (BrushSize > 6) //If it gets too high, it will start roughening at an ever increasing rate when held down { BrushSize = 6; } strength = TerrainUtil.MetersToSphericalStrength(BrushSize); float area = BrushSize; float step = BrushSize / 4; duration *= 0.01f; //MCP Should be read from ini file int zx = (int)(rx + 0.5); int zy = (int)(ry + 0.5); float average = 0; int avgsteps = 0; float nn; for (nn = 0 - area; nn < area; nn += step) { float l; for (l = 0 - area; l < area; l += step) { avgsteps++; average += TerrainUtil.GetBilinearInterpolate(rx + nn, ry + l, map); } } int dx; for (dx = -n; dx <= n; dx++) { int dy; for (dy = -n; dy <= n; dy++) { int x = zx + dx; int y = zy + dy; if (x >= 0 && y >= 0 && x < map.Width && y < map.Height) { if (!map.Scene.Permissions.CanTerraformLand(userID, new Vector3(x, y, 0))) { continue; } float z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength) / (strength); if (z > 0) // add in non-zero amount { float avg; if (avgsteps > 0) { avg = average / avgsteps; } else { avg = 0f; } float a = (map [x, y] - avg); float newz = map [x, y] + (a * duration); if (newz > 0.0) { map [x, y] = newz; } } } } } }
public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration, int startX, int endX, int startY, int endY) { strength = TerrainUtil.MetersToSphericalStrength(strength); int x, y; double[,] tweak = new double[map.Width, map.Height]; double area = strength; double step = strength / 4.0; duration = 0.03; //MCP Should be read from ini file // compute delta map for (x = startX; x <= endX; x++) { for (y = startY; y <= endY; y++) { if (!mask[x, y]) { continue; } double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); if (z > 0) // add in non-zero amount { double average = 0.0; int avgsteps = 0; double n; for (n = 0.0 - area; n < area; n += step) { double l; for (l = 0.0 - area; l < area; l += step) { avgsteps++; average += TerrainUtil.GetBilinearInterpolate(x + n, y + l, map); } } tweak[x, y] = average / avgsteps; } } } // blend in map for (x = startX; x <= endX; x++) { for (y = startY; y <= endY; y++) { if (!mask[x, y]) { continue; } double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); if (z > 0) // add in non-zero amount { double da = z; double a = (map[x, y] - tweak[x, y]) * da; double newz = map[x, y] - (a * duration); if (newz > 0.0) { map[x, y] = newz; } } } } }