aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs41
1 files changed, 25 insertions, 16 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs
index e507481..1e2d611 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs
@@ -25,29 +25,48 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
29using OpenSim.Region.Environment.Interfaces; 28using OpenSim.Region.Environment.Interfaces;
30 29
31namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes 30namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
32{ 31{
33 public class FlattenSphere : ITerrainPaintableEffect 32 public class FlattenSphere : ITerrainPaintableEffect
34 { 33 {
34
35 #region ITerrainPaintableEffect Members 35 #region ITerrainPaintableEffect Members
36 36
37 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) 37 public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration)
38 { 38 {
39 strength = TerrainUtil.MetersToSphericalStrength(strength); 39 strength = TerrainUtil.MetersToSphericalStrength(strength);
40 40
41 int x, y; 41 int x, y;
42 42
43 // blend in map 43 double sum = 0.0;
44 double step2 = 0.0;
45 duration = 0.009; //MCP Should be read from ini file
46
47
48 // compute delta map
44 for (x = 0; x < map.Width; x++) 49 for (x = 0; x < map.Width; x++)
45 { 50 {
46 for (y = 0; y < map.Height; y++) 51 for (y = 0; y < map.Height; y++)
47 { 52 {
48 if (!mask[x,y]) 53 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength);
49 continue; 54
55 if (z > 0) // add in non-zero amount
56 {
57 sum += map[x, y] * z;
58 step2 += z;
59 }
60 }
61 }
62
63 double avg = sum / step2;
50 64
65 // blend in map
66 for (x = 0; x < map.Width; x++)
67 {
68 for (y = 0; y < map.Height; y++)
69 {
51 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength) * duration; 70 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength) * duration;
52 71
53 if (z > 0) // add in non-zero amount 72 if (z > 0) // add in non-zero amount
@@ -55,18 +74,8 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
55 if (z > 1.0) 74 if (z > 1.0)
56 z = 1.0; 75 z = 1.0;
57 76
58 map[x, y] = (map[x, y] * (1.0 - z)) + (rz * z); 77 map[x, y] = (map[x, y] * (1.0 - z)) + (avg * z);
59 } 78 }
60
61 double delta = rz - map[x, y];
62 if (Math.Abs(delta) > 0.1)
63 delta *= 0.25;
64
65 if (delta != 0) // add in non-zero amount
66 {
67 map[x, y] += delta;
68 }
69
70 } 79 }
71 } 80 }
72 } 81 }