aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/OlsenSphere.cs
diff options
context:
space:
mode:
authorAdam Frisby2008-05-03 20:00:35 +0000
committerAdam Frisby2008-05-03 20:00:35 +0000
commit87b313792821cb842fd54b568302b6877c4e53f8 (patch)
tree446719156d1e8d8c12bc3bcd69546f04ba0d79ab /OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/OlsenSphere.cs
parent* Refactor: Move MoveFolder() and PurgeFolder() into CachedUserInfo (which ar... (diff)
downloadopensim-SC_OLD-87b313792821cb842fd54b568302b6877c4e53f8.zip
opensim-SC_OLD-87b313792821cb842fd54b568302b6877c4e53f8.tar.gz
opensim-SC_OLD-87b313792821cb842fd54b568302b6877c4e53f8.tar.bz2
opensim-SC_OLD-87b313792821cb842fd54b568302b6877c4e53f8.tar.xz
* Cleaned up code in Terrain, Tree and Map modules.
* Fixed a bug with Terragen loader where it would do bad things on a non 256x256 sized terrain. Now loads the array correctly. * Moved MapImageModule.cs to Modules/World/WorldMap * Changed Location.RegionHandle to use Helpers.GetUlong instead of doing it ourselves.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/OlsenSphere.cs28
1 files changed, 11 insertions, 17 deletions
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 {