aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs35
1 files changed, 9 insertions, 26 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs
index b1a52b0..92bac63 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs
@@ -26,51 +26,34 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Reflection;
30using log4net;
31using OpenSim.Region.Environment.Interfaces; 29using OpenSim.Region.Environment.Interfaces;
32 30
33namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes 31namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
34{ 32{
35 public class RaiseSphere : ITerrainPaintableEffect 33 public class RaiseSphere : ITerrainPaintableEffect
36 { 34 {
37 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
38 #region ITerrainPaintableEffect Members 35 #region ITerrainPaintableEffect Members
39 36
40 37
41 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) 38 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
42 { 39 {
43 int s = (int) (Math.Pow(2, strength) + 0.5); 40 duration = 0.03; //MCP Should be read from ini file
41 strength = TerrainUtil.MetersToSphericalStrength(strength);
44 42
45 int x; 43 int x;
46 int xFrom = (int)(rx-s+0.5); 44 for (x = 0; x < map.Width; x++)
47 int xTo = (int)(rx+s+0.5) + 1;
48 int yFrom = (int)(ry-s+0.5);
49 int yTo = (int)(ry+s+0.5) + 1;
50
51 if (xFrom < 0)
52 xFrom = 0;
53
54 if (yFrom < 0)
55 yFrom = 0;
56
57 if (xTo > map.Width)
58 xTo = map.Width;
59
60 if (yTo > map.Width)
61 yTo = map.Width;
62
63 for (x = xFrom; x < xTo; x++)
64 { 45 {
65 int y; 46 int y;
66 for (y = yFrom; y <= yTo; y++) 47 for (y = 0; y < map.Height; y++)
67 { 48 {
68 if (!mask[x,y]) 49 if (!mask[x,y])
69 continue; 50 continue;
70 51
71 // Calculate a cos-sphere and add it to the heighmap 52 // Calculate a sphere and add it to the heighmap
72 double r = Math.Sqrt((x-rx) * (x-rx) + ((y-ry) * (y-ry))); 53 double z = strength;
73 double z = Math.Cos(r * Math.PI / (s * 2)); 54 z *= z;
55 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
56
74 if (z > 0.0) 57 if (z > 0.0)
75 map[x, y] += z * duration; 58 map[x, y] += z * duration;
76 } 59 }