From 03e3f88059908675652ec3da3b267bc04bab6c37 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Tue, 16 Sep 2008 07:19:22 +0000 Subject: From: mike pitman New patch (terrainedit2.patch) is attached that passes unit tests ( and in fact supplies the new unit test to pass..:) The previous failure was due to the change of the brush size to be linear instead of exponential, and the fact that the test parameters were assuming the exponentional brush size. This patch also removes dependency on 'duration' argument for adjustment step size. This should address the widely differing reports of instability with terrain editing. Note: 'doing this right' implies ultimately reading the parameters from the ini file, which this patch does not do. --- .../Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs | 4 +++- .../Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs | 3 ++- .../Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs | 2 ++ .../Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs | 3 ++- .../Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs | 6 ++++-- OpenSim/Region/Environment/Modules/World/Terrain/TerrainUtil.cs | 3 ++- .../Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs | 4 ++-- 7 files changed, 17 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Environment/Modules/World/Terrain') diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs index 7bf88f0..40fb01e 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs @@ -42,6 +42,8 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes 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++) @@ -80,4 +82,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/LowerSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs index 202ab3b..08b2879 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs @@ -37,7 +37,8 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) { strength = TerrainUtil.MetersToSphericalStrength(strength); - + duration = 0.03; //MCP Should be read from ini file + int x; for (x = 0; x < map.Width; x++) { diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs index f5344a0..e4fe091 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs @@ -33,9 +33,11 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes public class RaiseSphere : ITerrainPaintableEffect { #region ITerrainPaintableEffect Members + public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) { + duration = 0.03; //MCP Should be read from ini file strength = TerrainUtil.MetersToSphericalStrength(strength); int x; diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs index db3fef7..64c0a07 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs @@ -44,7 +44,8 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) { strength = TerrainUtil.MetersToSphericalStrength(strength); - + duration = 0.03; //MCP Should be read from ini file + if (duration > 1.0) duration = 1.0; if (duration < 0) diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs index fc0a579..89d9063 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs @@ -40,8 +40,10 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes int x, y; double[,] tweak = new double[map.Width,map.Height]; - double area = strength; + double area = strength; double step = strength / 4.0; + duration = 0.0045; //MCP Should be read from ini file + // compute delta map for (x = 0; x < map.Width; x++) @@ -91,4 +93,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/TerrainUtil.cs b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainUtil.cs index def28eb..2e6595a 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainUtil.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainUtil.cs @@ -34,7 +34,8 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain { public static double MetersToSphericalStrength(double size) { - return Math.Pow(2, size); + //return Math.Pow(2, size); + return (size + 1) * 2.5; // MCP: a more useful brush size range } public static double SphericalFactor(double x, double y, double rx, double ry, double size) diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs b/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs index 61ebc5c..eaa674e 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/Tests/TerrainTest.cs @@ -40,14 +40,14 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.Tests TerrainChannel x = new TerrainChannel(256, 256); ITerrainPaintableEffect effect = new RaiseSphere(); - effect.PaintEffect(x, 128.0, 128.0, 50, 0.1); + effect.PaintEffect(x, 128.0, 128.0, 100, 0.1); Assert.That(x[128, 128] > 0.0, "Raise brush not raising values."); Assert.That(x[0, 128] > 0.0, "Raise brush lowering edge values."); x = new TerrainChannel(256, 256); effect = new LowerSphere(); - effect.PaintEffect(x, 128.0, 128.0, 50, 0.1); + effect.PaintEffect(x, 128.0, 128.0, 100, 0.1); Assert.That(x[128, 128] < 0.0, "Lower not lowering values."); Assert.That(x[0, 128] < 0.0, "Lower brush affecting edge values."); } -- cgit v1.1