aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs36
1 files changed, 11 insertions, 25 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs
index 290711f..fe82396 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs
@@ -36,43 +36,29 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
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, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
38 { 38 {
39 int s = (int) (Math.Pow(2, strength) + 0.5); 39 strength = TerrainUtil.MetersToSphericalStrength(strength);
40 40 duration = 0.03; //MCP Should be read from ini file
41
41 int x; 42 int x;
42 int xFrom = (int)(rx-s+0.5); 43 for (x = 0; x < map.Width; x++)
43 int xTo = (int)(rx+s+0.5) + 1;
44 int yFrom = (int)(ry-s+0.5);
45 int yTo = (int)(ry+s+0.5) + 1;
46
47 if (xFrom < 0)
48 xFrom = 0;
49
50 if (yFrom < 0)
51 yFrom = 0;
52
53 if (xTo > map.Width)
54 xTo = map.Width;
55
56 if (yTo > map.Width)
57 yTo = map.Width;
58
59 for (x = xFrom; x < xTo; x++)
60 { 44 {
61 int y; 45 int y;
62 for (y = yFrom; y <= yTo; y++) 46 for (y = 0; y < map.Height; y++)
63 { 47 {
64 if (!mask[x,y]) 48 if (!mask[x,y])
65 continue; 49 continue;
66 50
67 // Calculate a cos-sphere and add it to the heighmap 51 // Calculate a sphere and add it to the heighmap
68 double r = Math.Sqrt((x-rx) * (x-rx) + ((y-ry) * (y-ry))); 52 double z = strength;
69 double z = Math.Cos(r * Math.PI / (s * 2)); 53 z *= z;
54 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
55
70 if (z > 0.0) 56 if (z > 0.0)
71 map[x, y] -= z * duration; 57 map[x, y] -= z * duration;
72 } 58 }
73 } 59 }
74
75 } 60 }
61
76 #endregion 62 #endregion
77 } 63 }
78} 64}