From 48d86fb23f7ae0e7919274d67fc25f590e6845b1 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 7 Oct 2008 14:49:12 +0000 Subject: * Apply http://opensimulator.org/mantis/view.php?id=1207 * Implmements llModifyLand() and a check for the "Allow others to terraform flag" * Thanks tglion! --- .../World/Terrain/PaintBrushes/ErodeSphere.cs | 24 ++++++++----- .../World/Terrain/PaintBrushes/FlattenSphere.cs | 41 +++++++++------------- .../World/Terrain/PaintBrushes/LowerSphere.cs | 11 ++---- .../World/Terrain/PaintBrushes/NoiseSphere.cs | 11 ++---- .../World/Terrain/PaintBrushes/OlsenSphere.cs | 7 ++-- .../World/Terrain/PaintBrushes/RaiseSphere.cs | 11 ++---- .../World/Terrain/PaintBrushes/RevertSphere.cs | 9 ++--- .../World/Terrain/PaintBrushes/SmoothSphere.cs | 5 ++- .../World/Terrain/PaintBrushes/WeatherSphere.cs | 7 ++-- 9 files changed, 56 insertions(+), 70 deletions(-) (limited to 'OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes') diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/ErodeSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/ErodeSphere.cs index dae4cf8..3fa3f8a 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/ErodeSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/ErodeSphere.cs @@ -150,7 +150,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes #region ITerrainPaintableEffect Members - public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) + public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) { strength = TerrainUtil.MetersToSphericalStrength(strength); @@ -173,10 +173,13 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes { for (y = 0; y < water.Height; y++) { - const double solConst = (1.0 / rounds); - double sedDelta = water[x, y] * solConst; - map[x, y] -= sedDelta; - sediment[x, y] += sedDelta; + if (mask[x,y]) + { + const double solConst = (1.0 / rounds); + double sedDelta = water[x, y] * solConst; + map[x, y] -= sedDelta; + sediment[x, y] += sedDelta; + } } } @@ -292,8 +295,11 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes double sedimentDeposit = sediment[x, y] - waterCapacity; if (sedimentDeposit > 0) { - sediment[x, y] -= sedimentDeposit; - map[x, y] += sedimentDeposit; + if (mask[x,y]) + { + sediment[x, y] -= sedimentDeposit; + map[x, y] += sedimentDeposit; + } } } } @@ -302,10 +308,10 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes // Deposit any remainder (should be minimal) for (x = 0; x < water.Width; x++) for (y = 0; y < water.Height; y++) - if (sediment[x, y] > 0) + if (mask[x,y] && sediment[x, y] > 0) map[x, y] += sediment[x, y]; } #endregion } -} \ No newline at end of file +} diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs index 1e2d611..e507481 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs @@ -25,48 +25,29 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; using OpenSim.Region.Environment.Interfaces; namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes { public class FlattenSphere : ITerrainPaintableEffect { - #region ITerrainPaintableEffect Members - public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) + public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) { strength = TerrainUtil.MetersToSphericalStrength(strength); int x, y; - double sum = 0.0; - double step2 = 0.0; - duration = 0.009; //MCP Should be read from ini file - - - // compute delta map - for (x = 0; x < map.Width; x++) - { - for (y = 0; y < map.Height; y++) - { - double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); - - if (z > 0) // add in non-zero amount - { - sum += map[x, y] * z; - step2 += z; - } - } - } - - double avg = sum / step2; - // blend in map for (x = 0; x < map.Width; x++) { for (y = 0; y < map.Height; y++) { + if (!mask[x,y]) + continue; + double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength) * duration; if (z > 0) // add in non-zero amount @@ -74,8 +55,18 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes if (z > 1.0) z = 1.0; - map[x, y] = (map[x, y] * (1.0 - z)) + (avg * z); + map[x, y] = (map[x, y] * (1.0 - z)) + (rz * z); } + + double delta = rz - map[x, y]; + if (Math.Abs(delta) > 0.1) + delta *= 0.25; + + if (delta != 0) // add in non-zero amount + { + map[x, y] += delta; + } + } } } diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs index 08b2879..fe82396 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs @@ -34,7 +34,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes { #region ITerrainPaintableEffect Members - public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) + public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) { strength = TerrainUtil.MetersToSphericalStrength(strength); duration = 0.03; //MCP Should be read from ini file @@ -42,15 +42,10 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes int x; for (x = 0; x < map.Width; x++) { - // Skip everything unlikely to be affected - if (Math.Abs(x - rx) > strength * 1.1) - continue; - int y; for (y = 0; y < map.Height; y++) { - // Skip everything unlikely to be affected - if (Math.Abs(y - ry) > strength * 1.1) + if (!mask[x,y]) continue; // Calculate a sphere and add it to the heighmap @@ -66,4 +61,4 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes #endregion } -} \ No newline at end of file +} diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs index 0824efd..23f7bc5 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs @@ -35,22 +35,17 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes { #region ITerrainPaintableEffect Members - public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) + public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) { strength = TerrainUtil.MetersToSphericalStrength(strength); int x; for (x = 0; x < map.Width; x++) { - // Skip everything unlikely to be affected - if (Math.Abs(x - rx) > strength * 1.1) - continue; - int y; for (y = 0; y < map.Height; y++) { - // Skip everything unlikely to be affected - if (Math.Abs(y - ry) > strength * 1.1) + if (!mask[x,y]) continue; // Calculate a sphere and add it to the heighmap @@ -68,4 +63,4 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes #endregion } -} \ No newline at end of file +} diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/OlsenSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/OlsenSphere.cs index 6df8408..42ec794 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/OlsenSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/OlsenSphere.cs @@ -151,7 +151,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes #region ITerrainPaintableEffect Members - public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) + public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) { strength = TerrainUtil.MetersToSphericalStrength(strength); @@ -162,6 +162,9 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes int y; for (y = 0; y < map.Height; y++) { + if (!mask[x,y]) + continue; + double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); if (z > 0) // add in non-zero amount @@ -216,4 +219,4 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes #endregion } -} \ No newline at end of file +} diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs index e4fe091..92bac63 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs @@ -35,7 +35,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes #region ITerrainPaintableEffect Members - public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) + public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) { duration = 0.03; //MCP Should be read from ini file strength = TerrainUtil.MetersToSphericalStrength(strength); @@ -43,15 +43,10 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes int x; for (x = 0; x < map.Width; x++) { - // Skip everything unlikely to be affected - if (Math.Abs(x - rx) > strength * 1.1) - continue; - int y; for (y = 0; y < map.Height; y++) { - // Skip everything unlikely to be affected - if (Math.Abs(y - ry) > strength * 1.1) + if (!mask[x,y]) continue; // Calculate a sphere and add it to the heighmap @@ -67,4 +62,4 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes #endregion } -} \ No newline at end of file +} diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs index 7a1ec72..d3a1d3d 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs @@ -41,7 +41,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes #region ITerrainPaintableEffect Members - public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) + public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) { strength = TerrainUtil.MetersToSphericalStrength(strength); duration = 0.03; //MCP Should be read from ini file @@ -54,15 +54,10 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes int x; for (x = 0; x < map.Width; x++) { - // Skip everything unlikely to be affected - if (Math.Abs(x - rx) > strength * 1.1) - continue; - int y; for (y = 0; y < map.Height; y++) { - // Skip everything unlikely to be affected - if (Math.Abs(y - ry) > strength * 1.1) + if (!mask[x,y]) continue; // Calculate a sphere and add it to the heighmap diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs index 89d9063..c63cb90 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs @@ -33,7 +33,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes { #region ITerrainPaintableEffect Members - public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) + public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) { strength = TerrainUtil.MetersToSphericalStrength(strength); @@ -76,6 +76,9 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes { for (y = 0; y < map.Height; y++) { + if (!mask[x,y]) + continue; + double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); if (z > 0) // add in non-zero amount diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs index b3aa732..1288419 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs @@ -147,7 +147,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes #region ITerrainPaintableEffect Members - public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) + public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) { strength = TerrainUtil.MetersToSphericalStrength(strength); @@ -158,6 +158,9 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes int y; for (y = 0; y < map.Height; y++) { + if (!mask[x,y]) + continue; + double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); if (z > 0) // add in non-zero amount @@ -204,4 +207,4 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes #endregion } -} \ No newline at end of file +} -- cgit v1.1