aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-10-27 17:06:47 +0000
committerJustin Clarke Casey2008-10-27 17:06:47 +0000
commit6ec9c2d7068bd7b9da0cb32b6f0847d8fc6b0a53 (patch)
tree7637337a20aed42acefcd470ff70220b02353829 /OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs
parent* Temporarily revert terrain changes in r6976 and reinstate unit test from r6... (diff)
downloadopensim-SC_OLD-6ec9c2d7068bd7b9da0cb32b6f0847d8fc6b0a53.zip
opensim-SC_OLD-6ec9c2d7068bd7b9da0cb32b6f0847d8fc6b0a53.tar.gz
opensim-SC_OLD-6ec9c2d7068bd7b9da0cb32b6f0847d8fc6b0a53.tar.bz2
opensim-SC_OLD-6ec9c2d7068bd7b9da0cb32b6f0847d8fc6b0a53.tar.xz
* Apply http://opensimulator.org/mantis/view.php?id=2468
* This time there are accompanying changes to the unit test to adapt it to the changes * Thanks tglion
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs44
1 files changed, 32 insertions, 12 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs
index fe82396..745d3da 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs
@@ -36,29 +36,49 @@ 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 strength = TerrainUtil.MetersToSphericalStrength(strength); 39 int s = (int) (Math.Pow(2, strength) + 0.5);
40 duration = 0.03; //MCP Should be read from ini file 40
41
42 int x; 41 int x;
43 for (x = 0; x < map.Width; x++) 42 int xFrom = (int)(rx-s+0.5);
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++)
44 { 60 {
45 int y; 61 int y;
46 for (y = 0; y < map.Height; y++) 62 for (y = yFrom; y < yTo; y++)
47 { 63 {
48 if (!mask[x,y]) 64 if (!mask[x,y])
49 continue; 65 continue;
50 66
51 // Calculate a sphere and add it to the heighmap 67 // Calculate a cos-sphere and add it to the heighmap
52 double z = strength; 68 double r = Math.Sqrt((x-rx) * (x-rx) + ((y-ry) * (y-ry)));
53 z *= z; 69 double z = Math.Cos(r * Math.PI / (s * 2));
54 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
55
56 if (z > 0.0) 70 if (z > 0.0)
57 map[x, y] -= z * duration; 71 {
72 double newz = map[x, y] - z * duration;
73 if (newz < 0.0)
74 map[x, y] = 0.0;
75 else
76 map[x, y] = newz;
77 }
58 } 78 }
59 } 79 }
60 }
61 80
81 }
62 #endregion 82 #endregion
63 } 83 }
64} 84}