aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/ErodeSphere.cs19
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs17
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs3
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs5
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/OlsenSphere.cs28
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs3
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs5
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs3
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs16
9 files changed, 43 insertions, 56 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/ErodeSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/ErodeSphere.cs
index e036988..dae4cf8 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/ErodeSphere.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/ErodeSphere.cs
@@ -35,20 +35,20 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
35 /// </summary> 35 /// </summary>
36 public class ErodeSphere : ITerrainPaintableEffect 36 public class ErodeSphere : ITerrainPaintableEffect
37 { 37 {
38 private double rainHeight = 0.2; 38 private const double rainHeight = 0.2;
39 private int rounds = 10; 39 private const int rounds = 10;
40 private NeighbourSystem type = NeighbourSystem.Moore; // Parameter 40 private const NeighbourSystem type = NeighbourSystem.Moore;
41 private double waterSaturation = 0.30; // Can carry 1% of water in height 41 private const double waterSaturation = 0.30;
42 42
43 #region Supporting Functions 43 #region Supporting Functions
44 44
45 private int[] Neighbours(NeighbourSystem type, int index) 45 private static int[] Neighbours(NeighbourSystem neighbourType, int index)
46 { 46 {
47 int[] coord = new int[2]; 47 int[] coord = new int[2];
48 48
49 index++; 49 index++;
50 50
51 switch (type) 51 switch (neighbourType)
52 { 52 {
53 case NeighbourSystem.Moore: 53 case NeighbourSystem.Moore:
54 switch (index) 54 switch (index)
@@ -173,7 +173,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
173 { 173 {
174 for (y = 0; y < water.Height; y++) 174 for (y = 0; y < water.Height; y++)
175 { 175 {
176 double solConst = (1.0 / rounds); 176 const double solConst = (1.0 / rounds);
177 double sedDelta = water[x, y] * solConst; 177 double sedDelta = water[x, y] * solConst;
178 map[x, y] -= sedDelta; 178 map[x, y] -= sedDelta;
179 sediment[x, y] += sedDelta; 179 sediment[x, y] += sedDelta;
@@ -194,9 +194,8 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
194 double altitudeTotal = 0.0; 194 double altitudeTotal = 0.0;
195 double altitudeMe = map[x, y] + water[x, y]; 195 double altitudeMe = map[x, y] + water[x, y];
196 196
197 int NEIGHBOUR_ME = 4; 197 const int NEIGHBOUR_ME = 4;
198 198 const int NEIGHBOUR_MAX = 9;
199 int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5;
200 199
201 for (int j = 0; j < NEIGHBOUR_MAX; j++) 200 for (int j = 0; j < NEIGHBOUR_MAX; j++)
202 { 201 {
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs
index dee455f..0c4e3de 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs
@@ -39,21 +39,16 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
39 strength = TerrainUtil.MetersToSphericalStrength(strength); 39 strength = TerrainUtil.MetersToSphericalStrength(strength);
40 40
41 int x, y; 41 int x, y;
42 double[,] tweak = new double[map.Width,map.Height];
43
44 double area = strength;
45 double step = strength / 4.0;
46 42
47 double sum = 0.0; 43 double sum = 0.0;
48 double step2 = 0.0; 44 double step2 = 0.0;
49 double avg = 0.0;
50 45
51 // compute delta map 46 // compute delta map
52 for (x = 0; x < map.Width; x++) 47 for (x = 0; x < map.Width; x++)
53 { 48 {
54 for (y = 0; y < map.Height; y++) 49 for (y = 0; y < map.Height; y++)
55 { 50 {
56 double z = SphericalFactor(x, y, rx, ry, strength); 51 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength);
57 52
58 if (z > 0) // add in non-zero amount 53 if (z > 0) // add in non-zero amount
59 { 54 {
@@ -63,14 +58,14 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
63 } 58 }
64 } 59 }
65 60
66 avg = sum / step2; 61 double avg = sum / step2;
67 62
68 // blend in map 63 // blend in map
69 for (x = 0; x < map.Width; x++) 64 for (x = 0; x < map.Width; x++)
70 { 65 {
71 for (y = 0; y < map.Height; y++) 66 for (y = 0; y < map.Height; y++)
72 { 67 {
73 double z = SphericalFactor(x, y, rx, ry, strength) * duration; 68 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength) * duration;
74 69
75 if (z > 0) // add in non-zero amount 70 if (z > 0) // add in non-zero amount
76 { 71 {
@@ -84,11 +79,5 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
84 } 79 }
85 80
86 #endregion 81 #endregion
87
88 private double SphericalFactor(double x, double y, double rx, double ry, double size)
89 {
90 double z = size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry));
91 return z;
92 }
93 } 82 }
94} \ No newline at end of file 83} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs
index 092bd29..202ab3b 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/LowerSphere.cs
@@ -38,13 +38,14 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
38 { 38 {
39 strength = TerrainUtil.MetersToSphericalStrength(strength); 39 strength = TerrainUtil.MetersToSphericalStrength(strength);
40 40
41 int x, y; 41 int x;
42 for (x = 0; x < map.Width; x++) 42 for (x = 0; x < map.Width; x++)
43 { 43 {
44 // Skip everything unlikely to be affected 44 // Skip everything unlikely to be affected
45 if (Math.Abs(x - rx) > strength * 1.1) 45 if (Math.Abs(x - rx) > strength * 1.1)
46 continue; 46 continue;
47 47
48 int y;
48 for (y = 0; y < map.Height; y++) 49 for (y = 0; y < map.Height; y++)
49 { 50 {
50 // Skip everything unlikely to be affected 51 // Skip everything unlikely to be affected
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs
index 8ae583e..0824efd 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/NoiseSphere.cs
@@ -39,13 +39,14 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
39 { 39 {
40 strength = TerrainUtil.MetersToSphericalStrength(strength); 40 strength = TerrainUtil.MetersToSphericalStrength(strength);
41 41
42 int x, y; 42 int x;
43 for (x = 0; x < map.Width; x++) 43 for (x = 0; x < map.Width; x++)
44 { 44 {
45 // Skip everything unlikely to be affected 45 // Skip everything unlikely to be affected
46 if (Math.Abs(x - rx) > strength * 1.1) 46 if (Math.Abs(x - rx) > strength * 1.1)
47 continue; 47 continue;
48 48
49 int y;
49 for (y = 0; y < map.Height; y++) 50 for (y = 0; y < map.Height; y++)
50 { 51 {
51 // Skip everything unlikely to be affected 52 // Skip everything unlikely to be affected
@@ -57,7 +58,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
57 z *= z; 58 z *= z;
58 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); 59 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
59 60
60 double noise = TerrainUtil.PerlinNoise2D((double) x / (double) Constants.RegionSize, (double) y / (double) Constants.RegionSize, 8, 1.0); 61 double noise = TerrainUtil.PerlinNoise2D(x / (double) Constants.RegionSize, y / (double) Constants.RegionSize, 8, 1.0);
61 62
62 if (z > 0.0) 63 if (z > 0.0)
63 map[x, y] += noise * z * duration; 64 map[x, y] += noise * z * duration;
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/OlsenSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/OlsenSphere.cs
index ba01a01..f2a1800 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/OlsenSphere.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/OlsenSphere.cs
@@ -38,18 +38,18 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
38 /// </summary> 38 /// </summary>
39 public class OlsenSphere : ITerrainPaintableEffect 39 public class OlsenSphere : ITerrainPaintableEffect
40 { 40 {
41 private double nConst = 1024.0; 41 private const double nConst = 1024.0;
42 private NeighbourSystem type = NeighbourSystem.Moore; // Parameter 42 private const NeighbourSystem type = NeighbourSystem.Moore;
43 43
44 #region Supporting Functions 44 #region Supporting Functions
45 45
46 private int[] Neighbours(NeighbourSystem type, int index) 46 private static int[] Neighbours(NeighbourSystem neighbourType, int index)
47 { 47 {
48 int[] coord = new int[2]; 48 int[] coord = new int[2];
49 49
50 index++; 50 index++;
51 51
52 switch (type) 52 switch (neighbourType)
53 { 53 {
54 case NeighbourSystem.Moore: 54 case NeighbourSystem.Moore:
55 switch (index) 55 switch (index)
@@ -141,12 +141,6 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
141 return coord; 141 return coord;
142 } 142 }
143 143
144 private double SphericalFactor(double x, double y, double rx, double ry, double size)
145 {
146 double z = size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry));
147 return z;
148 }
149
150 private enum NeighbourSystem 144 private enum NeighbourSystem
151 { 145 {
152 Moore, 146 Moore,
@@ -161,22 +155,22 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
161 { 155 {
162 strength = TerrainUtil.MetersToSphericalStrength(strength); 156 strength = TerrainUtil.MetersToSphericalStrength(strength);
163 157
164 int x, y; 158 int x;
165 159
166 for (x = 0; x < map.Width; x++) 160 for (x = 0; x < map.Width; x++)
167 { 161 {
162 int y;
168 for (y = 0; y < map.Height; y++) 163 for (y = 0; y < map.Height; y++)
169 { 164 {
170 double z = SphericalFactor(x, y, rx, ry, strength); 165 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength);
171 166
172 if (z > 0) // add in non-zero amount 167 if (z > 0) // add in non-zero amount
173 { 168 {
174 int NEIGHBOUR_ME = 4; 169 const int NEIGHBOUR_ME = 4;
175 int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5; 170 const int NEIGHBOUR_MAX = 9;
176 171
177 double max = Double.MinValue; 172 double max = Double.MinValue;
178 int loc = 0; 173 int loc = 0;
179 double cellmax = 0;
180 174
181 175
182 for (int j = 0; j < NEIGHBOUR_MAX; j++) 176 for (int j = 0; j < NEIGHBOUR_MAX; j++)
@@ -197,7 +191,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
197 if (coords[1] < 0) 191 if (coords[1] < 0)
198 continue; 192 continue;
199 193
200 cellmax = map[x, y] - map[coords[0], coords[1]]; 194 double cellmax = map[x, y] - map[coords[0], coords[1]];
201 if (cellmax > max) 195 if (cellmax > max)
202 { 196 {
203 max = cellmax; 197 max = cellmax;
@@ -206,7 +200,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
206 } 200 }
207 } 201 }
208 202
209 double T = nConst / ((map.Width + map.Height) / 2); 203 double T = nConst / ((map.Width + map.Height) / 2.0);
210 // Apply results 204 // Apply results
211 if (0 < max && max <= T) 205 if (0 < max && max <= T)
212 { 206 {
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs
index 5d6f093..f5344a0 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RaiseSphere.cs
@@ -38,13 +38,14 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
38 { 38 {
39 strength = TerrainUtil.MetersToSphericalStrength(strength); 39 strength = TerrainUtil.MetersToSphericalStrength(strength);
40 40
41 int x, y; 41 int x;
42 for (x = 0; x < map.Width; x++) 42 for (x = 0; x < map.Width; x++)
43 { 43 {
44 // Skip everything unlikely to be affected 44 // Skip everything unlikely to be affected
45 if (Math.Abs(x - rx) > strength * 1.1) 45 if (Math.Abs(x - rx) > strength * 1.1)
46 continue; 46 continue;
47 47
48 int y;
48 for (y = 0; y < map.Height; y++) 49 for (y = 0; y < map.Height; y++)
49 { 50 {
50 // Skip everything unlikely to be affected 51 // Skip everything unlikely to be affected
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs
index b47e041..3deb458 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/RevertSphere.cs
@@ -32,7 +32,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
32{ 32{
33 public class RevertSphere : ITerrainPaintableEffect 33 public class RevertSphere : ITerrainPaintableEffect
34 { 34 {
35 private ITerrainChannel m_revertmap; 35 private readonly ITerrainChannel m_revertmap;
36 36
37 public RevertSphere(ITerrainChannel revertmap) 37 public RevertSphere(ITerrainChannel revertmap)
38 { 38 {
@@ -50,13 +50,14 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
50 if (duration < 0) 50 if (duration < 0)
51 return; 51 return;
52 52
53 int x, y; 53 int x;
54 for (x = 0; x < map.Width; x++) 54 for (x = 0; x < map.Width; x++)
55 { 55 {
56 // Skip everything unlikely to be affected 56 // Skip everything unlikely to be affected
57 if (Math.Abs(x - rx) > strength * 1.1) 57 if (Math.Abs(x - rx) > strength * 1.1)
58 continue; 58 continue;
59 59
60 int y;
60 for (y = 0; y < map.Height; y++) 61 for (y = 0; y < map.Height; y++)
61 { 62 {
62 // Skip everything unlikely to be affected 63 // Skip everything unlikely to be affected
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs
index 51d5f0e..49946fd 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/SmoothSphere.cs
@@ -40,7 +40,6 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
40 int x, y; 40 int x, y;
41 double[,] tweak = new double[map.Width,map.Height]; 41 double[,] tweak = new double[map.Width,map.Height];
42 42
43 double n, l;
44 double area = strength; 43 double area = strength;
45 double step = strength / 4.0; 44 double step = strength / 4.0;
46 45
@@ -56,8 +55,10 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
56 double average = 0.0; 55 double average = 0.0;
57 int avgsteps = 0; 56 int avgsteps = 0;
58 57
58 double n;
59 for (n = 0.0 - area; n < area; n += step) 59 for (n = 0.0 - area; n < area; n += step)
60 { 60 {
61 double l;
61 for (l = 0.0 - area; l < area; l += step) 62 for (l = 0.0 - area; l < area; l += step)
62 { 63 {
63 avgsteps++; 64 avgsteps++;
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs
index b48beb8..753d171 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs
@@ -34,18 +34,18 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
34 /// </summary> 34 /// </summary>
35 public class WeatherSphere : ITerrainPaintableEffect 35 public class WeatherSphere : ITerrainPaintableEffect
36 { 36 {
37 private double talus = 0.2; // Number of meters max difference before stop eroding. Tweakage required. 37 private const double talus = 0.2;
38 private NeighbourSystem type = NeighbourSystem.Moore; // Parameter 38 private const NeighbourSystem type = NeighbourSystem.Moore;
39 39
40 #region Supporting Functions 40 #region Supporting Functions
41 41
42 private int[] Neighbours(NeighbourSystem type, int index) 42 private static int[] Neighbours(NeighbourSystem neighbourType, int index)
43 { 43 {
44 int[] coord = new int[2]; 44 int[] coord = new int[2];
45 45
46 index++; 46 index++;
47 47
48 switch (type) 48 switch (neighbourType)
49 { 49 {
50 case NeighbourSystem.Moore: 50 case NeighbourSystem.Moore:
51 switch (index) 51 switch (index)
@@ -151,19 +151,19 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
151 { 151 {
152 strength = TerrainUtil.MetersToSphericalStrength(strength); 152 strength = TerrainUtil.MetersToSphericalStrength(strength);
153 153
154 int x, y; 154 int x;
155 155
156 for (x = 0; x < map.Width; x++) 156 for (x = 0; x < map.Width; x++)
157 { 157 {
158 int y;
158 for (y = 0; y < map.Height; y++) 159 for (y = 0; y < map.Height; y++)
159 { 160 {
160 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); 161 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength);
161 162
162 if (z > 0) // add in non-zero amount 163 if (z > 0) // add in non-zero amount
163 { 164 {
164 int NEIGHBOUR_ME = 4; 165 const int NEIGHBOUR_ME = 4;
165 166 const int NEIGHBOUR_MAX = 9;
166 int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5;
167 167
168 for (int j = 0; j < NEIGHBOUR_MAX; j++) 168 for (int j = 0; j < NEIGHBOUR_MAX; j++)
169 { 169 {