diff options
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs index 92bac63..56813ab 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs | |||
@@ -37,23 +37,37 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes | |||
37 | 37 | ||
38 | 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) |
39 | { | 39 | { |
40 | duration = 0.03; //MCP Should be read from ini file | 40 | int s = (int) (Math.Pow(2, strength) + 0.5); |
41 | strength = TerrainUtil.MetersToSphericalStrength(strength); | ||
42 | 41 | ||
43 | int x; | 42 | int x; |
44 | for (x = 0; x < map.Width; x++) | 43 | int xFrom = (int)(rx-s+0.5); |
44 | int xTo = (int)(rx+s+0.5) + 1; | ||
45 | int yFrom = (int)(ry-s+0.5); | ||
46 | int yTo = (int)(ry+s+0.5) + 1; | ||
47 | |||
48 | if (xFrom < 0) | ||
49 | xFrom = 0; | ||
50 | |||
51 | if (yFrom < 0) | ||
52 | yFrom = 0; | ||
53 | |||
54 | if (xTo > map.Width) | ||
55 | xTo = map.Width; | ||
56 | |||
57 | if (yTo > map.Width) | ||
58 | yTo = map.Width; | ||
59 | |||
60 | for (x = xFrom; x < xTo; x++) | ||
45 | { | 61 | { |
46 | int y; | 62 | int y; |
47 | for (y = 0; y < map.Height; y++) | 63 | for (y = yFrom; y < yTo; y++) |
48 | { | 64 | { |
49 | if (!mask[x,y]) | 65 | if (!mask[x,y]) |
50 | continue; | 66 | continue; |
51 | 67 | ||
52 | // Calculate a sphere and add it to the heighmap | 68 | // Calculate a cos-sphere and add it to the heighmap |
53 | double z = strength; | 69 | double r = Math.Sqrt((x-rx) * (x-rx) + ((y-ry) * (y-ry))); |
54 | z *= z; | 70 | double z = Math.Cos(r * Math.PI / (s * 2)); |
55 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); | ||
56 | |||
57 | if (z > 0.0) | 71 | if (z > 0.0) |
58 | map[x, y] += z * duration; | 72 | map[x, y] += z * duration; |
59 | } | 73 | } |