aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Terrain.BasicTerrain
diff options
context:
space:
mode:
authorlbsa712007-10-30 09:05:31 +0000
committerlbsa712007-10-30 09:05:31 +0000
commit67e12b95ea7b68f4904a7484d77ecfd787d16d0c (patch)
tree20b00d24c8a7617017960432ec044852e3ad5fa9 /OpenSim/Region/Terrain.BasicTerrain
parent* Deleted .user file (diff)
downloadopensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.zip
opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.gz
opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.bz2
opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.xz
* Optimized usings
* Shortened type references * Removed redundant 'this' qualifier
Diffstat (limited to 'OpenSim/Region/Terrain.BasicTerrain')
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs31
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs169
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/TerrainFilter.cs8
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Bitmap/Bitmap.cs20
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Channel.cs18
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Common.cs33
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs29
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs14
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/File.cs15
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs10
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Gradient.cs5
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs77
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Noise.cs4
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs47
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Voronoi.cs35
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Worms.cs14
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs42
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs23
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/HydraulicErosion.cs19
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs100
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/ThermalWeathering.cs18
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Neighbours.cs10
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs9
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Tools/Point2D.cs6
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Tools/Tools.cs31
25 files changed, 379 insertions, 408 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs b/OpenSim/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs
index e1c3191..e531f01 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/Properties/AssemblyInfo.cs
@@ -1,4 +1,4 @@
1/* 1/*
2* Copyright (c) Contributors, http://opensimulator.org/ 2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
@@ -27,25 +27,29 @@
27*/ 27*/
28using System.Reflection; 28using System.Reflection;
29using System.Runtime.InteropServices; 29using System.Runtime.InteropServices;
30
30// General Information about an assembly is controlled through the following 31// General Information about an assembly is controlled through the following
31// set of attributes. Change these attribute values to modify the information 32// set of attributes. Change these attribute values to modify the information
32// associated with an assembly. 33// associated with an assembly.
33[assembly: AssemblyTitle("OpenSim.Region.Terrain.BasicTerrain")] 34
34[assembly: AssemblyDescription("")] 35[assembly : AssemblyTitle("OpenSim.Region.Terrain.BasicTerrain")]
35[assembly: AssemblyConfiguration("")] 36[assembly : AssemblyDescription("")]
36[assembly: AssemblyCompany("")] 37[assembly : AssemblyConfiguration("")]
37[assembly: AssemblyProduct("OpenSim.Region.Terrain.BasicTerrain")] 38[assembly : AssemblyCompany("")]
38[assembly: AssemblyCopyright("Copyright © 2007")] 39[assembly : AssemblyProduct("OpenSim.Region.Terrain.BasicTerrain")]
39[assembly: AssemblyTrademark("")] 40[assembly : AssemblyCopyright("Copyright © 2007")]
40[assembly: AssemblyCulture("")] 41[assembly : AssemblyTrademark("")]
42[assembly : AssemblyCulture("")]
41 43
42// Setting ComVisible to false makes the types in this assembly not visible 44// Setting ComVisible to false makes the types in this assembly not visible
43// to COM components. If you need to access a type in this assembly from 45// to COM components. If you need to access a type in this assembly from
44// COM, set the ComVisible attribute to true on that type. 46// COM, set the ComVisible attribute to true on that type.
45[assembly: ComVisible(false)] 47
48[assembly : ComVisible(false)]
46 49
47// The following GUID is for the ID of the typelib if this project is exposed to COM 50// The following GUID is for the ID of the typelib if this project is exposed to COM
48[assembly: Guid("3263f5b5-0a41-4ed5-91a2-9baaaeecc849")] 51
52[assembly : Guid("3263f5b5-0a41-4ed5-91a2-9baaaeecc849")]
49 53
50// Version information for an assembly consists of the following four values: 54// Version information for an assembly consists of the following four values:
51// 55//
@@ -56,5 +60,6 @@ using System.Runtime.InteropServices;
56// 60//
57// You can specify all the values or you can default the Revision and Build Numbers 61// You can specify all the values or you can default the Revision and Build Numbers
58// by using the '*' as shown below: 62// by using the '*' as shown below:
59[assembly: AssemblyVersion("1.0.0.0")] 63
60[assembly: AssemblyFileVersion("1.0.0.0")] 64[assembly : AssemblyVersion("1.0.0.0")]
65[assembly : AssemblyFileVersion("1.0.0.0")] \ No newline at end of file
diff --git a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
index c8c6e51..bbbb4d7 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
@@ -29,11 +29,11 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Drawing; 30using System.Drawing;
31using System.Drawing.Imaging; 31using System.Drawing.Imaging;
32using System.Globalization;
32using System.IO; 33using System.IO;
34using System.Threading;
33using libTerrain; 35using libTerrain;
34using OpenJPEGNet; 36using OpenJPEGNet;
35using OpenSim.Framework.Interfaces;
36using System.Globalization;
37using OpenSim.Framework; 37using OpenSim.Framework;
38 38
39namespace OpenSim.Region.Terrain 39namespace OpenSim.Region.Terrain
@@ -51,7 +51,7 @@ namespace OpenSim.Region.Terrain
51 51
52 public class TerrainEngine 52 public class TerrainEngine
53 { 53 {
54 public static System.Threading.Mutex fileIOLock = new System.Threading.Mutex(); 54 public static Mutex fileIOLock = new Mutex();
55 55
56 /// <summary> 56 /// <summary>
57 /// Plugin library for scripts 57 /// Plugin library for scripts
@@ -95,12 +95,13 @@ namespace OpenSim.Region.Terrain
95 /// </summary> 95 /// </summary>
96 public int tainted; 96 public int tainted;
97 97
98 int w, h; 98 private int w, h;
99 99
100 /// <summary> 100 /// <summary>
101 /// Used to determine what offset to use when loading singular heightmaps across multiple sims 101 /// Used to determine what offset to use when loading singular heightmaps across multiple sims
102 /// </summary> 102 /// </summary>
103 private int offsetX; 103 private int offsetX;
104
104 private int offsetY; 105 private int offsetY;
105 106
106 107
@@ -139,13 +140,13 @@ namespace OpenSim.Region.Terrain
139 140
140 public bool Tainted(int x, int y) 141 public bool Tainted(int x, int y)
141 { 142 {
142 return (heightmap.diff[x / 16, y / 16] != 0); 143 return (heightmap.diff[x/16, y/16] != 0);
143 } 144 }
144 145
145 public void ResetTaint() 146 public void ResetTaint()
146 { 147 {
147 tainted = 0; 148 tainted = 0;
148 heightmap.diff = new int[w / 16, h / 16]; 149 heightmap.diff = new int[w/16,h/16];
149 } 150 }
150 151
151 //Testing to see if moving the TerraForming packet handling code into here works well 152 //Testing to see if moving the TerraForming packet handling code into here works well
@@ -158,40 +159,40 @@ namespace OpenSim.Region.Terrain
158 /// <param name="action">The action to be performed</param> 159 /// <param name="action">The action to be performed</param>
159 /// <param name="north">Distance from the north border where the cursor is located</param> 160 /// <param name="north">Distance from the north border where the cursor is located</param>
160 /// <param name="west">Distance from the west border where the cursor is located</param> 161 /// <param name="west">Distance from the west border where the cursor is located</param>
161 public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west, IClientAPI remoteUser) 162 public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west,
163 IClientAPI remoteUser)
162 { 164 {
163
164 // Shiny. 165 // Shiny.
165 double size = (double)(1 << brushsize); 166 double size = (double) (1 << brushsize);
166 167
167 switch (action) 168 switch (action)
168 { 169 {
169 case 0: 170 case 0:
170 // flatten terrain 171 // flatten terrain
171 this.FlattenTerrain(west, north, size, (double)seconds / 5.0); 172 FlattenTerrain(west, north, size, (double) seconds/5.0);
172 break; 173 break;
173 case 1: 174 case 1:
174 // raise terrain 175 // raise terrain
175 this.RaiseTerrain(west, north, size, (double)seconds / 5.0); 176 RaiseTerrain(west, north, size, (double) seconds/5.0);
176 break; 177 break;
177 case 2: 178 case 2:
178 //lower terrain 179 //lower terrain
179 this.LowerTerrain(west, north, size, (double)seconds / 5.0); 180 LowerTerrain(west, north, size, (double) seconds/5.0);
180 break; 181 break;
181 case 3: 182 case 3:
182 // smooth terrain 183 // smooth terrain
183 this.SmoothTerrain(west, north, size, (double)seconds / 5.0); 184 SmoothTerrain(west, north, size, (double) seconds/5.0);
184 break; 185 break;
185 case 4: 186 case 4:
186 // noise 187 // noise
187 this.NoiseTerrain(west, north, size, (double)seconds / 5.0); 188 NoiseTerrain(west, north, size, (double) seconds/5.0);
188 break; 189 break;
189 case 5: 190 case 5:
190 // revert 191 // revert
191 this.RevertTerrain(west, north, size, (double)seconds / 5.0); 192 RevertTerrain(west, north, size, (double) seconds/5.0);
192 break; 193 break;
193 194
194 // CLIENT EXTENSIONS GO HERE 195 // CLIENT EXTENSIONS GO HERE
195 case 128: 196 case 128:
196 // erode-thermal 197 // erode-thermal
197 break; 198 break;
@@ -207,9 +208,9 @@ namespace OpenSim.Region.Terrain
207 { 208 {
208 for (int y = 0; y < 16; y++) 209 for (int y = 0; y < 16; y++)
209 { 210 {
210 if (this.Tainted(x * 16, y * 16)) 211 if (Tainted(x*16, y*16))
211 { 212 {
212 remoteUser.SendLayerData(x, y, this.GetHeights1D()); 213 remoteUser.SendLayerData(x, y, GetHeights1D());
213 } 214 }
214 } 215 }
215 } 216 }
@@ -249,12 +250,12 @@ namespace OpenSim.Region.Terrain
249 /// <returns>A float[65536] array containing the heightmap</returns> 250 /// <returns>A float[65536] array containing the heightmap</returns>
250 public float[] GetHeights1D() 251 public float[] GetHeights1D()
251 { 252 {
252 float[] heights = new float[w * h]; 253 float[] heights = new float[w*h];
253 int i; 254 int i;
254 255
255 for (i = 0; i < w * h; i++) 256 for (i = 0; i < w*h; i++)
256 { 257 {
257 heights[i] = (float)heightmap.map[i % w, i / w]; 258 heights[i] = (float) heightmap.map[i%w, i/w];
258 } 259 }
259 260
260 return heights; 261 return heights;
@@ -266,13 +267,13 @@ namespace OpenSim.Region.Terrain
266 /// <returns>An array of 256,256 values containing the heightmap</returns> 267 /// <returns>An array of 256,256 values containing the heightmap</returns>
267 public float[,] GetHeights2D() 268 public float[,] GetHeights2D()
268 { 269 {
269 float[,] heights = new float[w, h]; 270 float[,] heights = new float[w,h];
270 int x, y; 271 int x, y;
271 for (x = 0; x < w; x++) 272 for (x = 0; x < w; x++)
272 { 273 {
273 for (y = 0; y < h; y++) 274 for (y = 0; y < h; y++)
274 { 275 {
275 heights[x, y] = (float)heightmap.map[x, y]; 276 heights[x, y] = (float) heightmap.map[x, y];
276 } 277 }
277 } 278 }
278 return heights; 279 return heights;
@@ -294,9 +295,9 @@ namespace OpenSim.Region.Terrain
294 public void GetHeights1D(float[] heights) 295 public void GetHeights1D(float[] heights)
295 { 296 {
296 int i; 297 int i;
297 for (i = 0; i < w * h; i++) 298 for (i = 0; i < w*h; i++)
298 { 299 {
299 heightmap.map[i % w, i / w] = heights[i]; 300 heightmap.map[i%w, i/w] = heights[i];
300 } 301 }
301 302
302 tainted++; 303 tainted++;
@@ -313,7 +314,7 @@ namespace OpenSim.Region.Terrain
313 { 314 {
314 for (y = 0; y < h; y++) 315 for (y = 0; y < h; y++)
315 { 316 {
316 heightmap.Set(x, y, (double)heights[x, y]); 317 heightmap.Set(x, y, (double) heights[x, y]);
317 } 318 }
318 } 319 }
319 SaveRevertMap(); 320 SaveRevertMap();
@@ -376,28 +377,36 @@ namespace OpenSim.Region.Terrain
376 377
377 try 378 try
378 { 379 {
379
380 switch (command) 380 switch (command)
381 { 381 {
382 case "help": 382 case "help":
383 resultText += "terrain regenerate - rebuilds the sims terrain using a default algorithm\n"; 383 resultText += "terrain regenerate - rebuilds the sims terrain using a default algorithm\n";
384 resultText += "terrain hills <type> <number of hills> <min height> <max height> <island t/f> <additive t/f> <noisy t/f>\n"; 384 resultText +=
385 "terrain hills <type> <number of hills> <min height> <max height> <island t/f> <additive t/f> <noisy t/f>\n";
385 resultText += " type should be spheres, blocks, cones, or squared\n"; 386 resultText += " type should be spheres, blocks, cones, or squared\n";
386 resultText += "terrain voronoi <points> <blocksize> - generates a worley fractal with X points per block"; 387 resultText +=
388 "terrain voronoi <points> <blocksize> - generates a worley fractal with X points per block";
387 resultText += "terrain seed <seed> - sets the random seed value to <seed>\n"; 389 resultText += "terrain seed <seed> - sets the random seed value to <seed>\n";
388 resultText += "terrain load <type> <filename> - loads a terrain from disk, type can be 'F32', 'F64', 'RAW' or 'IMG'\n"; 390 resultText +=
389 resultText += "terrain save <type> <filename> - saves a terrain to disk, type can be 'F32', 'F64', 'PNG', 'RAW' or 'HIRAW'\n"; 391 "terrain load <type> <filename> - loads a terrain from disk, type can be 'F32', 'F64', 'RAW' or 'IMG'\n";
390 resultText += "terrain save grdmap <filename> <gradient map> - creates a PNG snapshot of the region using a named gradient map\n"; 392 resultText +=
391 resultText += "terrain rescale <min> <max> - rescales a terrain to be between <min> and <max> meters high\n"; 393 "terrain save <type> <filename> - saves a terrain to disk, type can be 'F32', 'F64', 'PNG', 'RAW' or 'HIRAW'\n";
394 resultText +=
395 "terrain save grdmap <filename> <gradient map> - creates a PNG snapshot of the region using a named gradient map\n";
396 resultText +=
397 "terrain rescale <min> <max> - rescales a terrain to be between <min> and <max> meters high\n";
392 resultText += "terrain fill <val> - fills a terrain at the specified height\n"; 398 resultText += "terrain fill <val> - fills a terrain at the specified height\n";
393 resultText += "terrain erode aerobic <windspeed> <pickupmin> <dropmin> <carry> <rounds> <lowest t/f> <fluid dynamics t/f>\n"; 399 resultText +=
400 "terrain erode aerobic <windspeed> <pickupmin> <dropmin> <carry> <rounds> <lowest t/f> <fluid dynamics t/f>\n";
394 resultText += "terrain erode thermal <talus> <rounds> <carry>\n"; 401 resultText += "terrain erode thermal <talus> <rounds> <carry>\n";
395 resultText += "terrain erode hydraulic <rain> <evaporation> <solubility> <frequency> <rounds>\n"; 402 resultText += "terrain erode hydraulic <rain> <evaporation> <solubility> <frequency> <rounds>\n";
396 resultText += "terrain multiply <val> - multiplies a terrain by <val>\n"; 403 resultText += "terrain multiply <val> - multiplies a terrain by <val>\n";
397 resultText += "terrain revert - reverts the terrain to the stored original\n"; 404 resultText += "terrain revert - reverts the terrain to the stored original\n";
398 resultText += "terrain bake - saves the current terrain into the revert map\n"; 405 resultText += "terrain bake - saves the current terrain into the revert map\n";
399 resultText += "terrain csfilter <filename.cs> - loads a new filter from the specified .cs file\n"; 406 resultText +=
400 resultText += "terrain jsfilter <filename.js> - loads a new filter from the specified .js file\n"; 407 "terrain csfilter <filename.cs> - loads a new filter from the specified .cs file\n";
408 resultText +=
409 "terrain jsfilter <filename.js> - loads a new filter from the specified .js file\n";
401 foreach (KeyValuePair<string, ITerrainFilter> filter in customFilters.filters) 410 foreach (KeyValuePair<string, ITerrainFilter> filter in customFilters.filters)
402 { 411 {
403 resultText += filter.Value.Help(); 412 resultText += filter.Value.Help();
@@ -466,8 +475,8 @@ namespace OpenSim.Region.Terrain
466 475
467 case "load": 476 case "load":
468 string filenameL = args[2].Replace("%name%", simName); 477 string filenameL = args[2].Replace("%name%", simName);
469 filenameL = filenameL.Replace("%x%", this.offsetX.ToString()); 478 filenameL = filenameL.Replace("%x%", offsetX.ToString());
470 filenameL = filenameL.Replace("%y%", this.offsetY.ToString()); 479 filenameL = filenameL.Replace("%y%", offsetY.ToString());
471 480
472 switch (args[1].ToLower()) 481 switch (args[1].ToLower())
473 { 482 {
@@ -499,11 +508,11 @@ namespace OpenSim.Region.Terrain
499 { 508 {
500 case "f32": 509 case "f32":
501 LoadFromFileF32(args[2], Convert.ToInt32(args[3]), Convert.ToInt32(args[4]), 510 LoadFromFileF32(args[2], Convert.ToInt32(args[3]), Convert.ToInt32(args[4]),
502 Convert.ToInt32(args[5]), Convert.ToInt32(args[6])); 511 Convert.ToInt32(args[5]), Convert.ToInt32(args[6]));
503 break; 512 break;
504 case "img": 513 case "img":
505 LoadFromFileIMG(args[2], Convert.ToInt32(args[3]), Convert.ToInt32(args[4]), 514 LoadFromFileIMG(args[2], Convert.ToInt32(args[3]), Convert.ToInt32(args[4]),
506 Convert.ToInt32(args[5]), Convert.ToInt32(args[6])); 515 Convert.ToInt32(args[5]), Convert.ToInt32(args[6]));
507 break; 516 break;
508 default: 517 default:
509 resultText = "Unknown or unsupported image or data format"; 518 resultText = "Unknown or unsupported image or data format";
@@ -513,8 +522,8 @@ namespace OpenSim.Region.Terrain
513 522
514 case "save": 523 case "save":
515 string filename = args[2].Replace("%name%", simName); 524 string filename = args[2].Replace("%name%", simName);
516 filename = filename.Replace("%x%", this.offsetX.ToString()); 525 filename = filename.Replace("%x%", offsetX.ToString());
517 filename = filename.Replace("%y%", this.offsetY.ToString()); 526 filename = filename.Replace("%y%", offsetY.ToString());
518 527
519 switch (args[1].ToLower()) 528 switch (args[1].ToLower())
520 { 529 {
@@ -589,15 +598,20 @@ namespace OpenSim.Region.Terrain
589 { 598 {
590 case "aerobic": 599 case "aerobic":
591 // WindSpeed, PickupMinimum,DropMinimum,Carry,Rounds,Lowest 600 // WindSpeed, PickupMinimum,DropMinimum,Carry,Rounds,Lowest
592 heightmap.AerobicErosion(Convert.ToDouble(args[2]), Convert.ToDouble(args[3]), Convert.ToDouble(args[4]), Convert.ToDouble(args[5]), Convert.ToInt32(args[6]), Convert.ToBoolean(args[7]), Convert.ToBoolean(args[8])); 601 heightmap.AerobicErosion(Convert.ToDouble(args[2]), Convert.ToDouble(args[3]),
602 Convert.ToDouble(args[4]), Convert.ToDouble(args[5]),
603 Convert.ToInt32(args[6]), Convert.ToBoolean(args[7]),
604 Convert.ToBoolean(args[8]));
593 break; 605 break;
594 case "thermal": 606 case "thermal":
595 heightmap.ThermalWeathering(Convert.ToDouble(args[2]), Convert.ToInt32(args[3]), Convert.ToDouble(args[4])); 607 heightmap.ThermalWeathering(Convert.ToDouble(args[2]), Convert.ToInt32(args[3]),
608 Convert.ToDouble(args[4]));
596 break; 609 break;
597 case "hydraulic": 610 case "hydraulic":
598 Channel rainMap = new Channel(w, h); 611 Channel rainMap = new Channel(w, h);
599 rainMap.Fill(Convert.ToDouble(args[2])); 612 rainMap.Fill(Convert.ToDouble(args[2]));
600 heightmap.HydraulicErosion(rainMap, Convert.ToDouble(args[3]), Convert.ToDouble(args[4]), Convert.ToInt32(args[5]), Convert.ToInt32(args[6])); 613 heightmap.HydraulicErosion(rainMap, Convert.ToDouble(args[3]), Convert.ToDouble(args[4]),
614 Convert.ToInt32(args[5]), Convert.ToInt32(args[6]));
601 break; 615 break;
602 default: 616 default:
603 resultText = "Unknown erosion type"; 617 resultText = "Unknown erosion type";
@@ -624,8 +638,10 @@ namespace OpenSim.Region.Terrain
624 if (args.GetLength(0) > 2) 638 if (args.GetLength(0) > 2)
625 { 639 {
626 int.TryParse(args[2].ToString(), out count); 640 int.TryParse(args[2].ToString(), out count);
627 double.TryParse(args[3].ToString(), NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo, out sizeMin); 641 double.TryParse(args[3].ToString(), NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo,
628 double.TryParse(args[4].ToString(), NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo, out sizeRange); 642 out sizeMin);
643 double.TryParse(args[4].ToString(), NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo,
644 out sizeRange);
629 bool.TryParse(args[5].ToString(), out island); 645 bool.TryParse(args[5].ToString(), out island);
630 bool.TryParse(args[6].ToString(), out additive); 646 bool.TryParse(args[6].ToString(), out additive);
631 bool.TryParse(args[7].ToString(), out noisy); 647 bool.TryParse(args[7].ToString(), out noisy);
@@ -669,7 +685,7 @@ namespace OpenSim.Region.Terrain
669 /// <param name="max">Maximum value of the new array</param> 685 /// <param name="max">Maximum value of the new array</param>
670 public void SetRange(float min, float max) 686 public void SetRange(float min, float max)
671 { 687 {
672 heightmap.Normalise((double)min, (double)max); 688 heightmap.Normalise((double) min, (double) max);
673 tainted++; 689 tainted++;
674 } 690 }
675 691
@@ -713,7 +729,7 @@ namespace OpenSim.Region.Terrain
713 { 729 {
714 for (x = 0; x < w; x++) 730 for (x = 0; x < w; x++)
715 { 731 {
716 heightmap.map[x, y] = (double)bs.ReadSingle(); 732 heightmap.map[x, y] = (double) bs.ReadSingle();
717 } 733 }
718 } 734 }
719 735
@@ -736,11 +752,10 @@ namespace OpenSim.Region.Terrain
736 fileIOLock.WaitOne(); 752 fileIOLock.WaitOne();
737 try 753 try
738 { 754 {
755 int sectionToLoadX = ((offsetX - lowerboundX)*w);
756 int sectionToLoadY = ((offsetY - lowerboundY)*h);
739 757
740 int sectionToLoadX = ((this.offsetX - lowerboundX) * this.w); 758 double[,] tempMap = new double[dimensionX,dimensionY];
741 int sectionToLoadY = ((this.offsetY - lowerboundY) * this.h);
742
743 double[,] tempMap = new double[dimensionX, dimensionY];
744 759
745 FileInfo file = new FileInfo(filename); 760 FileInfo file = new FileInfo(filename);
746 FileStream s = file.Open(FileMode.Open, FileAccess.Read); 761 FileStream s = file.Open(FileMode.Open, FileAccess.Read);
@@ -751,7 +766,7 @@ namespace OpenSim.Region.Terrain
751 { 766 {
752 for (y = 0; y < dimensionY; y++) 767 for (y = 0; y < dimensionY; y++)
753 { 768 {
754 tempMap[x, y] = (double)bs.ReadSingle(); 769 tempMap[x, y] = (double) bs.ReadSingle();
755 } 770 }
756 } 771 }
757 772
@@ -784,19 +799,19 @@ namespace OpenSim.Region.Terrain
784 /// <param name="lowerboundY">Where sim coords begin for this patch</param> 799 /// <param name="lowerboundY">Where sim coords begin for this patch</param>
785 public void LoadFromFileIMG(string filename, int dimensionX, int dimensionY, int lowerboundX, int lowerboundY) 800 public void LoadFromFileIMG(string filename, int dimensionX, int dimensionY, int lowerboundX, int lowerboundY)
786 { 801 {
787 int sectionToLoadX = ((this.offsetX - lowerboundX) * this.w); 802 int sectionToLoadX = ((offsetX - lowerboundX)*w);
788 int sectionToLoadY = ((this.offsetY - lowerboundY) * this.h); 803 int sectionToLoadY = ((offsetY - lowerboundY)*h);
789 804
790 double[,] tempMap = new double[dimensionX, dimensionY]; 805 double[,] tempMap = new double[dimensionX,dimensionY];
791 806
792 System.Drawing.Bitmap lgrBmp = new Bitmap(filename); 807 Bitmap lgrBmp = new Bitmap(filename);
793 808
794 int x, y; 809 int x, y;
795 for (x = 0; x < dimensionX; x++) 810 for (x = 0; x < dimensionX; x++)
796 { 811 {
797 for (y = 0; y < dimensionY; y++) 812 for (y = 0; y < dimensionY; y++)
798 { 813 {
799 tempMap[x, y] = (float)lgrBmp.GetPixel(x, y).GetBrightness(); 814 tempMap[x, y] = (float) lgrBmp.GetPixel(x, y).GetBrightness();
800 } 815 }
801 } 816 }
802 817
@@ -826,7 +841,7 @@ namespace OpenSim.Region.Terrain
826 { 841 {
827 for (x = 0; x < w; x++) 842 for (x = 0; x < w; x++)
828 { 843 {
829 heightmap.map[x, y] = (double)bs.ReadByte() * ((double)bs.ReadByte() / 127.0); 844 heightmap.map[x, y] = (double) bs.ReadByte()*((double) bs.ReadByte()/127.0);
830 bs.ReadBytes(11); // Advance the stream to next bytes. 845 bs.ReadBytes(11); // Advance the stream to next bytes.
831 } 846 }
832 } 847 }
@@ -875,7 +890,7 @@ namespace OpenSim.Region.Terrain
875 { 890 {
876 for (x = 0; x < w; x++) 891 for (x = 0; x < w; x++)
877 { 892 {
878 bs.Write((float)heightmap.Get(x, y)); 893 bs.Write((float) heightmap.Get(x, y));
879 } 894 }
880 } 895 }
881 896
@@ -897,27 +912,27 @@ namespace OpenSim.Region.Terrain
897 int x, y; 912 int x, y;
898 913
899 // Used for the 'green' channel. 914 // Used for the 'green' channel.
900 byte avgMultiplier = (byte)heightmap.Avg(); 915 byte avgMultiplier = (byte) heightmap.Avg();
901 byte backupMultiplier = (byte)revertmap.Avg(); 916 byte backupMultiplier = (byte) revertmap.Avg();
902 917
903 // Limit the multiplier so it can represent points >64m. 918 // Limit the multiplier so it can represent points >64m.
904 if (avgMultiplier > 196) 919 if (avgMultiplier > 196)
905 avgMultiplier = 196; 920 avgMultiplier = 196;
906 if(backupMultiplier > 196) 921 if (backupMultiplier > 196)
907 backupMultiplier = 196; 922 backupMultiplier = 196;
908 // Make sure it's at least one to prevent a div by zero 923 // Make sure it's at least one to prevent a div by zero
909 if (avgMultiplier < 1) 924 if (avgMultiplier < 1)
910 avgMultiplier = 1; 925 avgMultiplier = 1;
911 if(backupMultiplier < 1) 926 if (backupMultiplier < 1)
912 backupMultiplier = 1; 927 backupMultiplier = 1;
913 928
914 for (y = 0; y < h; y++) 929 for (y = 0; y < h; y++)
915 { 930 {
916 for (x = 0; x < h; x++) 931 for (x = 0; x < h; x++)
917 { 932 {
918 byte red = (byte)(heightmap.Get(x, y) / ((double)avgMultiplier / 128.0)); 933 byte red = (byte) (heightmap.Get(x, y)/((double) avgMultiplier/128.0));
919 byte green = avgMultiplier; 934 byte green = avgMultiplier;
920 byte blue = (byte)watermap.Get(x, y); 935 byte blue = (byte) watermap.Get(x, y);
921 byte alpha1 = 0; // Land Parcels 936 byte alpha1 = 0; // Land Parcels
922 byte alpha2 = 0; // For Sale Land 937 byte alpha2 = 0; // For Sale Land
923 byte alpha3 = 0; // Public Edit Object 938 byte alpha3 = 0; // Public Edit Object
@@ -926,7 +941,7 @@ namespace OpenSim.Region.Terrain
926 byte alpha6 = 255; // Flying Allowed 941 byte alpha6 = 255; // Flying Allowed
927 byte alpha7 = 255; // Create Landmark 942 byte alpha7 = 255; // Create Landmark
928 byte alpha8 = 255; // Outside Scripts 943 byte alpha8 = 255; // Outside Scripts
929 byte alpha9 = (byte)(revertmap.Get(x, y) / ((double)backupMultiplier / 128.0)); 944 byte alpha9 = (byte) (revertmap.Get(x, y)/((double) backupMultiplier/128.0));
930 byte alpha10 = backupMultiplier; 945 byte alpha10 = backupMultiplier;
931 946
932 binStream.Write(red); 947 binStream.Write(red);
@@ -966,7 +981,7 @@ namespace OpenSim.Region.Terrain
966 { 981 {
967 for (j = 0; j < 256; j++) 982 for (j = 0; j < 256; j++)
968 { 983 {
969 lookupHeightTable[i + (j * 256)] = ((double)i * ((double)j / 127.0)); 984 lookupHeightTable[i + (j*256)] = ((double) i*((double) j/127.0));
970 } 985 }
971 } 986 }
972 987
@@ -988,9 +1003,9 @@ namespace OpenSim.Region.Terrain
988 } 1003 }
989 } 1004 }
990 1005
991 byte red = (byte)(index & 0xFF); 1006 byte red = (byte) (index & 0xFF);
992 byte green = (byte)((index >> 8) & 0xFF); 1007 byte green = (byte) ((index >> 8) & 0xFF);
993 byte blue = (byte)watermap.Get(x, y); 1008 byte blue = (byte) watermap.Get(x, y);
994 byte alpha1 = 0; // Land Parcels 1009 byte alpha1 = 0; // Land Parcels
995 byte alpha2 = 0; // For Sale Land 1010 byte alpha2 = 0; // For Sale Land
996 byte alpha3 = 0; // Public Edit Object 1011 byte alpha3 = 0; // Public Edit Object
@@ -1140,7 +1155,7 @@ namespace OpenSim.Region.Terrain
1140 smoothed.Smooth(amount); 1155 smoothed.Smooth(amount);
1141 1156
1142 Channel mask = new Channel(); 1157 Channel mask = new Channel();
1143 mask.Raise(rx,ry,size,amount); 1158 mask.Raise(rx, ry, size, amount);
1144 1159
1145 heightmap.Blend(smoothed, mask); 1160 heightmap.Blend(smoothed, mask);
1146 } 1161 }
@@ -1221,8 +1236,7 @@ namespace OpenSim.Region.Terrain
1221 { 1236 {
1222 Bitmap bmp = TerrainToBitmap(gradientmap); 1237 Bitmap bmp = TerrainToBitmap(gradientmap);
1223 1238
1224 imageData = OpenJPEG.EncodeFromImage(bmp, true ); 1239 imageData = OpenJPEG.EncodeFromImage(bmp, true);
1225
1226 } 1240 }
1227 catch (Exception e) 1241 catch (Exception e)
1228 { 1242 {
@@ -1252,12 +1266,11 @@ namespace OpenSim.Region.Terrain
1252 for (int x = 0; x < copy.w; x++) 1266 for (int x = 0; x < copy.w; x++)
1253 { 1267 {
1254 // 512 is the largest possible height before colours clamp 1268 // 512 is the largest possible height before colours clamp
1255 int colorindex = (int)(Math.Max(Math.Min(1.0, copy.Get(x, y) / 512.0), 0.0) * (pallete - 1)); 1269 int colorindex = (int) (Math.Max(Math.Min(1.0, copy.Get(x, y)/512.0), 0.0)*(pallete - 1));
1256 bmp.SetPixel(x, y, colours[colorindex]); 1270 bmp.SetPixel(x, y, colours[colorindex]);
1257 } 1271 }
1258 } 1272 }
1259 return bmp; 1273 return bmp;
1260 } 1274 }
1261
1262 } 1275 }
1263} 1276} \ No newline at end of file
diff --git a/OpenSim/Region/Terrain.BasicTerrain/TerrainFilter.cs b/OpenSim/Region/Terrain.BasicTerrain/TerrainFilter.cs
index 2ae55f0..8c29c6a 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/TerrainFilter.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainFilter.cs
@@ -87,11 +87,12 @@ namespace OpenSim.Region.Terrain
87 { 87 {
88 foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes()) 88 foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes())
89 { 89 {
90 Type testInterface = pluginType.GetInterface("ITerrainFilter",true); 90 Type testInterface = pluginType.GetInterface("ITerrainFilter", true);
91 91
92 if (testInterface != null) 92 if (testInterface != null)
93 { 93 {
94 ITerrainFilter filter = (ITerrainFilter)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString()); 94 ITerrainFilter filter =
95 (ITerrainFilter) compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString());
95 96
96 string filterName = filter.Register(); 97 string filterName = filter.Register();
97 Console.WriteLine("Plugin: " + filterName + " loaded."); 98 Console.WriteLine("Plugin: " + filterName + " loaded.");
@@ -107,7 +108,6 @@ namespace OpenSim.Region.Terrain
107 } 108 }
108 } 109 }
109 } 110 }
110
111 } 111 }
112 112
113 public void LoadFilterCSharp(string filename) 113 public void LoadFilterCSharp(string filename)
@@ -122,4 +122,4 @@ namespace OpenSim.Region.Terrain
122 LoadFilter(compiler, filename); 122 LoadFilter(compiler, filename);
123 } 123 }
124 } 124 }
125} 125} \ No newline at end of file
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Bitmap/Bitmap.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Bitmap/Bitmap.cs
index 8359f8e..8b5fbed 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Bitmap/Bitmap.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Bitmap/Bitmap.cs
@@ -26,18 +26,16 @@
26* 26*
27*/ 27*/
28 28
29using System;
30using System.Collections.Generic;
31using System.Text;
32using System.Drawing; 29using System.Drawing;
30using System.Drawing.Imaging;
33 31
34namespace libTerrain 32namespace libTerrain
35{ 33{
36 class Raster 34 internal class Raster
37 { 35 {
38 int w; 36 private int w;
39 int h; 37 private int h;
40 Bitmap bmp; 38 private Bitmap bmp;
41 39
42 /// <summary> 40 /// <summary>
43 /// Creates a new Raster channel for use with bitmap or GDI functions 41 /// Creates a new Raster channel for use with bitmap or GDI functions
@@ -48,7 +46,7 @@ namespace libTerrain
48 { 46 {
49 w = width; 47 w = width;
50 h = height; 48 h = height;
51 bmp = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); 49 bmp = new Bitmap(width, height, PixelFormat.Format24bppRgb);
52 } 50 }
53 51
54 /// <summary> 52 /// <summary>
@@ -65,7 +63,7 @@ namespace libTerrain
65 for (y = 0; y < bmp.Height; y++) 63 for (y = 0; y < bmp.Height; y++)
66 { 64 {
67 Color val = bmp.GetPixel(x, y); 65 Color val = bmp.GetPixel(x, y);
68 chan.map[x, y] = (((double)val.R + (double)val.G + (double)val.B) / 3.0) / 255.0; 66 chan.map[x, y] = (((double) val.R + (double) val.G + (double) val.B)/3.0)/255.0;
69 } 67 }
70 } 68 }
71 69
@@ -86,7 +84,7 @@ namespace libTerrain
86 sf.LineAlignment = StringAlignment.Center; 84 sf.LineAlignment = StringAlignment.Center;
87 85
88 Graphics gd = Graphics.FromImage(bmp); 86 Graphics gd = Graphics.FromImage(bmp);
89 gd.DrawString(txt, new Font(font, (float)size), new SolidBrush(Color.White), area, sf); 87 gd.DrawString(txt, new Font(font, (float) size), new SolidBrush(Color.White), area, sf);
90 } 88 }
91 } 89 }
92} 90} \ No newline at end of file
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Channel.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Channel.cs
index 093bfb1..4cb70c2 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Channel.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Channel.cs
@@ -26,12 +26,7 @@
26* 26*
27*/ 27*/
28 28
29using System; 29 /* Channel
30using System.Collections.Generic;
31using System.Text;
32
33
34/* Channel
35 * A channel is a single heightmap array 30 * A channel is a single heightmap array
36 * */ 31 * */
37 32
@@ -50,17 +45,16 @@ namespace libTerrain
50 { 45 {
51 w = 256; 46 w = 256;
52 h = 256; 47 h = 256;
53 map = new double[w, h]; 48 map = new double[w,h];
54 diff = new int[(int)(w / 16), (int)(h / 16)]; 49 diff = new int[(int) (w/16),(int) (h/16)];
55 } 50 }
56 51
57 public Channel(int width, int height) 52 public Channel(int width, int height)
58 { 53 {
59 w = width; 54 w = width;
60 h = height; 55 h = height;
61 map = new double[w, h]; 56 map = new double[w,h];
62 diff = new int[(int)(w / 16), (int)(h / 16)]; 57 diff = new int[(int) (w/16),(int) (h/16)];
63 } 58 }
64
65 } 59 }
66} 60} \ No newline at end of file
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Common.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Common.cs
index 730f206..2ad784b 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Common.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Common.cs
@@ -28,8 +28,6 @@
28 28
29 29
30using System; 30using System;
31using System.Collections.Generic;
32using System.Text;
33 31
34namespace libTerrain 32namespace libTerrain
35{ 33{
@@ -39,6 +37,7 @@ namespace libTerrain
39 { 37 {
40 return w; 38 return w;
41 } 39 }
40
42 public int GetHeight() 41 public int GetHeight()
43 { 42 {
44 return h; 43 return h;
@@ -47,7 +46,7 @@ namespace libTerrain
47 public Channel Copy() 46 public Channel Copy()
48 { 47 {
49 Channel x = new Channel(w, h); 48 Channel x = new Channel(w, h);
50 x.map = (double[,])this.map.Clone(); 49 x.map = (double[,]) map.Clone();
51 return x; 50 return x;
52 } 51 }
53 52
@@ -58,9 +57,9 @@ namespace libTerrain
58 57
59 public void SetDiff(int val) 58 public void SetDiff(int val)
60 { 59 {
61 for (int x = 0; x < w / 16; x++) 60 for (int x = 0; x < w/16; x++)
62 { 61 {
63 for (int y = 0; y < h / 16; y++) 62 for (int y = 0; y < h/16; y++)
64 { 63 {
65 diff[x, y] = val; 64 diff[x, y] = val;
66 } 65 }
@@ -69,7 +68,7 @@ namespace libTerrain
69 68
70 public void SetDiff(int x, int y) 69 public void SetDiff(int x, int y)
71 { 70 {
72 diff[x / 16, y / 16]++; 71 diff[x/16, y/16]++;
73 } 72 }
74 73
75 public void Set(int x, int y, double val) 74 public void Set(int x, int y, double val)
@@ -124,10 +123,10 @@ namespace libTerrain
124 y = 0.0; 123 y = 0.0;
125 124
126 int stepSize = 1; 125 int stepSize = 1;
127 double h00 = Get((int)x, (int)y); 126 double h00 = Get((int) x, (int) y);
128 double h10 = Get((int)x + stepSize, (int)y); 127 double h10 = Get((int) x + stepSize, (int) y);
129 double h01 = Get((int)x, (int)y + stepSize); 128 double h01 = Get((int) x, (int) y + stepSize);
130 double h11 = Get((int)x + stepSize, (int)y + stepSize); 129 double h11 = Get((int) x + stepSize, (int) y + stepSize);
131 double h1 = h00; 130 double h1 = h00;
132 double h2 = h10; 131 double h2 = h10;
133 double h3 = h01; 132 double h3 = h01;
@@ -136,9 +135,9 @@ namespace libTerrain
136 double a10 = h2 - h1; 135 double a10 = h2 - h1;
137 double a01 = h3 - h1; 136 double a01 = h3 - h1;
138 double a11 = h1 - h2 - h3 + h4; 137 double a11 = h1 - h2 - h3 + h4;
139 double partialx = x - (int)x; 138 double partialx = x - (int) x;
140 double partialz = y - (int)y; 139 double partialz = y - (int) y;
141 double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz); 140 double hi = a00 + (a10*partialx) + (a01*partialz) + (a11*partialx*partialz);
142 return hi; 141 return hi;
143 } 142 }
144 143
@@ -159,7 +158,7 @@ namespace libTerrain
159 { 158 {
160 SetDiff(x, y); 159 SetDiff(x, y);
161 160
162 map[x % w, y % h] = val; 161 map[x%w, y%h] = val;
163 } 162 }
164 163
165 public void SetWrapClip(int x, int y, double val) 164 public void SetWrapClip(int x, int y, double val)
@@ -171,7 +170,7 @@ namespace libTerrain
171 if (val < 0.0) 170 if (val < 0.0)
172 val = 0.0; 171 val = 0.0;
173 172
174 map[x % w, y % h] = val; 173 map[x%w, y%h] = val;
175 } 174 }
176 175
177 public void Fill(double val) 176 public void Fill(double val)
@@ -255,7 +254,7 @@ namespace libTerrain
255 254
256 public double Avg() 255 public double Avg()
257 { 256 {
258 return Sum() / (w * h); 257 return Sum()/(w*h);
259 } 258 }
260 259
261 public bool ContainsNaN() 260 public bool ContainsNaN()
@@ -274,4 +273,4 @@ namespace libTerrain
274 return false; 273 return false;
275 } 274 }
276 } 275 }
277} 276} \ No newline at end of file
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs
index 45bb06b..e753847 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs
@@ -28,8 +28,6 @@
28 28
29 29
30using System; 30using System;
31using System.Collections.Generic;
32using System.Text;
33 31
34namespace libTerrain 32namespace libTerrain
35{ 33{
@@ -58,12 +56,12 @@ namespace libTerrain
58 56
59 // Establish the average height under the area 57 // Establish the average height under the area
60 Channel newmap = new Channel(w, h); 58 Channel newmap = new Channel(w, h);
61 newmap.map = (double[,])map.Clone(); 59 newmap.map = (double[,]) map.Clone();
62 60
63 newmap *= temp; 61 newmap *= temp;
64 62
65 double total_terrain = newmap.Sum(); 63 double total_terrain = newmap.Sum();
66 double avg_height = total_terrain / total_mod; 64 double avg_height = total_terrain/total_mod;
67 65
68 // Create a flat terrain using the average height 66 // Create a flat terrain using the average height
69 Channel flat = new Channel(w, h); 67 Channel flat = new Channel(w, h);
@@ -72,7 +70,6 @@ namespace libTerrain
72 // Blend the current terrain with the average height terrain 70 // Blend the current terrain with the average height terrain
73 // using the "raised" empty terrain as a mask 71 // using the "raised" empty terrain as a mask
74 Blend(flat, temp); 72 Blend(flat, temp);
75
76 } 73 }
77 74
78 private void FlattenFast(double rx, double ry, double size, double amount) 75 private void FlattenFast(double rx, double ry, double size, double amount)
@@ -81,10 +78,10 @@ namespace libTerrain
81 double avg = 0; 78 double avg = 0;
82 double div = 0; 79 double div = 0;
83 80
84 int minX = Math.Max(0, (int)(rx - (size + 1))); 81 int minX = Math.Max(0, (int) (rx - (size + 1)));
85 int maxX = Math.Min(w, (int)(rx + (size + 1))); 82 int maxX = Math.Min(w, (int) (rx + (size + 1)));
86 int minY = Math.Max(0, (int)(ry - (size + 1))); 83 int minY = Math.Max(0, (int) (ry - (size + 1)));
87 int maxY = Math.Min(h, (int)(ry + (size + 1))); 84 int maxY = Math.Min(h, (int) (ry + (size + 1)));
88 85
89 for (x = minX; x < maxX; x++) 86 for (x = minX; x < maxX; x++)
90 { 87 {
@@ -92,17 +89,17 @@ namespace libTerrain
92 { 89 {
93 double z = size; 90 double z = size;
94 z *= z; 91 z *= z;
95 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); 92 z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry));
96 93
97 if (z < 0) 94 if (z < 0)
98 z = 0; 95 z = 0;
99 96
100 avg += z * amount; 97 avg += z*amount;
101 div += z; 98 div += z;
102 } 99 }
103 } 100 }
104 101
105 double height = avg / div; 102 double height = avg/div;
106 103
107 for (x = minX; x < maxX; x++) 104 for (x = minX; x < maxX; x++)
108 { 105 {
@@ -110,7 +107,7 @@ namespace libTerrain
110 { 107 {
111 double z = size; 108 double z = size;
112 z *= z; 109 z *= z;
113 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); 110 z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry));
114 111
115 if (z < 0) 112 if (z < 0)
116 z = 0; 113 z = 0;
@@ -123,19 +120,19 @@ namespace libTerrain
123 public void Flatten(Channel mask, double amount) 120 public void Flatten(Channel mask, double amount)
124 { 121 {
125 // Generate the mask 122 // Generate the mask
126 Channel temp = mask * amount; 123 Channel temp = mask*amount;
127 temp.Clip(0, 1); // Cut off out-of-bounds values 124 temp.Clip(0, 1); // Cut off out-of-bounds values
128 125
129 double total_mod = temp.Sum(); 126 double total_mod = temp.Sum();
130 127
131 // Establish the average height under the area 128 // Establish the average height under the area
132 Channel map = new Channel(w, h); 129 Channel map = new Channel(w, h);
133 map.map = (double[,])this.map.Clone(); 130 map.map = (double[,]) this.map.Clone();
134 131
135 map *= temp; 132 map *= temp;
136 133
137 double total_terrain = map.Sum(); 134 double total_terrain = map.Sum();
138 double avg_height = total_terrain / total_mod; 135 double avg_height = total_terrain/total_mod;
139 136
140 // Create a flat terrain using the average height 137 // Create a flat terrain using the average height
141 Channel flat = new Channel(w, h); 138 Channel flat = new Channel(w, h);
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs
index 15631df..9e8f3a4 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs
@@ -28,8 +28,6 @@
28 28
29 29
30using System; 30using System;
31using System.Collections.Generic;
32using System.Text;
33 31
34namespace libTerrain 32namespace libTerrain
35{ 33{
@@ -63,12 +61,12 @@ namespace libTerrain
63 { 61 {
64 double z = size; 62 double z = size;
65 z *= z; 63 z *= z;
66 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); 64 z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry));
67 65
68 if (z < 0) 66 if (z < 0)
69 z = 0; 67 z = 0;
70 68
71 Set(x, y, map[x, y] + (z * amount)); 69 Set(x, y, map[x, y] + (z*amount));
72 } 70 }
73 } 71 }
74 } 72 }
@@ -88,12 +86,12 @@ namespace libTerrain
88 for (y = 0; y < h; y++) 86 for (y = 0; y < h; y++)
89 { 87 {
90 double z = size; 88 double z = size;
91 z -= Math.Sqrt(((x - rx) * (x - rx)) + ((y - ry) * (y - ry))); 89 z -= Math.Sqrt(((x - rx)*(x - rx)) + ((y - ry)*(y - ry)));
92 90
93 if (z < 0) 91 if (z < 0)
94 z = 0; 92 z = 0;
95 93
96 Set(x, y, map[x, y] + (z * amount)); 94 Set(x, y, map[x, y] + (z*amount));
97 } 95 }
98 } 96 }
99 } 97 }
@@ -126,12 +124,12 @@ namespace libTerrain
126 { 124 {
127 double z = size; 125 double z = size;
128 z *= z; 126 z *= z;
129 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); 127 z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry));
130 128
131 if (z < 0) 129 if (z < 0)
132 z = 0; 130 z = 0;
133 131
134 Set(x, y, map[x, y] - (z * amount)); 132 Set(x, y, map[x, y] - (z*amount));
135 } 133 }
136 } 134 }
137 } 135 }
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/File.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/File.cs
index 5949759..b4eda47 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/File.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/File.cs
@@ -27,9 +27,8 @@
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic;
31using System.Text;
32using System.Drawing; 30using System.Drawing;
31using System.Drawing.Imaging;
33 32
34namespace libTerrain 33namespace libTerrain
35{ 34{
@@ -48,7 +47,7 @@ namespace libTerrain
48 for (y = 0; y < bit.Height; y++) 47 for (y = 0; y < bit.Height; y++)
49 { 48 {
50 Color val = bit.GetPixel(x, y); 49 Color val = bit.GetPixel(x, y);
51 chan.map[x, y] = (((double)val.R + (double)val.G + (double)val.B) / 3.0) / 255.0; 50 chan.map[x, y] = (((double) val.R + (double) val.G + (double) val.B)/3.0)/255.0;
52 } 51 }
53 } 52 }
54 53
@@ -57,21 +56,21 @@ namespace libTerrain
57 56
58 public void SaveImage(string filename) 57 public void SaveImage(string filename)
59 { 58 {
60 Channel outmap = this.Copy(); 59 Channel outmap = Copy();
61 outmap.Normalise(); 60 outmap.Normalise();
62 61
63 Bitmap bit = new Bitmap(w, h, System.Drawing.Imaging.PixelFormat.Format24bppRgb); 62 Bitmap bit = new Bitmap(w, h, PixelFormat.Format24bppRgb);
64 int x, y; 63 int x, y;
65 for (x = 0; x < w; x++) 64 for (x = 0; x < w; x++)
66 { 65 {
67 for (y = 0; y < h; y++) 66 for (y = 0; y < h; y++)
68 { 67 {
69 int val = Math.Min(255, (int)(outmap.map[x,y] * 255)); 68 int val = Math.Min(255, (int) (outmap.map[x, y]*255));
70 Color col = Color.FromArgb(val,val,val); 69 Color col = Color.FromArgb(val, val, val);
71 bit.SetPixel(x, y, col); 70 bit.SetPixel(x, y, col);
72 } 71 }
73 } 72 }
74 bit.Save(filename); 73 bit.Save(filename);
75 } 74 }
76 } 75 }
77} 76} \ No newline at end of file
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs
index 3a9b7f7..65badd1 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs
@@ -27,8 +27,6 @@
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic;
31using System.Text;
32 30
33namespace libTerrain 31namespace libTerrain
34{ 32{
@@ -60,19 +58,19 @@ namespace libTerrain
60 } 58 }
61 if (val < 512) 59 if (val < 512)
62 { 60 {
63 ret[0] = (val % 256); 61 ret[0] = (val%256);
64 ret[1] = 255; 62 ret[1] = 255;
65 return ret; 63 return ret;
66 } 64 }
67 if (val < 768) 65 if (val < 768)
68 { 66 {
69 ret[0] = 255; 67 ret[0] = 255;
70 ret[1] = 255 - (val % 256); 68 ret[1] = 255 - (val%256);
71 return ret; 69 return ret;
72 } 70 }
73 if (val < 1024) 71 if (val < 1024)
74 { 72 {
75 ret[0] = 255 - (val % 256); 73 ret[0] = 255 - (val%256);
76 ret[1] = 255; 74 ret[1] = 255;
77 return ret; 75 return ret;
78 } 76 }
@@ -100,7 +98,7 @@ namespace libTerrain
100 { 98 {
101 for (int y = 0; y < h; y++) 99 for (int y = 0; y < h; y++)
102 { 100 {
103 double miny = Tools.LinearInterpolate(a[1], b[1], (double)x / (double)w); 101 double miny = Tools.LinearInterpolate(a[1], b[1], (double) x/(double) w);
104 102
105 if (v >= 0.5) 103 if (v >= 0.5)
106 { 104 {
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Gradient.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Gradient.cs
index 8a1b048..b6e2491 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Gradient.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Gradient.cs
@@ -26,15 +26,10 @@
26* 26*
27*/ 27*/
28 28
29using System;
30using System.Collections.Generic;
31using System.Text;
32
33namespace libTerrain 29namespace libTerrain
34{ 30{
35 partial class Channel 31 partial class Channel
36 { 32 {
37
38 public void GradientCube() 33 public void GradientCube()
39 { 34 {
40 SetDiff(); 35 SetDiff();
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs
index 7cea800..6806748 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs
@@ -27,8 +27,6 @@
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic;
31using System.Text;
32 30
33namespace libTerrain 31namespace libTerrain
34{ 32{
@@ -44,7 +42,8 @@ namespace libTerrain
44 /// <param name="island">Whether to bias hills towards the center of the map</param> 42 /// <param name="island">Whether to bias hills towards the center of the map</param>
45 /// <param name="additive">Whether to add hills together or to pick the largest value</param> 43 /// <param name="additive">Whether to add hills together or to pick the largest value</param>
46 /// <param name="noisy">Generates hill-shaped noise instead of consistent hills</param> 44 /// <param name="noisy">Generates hill-shaped noise instead of consistent hills</param>
47 public void HillsSpheres(int number, double scale_min, double scale_range, bool island, bool additive, bool noisy) 45 public void HillsSpheres(int number, double scale_min, double scale_range, bool island, bool additive,
46 bool noisy)
48 { 47 {
49 SetDiff(); 48 SetDiff();
50 49
@@ -55,20 +54,20 @@ namespace libTerrain
55 54
56 for (i = 0; i < number; i++) 55 for (i = 0; i < number; i++)
57 { 56 {
58 double rx = Math.Min(255.0, random.NextDouble() * w); 57 double rx = Math.Min(255.0, random.NextDouble()*w);
59 double ry = Math.Min(255.0, random.NextDouble() * h); 58 double ry = Math.Min(255.0, random.NextDouble()*h);
60 double rand = random.NextDouble(); 59 double rand = random.NextDouble();
61 60
62 if (island) 61 if (island)
63 { 62 {
64 // Move everything towards the center 63 // Move everything towards the center
65 rx -= w / 2; 64 rx -= w/2;
66 rx /= 2; 65 rx /= 2;
67 rx += w / 2; 66 rx += w/2;
68 67
69 ry -= h / 2; 68 ry -= h/2;
70 ry /= 2; 69 ry /= 2;
71 ry += h / 2; 70 ry += h/2;
72 } 71 }
73 72
74 for (x = 0; x < w; x++) 73 for (x = 0; x < w; x++)
@@ -78,9 +77,9 @@ namespace libTerrain
78 if (noisy) 77 if (noisy)
79 rand = random.NextDouble(); 78 rand = random.NextDouble();
80 79
81 double z = (scale_min + (scale_range * rand)); 80 double z = (scale_min + (scale_range*rand));
82 z *= z; 81 z *= z;
83 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); 82 z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry));
84 83
85 if (z < 0) 84 if (z < 0)
86 z = 0; 85 z = 0;
@@ -121,20 +120,20 @@ namespace libTerrain
121 120
122 for (i = 0; i < number; i++) 121 for (i = 0; i < number; i++)
123 { 122 {
124 double rx = Math.Min(255.0, random.NextDouble() * w); 123 double rx = Math.Min(255.0, random.NextDouble()*w);
125 double ry = Math.Min(255.0, random.NextDouble() * h); 124 double ry = Math.Min(255.0, random.NextDouble()*h);
126 double rand = random.NextDouble(); 125 double rand = random.NextDouble();
127 126
128 if (island) 127 if (island)
129 { 128 {
130 // Move everything towards the center 129 // Move everything towards the center
131 rx -= w / 2; 130 rx -= w/2;
132 rx /= 2; 131 rx /= 2;
133 rx += w / 2; 132 rx += w/2;
134 133
135 ry -= h / 2; 134 ry -= h/2;
136 ry /= 2; 135 ry /= 2;
137 ry += h / 2; 136 ry += h/2;
138 } 137 }
139 138
140 for (x = 0; x < w; x++) 139 for (x = 0; x < w; x++)
@@ -144,8 +143,8 @@ namespace libTerrain
144 if (noisy) 143 if (noisy)
145 rand = random.NextDouble(); 144 rand = random.NextDouble();
146 145
147 double z = (scale_min + (scale_range * rand)); 146 double z = (scale_min + (scale_range*rand));
148 z -= Math.Sqrt(((x - rx) * (x - rx)) + ((y - ry) * (y - ry))); 147 z -= Math.Sqrt(((x - rx)*(x - rx)) + ((y - ry)*(y - ry)));
149 148
150 if (z < 0) 149 if (z < 0)
151 z = 0; 150 z = 0;
@@ -176,20 +175,20 @@ namespace libTerrain
176 175
177 for (i = 0; i < number; i++) 176 for (i = 0; i < number; i++)
178 { 177 {
179 double rx = Math.Min(255.0, random.NextDouble() * w); 178 double rx = Math.Min(255.0, random.NextDouble()*w);
180 double ry = Math.Min(255.0, random.NextDouble() * h); 179 double ry = Math.Min(255.0, random.NextDouble()*h);
181 double rand = random.NextDouble(); 180 double rand = random.NextDouble();
182 181
183 if (island) 182 if (island)
184 { 183 {
185 // Move everything towards the center 184 // Move everything towards the center
186 rx -= w / 2; 185 rx -= w/2;
187 rx /= 2; 186 rx /= 2;
188 rx += w / 2; 187 rx += w/2;
189 188
190 ry -= h / 2; 189 ry -= h/2;
191 ry /= 2; 190 ry /= 2;
192 ry += h / 2; 191 ry += h/2;
193 } 192 }
194 193
195 for (x = 0; x < w; x++) 194 for (x = 0; x < w; x++)
@@ -199,8 +198,8 @@ namespace libTerrain
199 if (noisy) 198 if (noisy)
200 rand = random.NextDouble(); 199 rand = random.NextDouble();
201 200
202 double z = (scale_min + (scale_range * rand)); 201 double z = (scale_min + (scale_range*rand));
203 z -= Math.Abs(x-rx) + Math.Abs(y-ry); 202 z -= Math.Abs(x - rx) + Math.Abs(y - ry);
204 //z -= Math.Sqrt(((x - rx) * (x - rx)) + ((y - ry) * (y - ry))); 203 //z -= Math.Sqrt(((x - rx) * (x - rx)) + ((y - ry) * (y - ry)));
205 204
206 if (z < 0) 205 if (z < 0)
@@ -221,7 +220,8 @@ namespace libTerrain
221 Normalise(); 220 Normalise();
222 } 221 }
223 222
224 public void HillsSquared(int number, double scale_min, double scale_range, bool island, bool additive, bool noisy) 223 public void HillsSquared(int number, double scale_min, double scale_range, bool island, bool additive,
224 bool noisy)
225 { 225 {
226 SetDiff(); 226 SetDiff();
227 227
@@ -232,20 +232,20 @@ namespace libTerrain
232 232
233 for (i = 0; i < number; i++) 233 for (i = 0; i < number; i++)
234 { 234 {
235 double rx = Math.Min(255.0, random.NextDouble() * w); 235 double rx = Math.Min(255.0, random.NextDouble()*w);
236 double ry = Math.Min(255.0, random.NextDouble() * h); 236 double ry = Math.Min(255.0, random.NextDouble()*h);
237 double rand = random.NextDouble(); 237 double rand = random.NextDouble();
238 238
239 if (island) 239 if (island)
240 { 240 {
241 // Move everything towards the center 241 // Move everything towards the center
242 rx -= w / 2; 242 rx -= w/2;
243 rx /= 2; 243 rx /= 2;
244 rx += w / 2; 244 rx += w/2;
245 245
246 ry -= h / 2; 246 ry -= h/2;
247 ry /= 2; 247 ry /= 2;
248 ry += h / 2; 248 ry += h/2;
249 } 249 }
250 250
251 for (x = 0; x < w; x++) 251 for (x = 0; x < w; x++)
@@ -255,11 +255,11 @@ namespace libTerrain
255 if (noisy) 255 if (noisy)
256 rand = random.NextDouble(); 256 rand = random.NextDouble();
257 257
258 double z = (scale_min + (scale_range * rand)); 258 double z = (scale_min + (scale_range*rand));
259 z *= z * z * z; 259 z *= z*z*z;
260 double dx = Math.Abs(x - rx); 260 double dx = Math.Abs(x - rx);
261 double dy = Math.Abs(y - ry); 261 double dy = Math.Abs(y - ry);
262 z -= (dx * dx * dx * dx) + (dy * dy * dy * dy); 262 z -= (dx*dx*dx*dx) + (dy*dy*dy*dy);
263 263
264 if (z < 0) 264 if (z < 0)
265 z = 0; 265 z = 0;
@@ -278,6 +278,5 @@ namespace libTerrain
278 278
279 Normalise(); 279 Normalise();
280 } 280 }
281
282 } 281 }
283} 282} \ No newline at end of file
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Noise.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Noise.cs
index 43ae37a..5d39cd5 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Noise.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Noise.cs
@@ -27,8 +27,6 @@
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic;
31using System.Text;
32 30
33namespace libTerrain 31namespace libTerrain
34{ 32{
@@ -53,4 +51,4 @@ namespace libTerrain
53 } 51 }
54 } 52 }
55 } 53 }
56} 54} \ No newline at end of file
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs
index d7e0dcd..10eaf71 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs
@@ -28,7 +28,6 @@
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text;
32 31
33namespace libTerrain 32namespace libTerrain
34{ 33{
@@ -36,10 +35,10 @@ namespace libTerrain
36 { 35 {
37 private double[] CoordinatesToPolar(int x, int y) 36 private double[] CoordinatesToPolar(int x, int y)
38 { 37 {
39 double theta = Math.Atan2(x - (w / 2), y - (h / 2)); 38 double theta = Math.Atan2(x - (w/2), y - (h/2));
40 double rx = (double)x - ((double)w / 2); 39 double rx = (double) x - ((double) w/2);
41 double ry = (double)y - ((double)h / 2); 40 double ry = (double) y - ((double) h/2);
42 double r = Math.Sqrt((rx * rx) + (ry * ry)); 41 double r = Math.Sqrt((rx*rx) + (ry*ry));
43 42
44 double[] coords = new double[2]; 43 double[] coords = new double[2];
45 coords[0] = r; 44 coords[0] = r;
@@ -47,15 +46,16 @@ namespace libTerrain
47 return coords; 46 return coords;
48 } 47 }
49 48
50 public int[] PolarToCoordinates(double r, double theta) { 49 public int[] PolarToCoordinates(double r, double theta)
50 {
51 double nx; 51 double nx;
52 double ny; 52 double ny;
53 53
54 nx = (double)r * Math.Cos(theta); 54 nx = (double) r*Math.Cos(theta);
55 ny = (double)r * Math.Sin(theta); 55 ny = (double) r*Math.Sin(theta);
56 56
57 nx += w / 2; 57 nx += w/2;
58 ny += h / 2; 58 ny += h/2;
59 59
60 if (nx >= w) 60 if (nx >= w)
61 nx = w - 1; 61 nx = w - 1;
@@ -70,8 +70,8 @@ namespace libTerrain
70 ny = 0; 70 ny = 0;
71 71
72 int[] coords = new int[2]; 72 int[] coords = new int[2];
73 coords[0] = (int)nx; 73 coords[0] = (int) nx;
74 coords[1] = (int)ny; 74 coords[1] = (int) ny;
75 return coords; 75 return coords;
76 } 76 }
77 77
@@ -79,19 +79,19 @@ namespace libTerrain
79 { 79 {
80 SetDiff(); 80 SetDiff();
81 81
82 Channel n = this.Copy(); 82 Channel n = Copy();
83 83
84 int x, y; 84 int x, y;
85 for (x = 0; x < w; x++) 85 for (x = 0; x < w; x++)
86 { 86 {
87 for (y = 0; y < h; y++) 87 for (y = 0; y < h; y++)
88 { 88 {
89 double[] coords = CoordinatesToPolar(x,y); 89 double[] coords = CoordinatesToPolar(x, y);
90 90
91 coords[0] += w / 2.0; 91 coords[0] += w/2.0;
92 coords[1] += h / 2.0; 92 coords[1] += h/2.0;
93 93
94 map[x, y] = n.map[(int)coords[0] % n.w, (int)coords[1] % n.h]; 94 map[x, y] = n.map[(int) coords[0]%n.w, (int) coords[1]%n.h];
95 } 95 }
96 } 96 }
97 } 97 }
@@ -108,12 +108,13 @@ namespace libTerrain
108 r += incRadius; 108 r += incRadius;
109 theta += incAngle; 109 theta += incAngle;
110 110
111 int[] coords = PolarToCoordinates(r,theta); 111 int[] coords = PolarToCoordinates(r, theta);
112 Raise(coords[0], coords[1], 20, 1); 112 Raise(coords[0], coords[1], 20, 1);
113 } 113 }
114 } 114 }
115 115
116 public void SpiralCells(int steps, double incAngle, double incRadius, double offsetRadius, double offsetAngle, double[] c) 116 public void SpiralCells(int steps, double incAngle, double incRadius, double offsetRadius, double offsetAngle,
117 double[] c)
117 { 118 {
118 SetDiff(); 119 SetDiff();
119 120
@@ -128,7 +129,7 @@ namespace libTerrain
128 theta += incAngle; 129 theta += incAngle;
129 130
130 int[] coords = PolarToCoordinates(r, theta); 131 int[] coords = PolarToCoordinates(r, theta);
131 points.Add(new Point2D(coords[0],coords[1])); 132 points.Add(new Point2D(coords[0], coords[1]));
132 } 133 }
133 134
134 VoronoiDiagram(points, c); 135 VoronoiDiagram(points, c);
@@ -145,9 +146,9 @@ namespace libTerrain
145 for (y = 0; y < h; y++) 146 for (y = 0; y < h; y++)
146 { 147 {
147 z++; 148 z++;
148 double dx = Math.Abs((w / 2) - x); 149 double dx = Math.Abs((w/2) - x);
149 double dy = Math.Abs((h / 2) - y); 150 double dy = Math.Abs((h/2) - y);
150 map[x, y] += Math.Sin(dx / wid) + Math.Cos(dy / hig); 151 map[x, y] += Math.Sin(dx/wid) + Math.Cos(dy/hig);
151 } 152 }
152 } 153 }
153 Normalise(); 154 Normalise();
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Voronoi.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Voronoi.cs
index e2f9560..0159b87 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Voronoi.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Voronoi.cs
@@ -28,7 +28,6 @@
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text;
32 31
33namespace libTerrain 32namespace libTerrain
34{ 33{
@@ -57,8 +56,8 @@ namespace libTerrain
57 { 56 {
58 for (i = 0; i < pointsPerBlock; i++) 57 for (i = 0; i < pointsPerBlock; i++)
59 { 58 {
60 double pX = x + (generator.NextDouble() * (double)blockSize); 59 double pX = x + (generator.NextDouble()*(double) blockSize);
61 double pY = y + (generator.NextDouble() * (double)blockSize); 60 double pY = y + (generator.NextDouble()*(double) blockSize);
62 61
63 points.Add(new Point2D(pX, pY)); 62 points.Add(new Point2D(pX, pY));
64 } 63 }
@@ -75,10 +74,10 @@ namespace libTerrain
75 for (i = 0; i < points.Count; i++) 74 for (i = 0; i < points.Count; i++)
76 { 75 {
77 double dx, dy; 76 double dx, dy;
78 dx = Math.Abs((double)x - points[i].x); 77 dx = Math.Abs((double) x - points[i].x);
79 dy = Math.Abs((double)y - points[i].y); 78 dy = Math.Abs((double) y - points[i].y);
80 79
81 distances[i] = (dx * dx + dy * dy); 80 distances[i] = (dx*dx + dy*dy);
82 } 81 }
83 82
84 Array.Sort(distances); 83 Array.Sort(distances);
@@ -92,7 +91,7 @@ namespace libTerrain
92 if (i >= points.Count) 91 if (i >= points.Count)
93 break; 92 break;
94 93
95 f += c[i] * distances[i]; 94 f += c[i]*distances[i];
96 } 95 }
97 96
98 map[x, y] = f; 97 map[x, y] = f;
@@ -119,10 +118,10 @@ namespace libTerrain
119 for (i = 0; i < points.Count; i++) 118 for (i = 0; i < points.Count; i++)
120 { 119 {
121 double dx, dy; 120 double dx, dy;
122 dx = Math.Abs((double)x - points[i].x); 121 dx = Math.Abs((double) x - points[i].x);
123 dy = Math.Abs((double)y - points[i].y); 122 dy = Math.Abs((double) y - points[i].y);
124 123
125 distances[i] = (dx * dx + dy * dy); 124 distances[i] = (dx*dx + dy*dy);
126 } 125 }
127 126
128 Array.Sort(distances); 127 Array.Sort(distances);
@@ -136,7 +135,7 @@ namespace libTerrain
136 if (i >= points.Count) 135 if (i >= points.Count)
137 break; 136 break;
138 137
139 f += c[i] * distances[i]; 138 f += c[i]*distances[i];
140 } 139 }
141 140
142 map[x, y] = f; 141 map[x, y] = f;
@@ -162,8 +161,8 @@ namespace libTerrain
162 { 161 {
163 for (i = 0; i < pointsPerBlock; i++) 162 for (i = 0; i < pointsPerBlock; i++)
164 { 163 {
165 double pX = x + (generator.NextDouble() * (double)blockSize); 164 double pX = x + (generator.NextDouble()*(double) blockSize);
166 double pY = y + (generator.NextDouble() * (double)blockSize); 165 double pY = y + (generator.NextDouble()*(double) blockSize);
167 166
168 points.Add(new Point2D(pX, pY)); 167 points.Add(new Point2D(pX, pY));
169 } 168 }
@@ -180,10 +179,10 @@ namespace libTerrain
180 for (i = 0; i < points.Count; i++) 179 for (i = 0; i < points.Count; i++)
181 { 180 {
182 double dx, dy; 181 double dx, dy;
183 dx = Math.Abs((double)x - points[i].x); 182 dx = Math.Abs((double) x - points[i].x);
184 dy = Math.Abs((double)y - points[i].y); 183 dy = Math.Abs((double) y - points[i].y);
185 184
186 distances[i] = (dx * dx + dy * dy); 185 distances[i] = (dx*dx + dy*dy);
187 } 186 }
188 187
189 //Array.Sort(distances); 188 //Array.Sort(distances);
@@ -191,7 +190,7 @@ namespace libTerrain
191 double f = 0.0; 190 double f = 0.0;
192 191
193 double min = double.MaxValue; 192 double min = double.MaxValue;
194 for (int j = 0; j < distances.Length;j++ ) 193 for (int j = 0; j < distances.Length; j++)
195 { 194 {
196 if (distances[j] < min) 195 if (distances[j] < min)
197 { 196 {
@@ -211,4 +210,4 @@ namespace libTerrain
211 Normalise(); 210 Normalise();
212 } 211 }
213 } 212 }
214} 213} \ No newline at end of file
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Worms.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Worms.cs
index 788134d..deb2e0e 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Worms.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Worms.cs
@@ -27,8 +27,6 @@
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic;
31using System.Text;
32 30
33namespace libTerrain 31namespace libTerrain
34{ 32{
@@ -54,18 +52,18 @@ namespace libTerrain
54 double rx, ry; 52 double rx, ry;
55 if (centerspawn) 53 if (centerspawn)
56 { 54 {
57 rx = w / 2.0; 55 rx = w/2.0;
58 ry = h / 2.0; 56 ry = h/2.0;
59 } 57 }
60 else 58 else
61 { 59 {
62 rx = random.NextDouble() * (w - 1); 60 rx = random.NextDouble()*(w - 1);
63 ry = random.NextDouble() * (h - 1); 61 ry = random.NextDouble()*(h - 1);
64 } 62 }
65 for (j = 0; j < rounds; j++) 63 for (j = 0; j < rounds; j++)
66 { 64 {
67 rx += (random.NextDouble() * movement) - (movement / 2.0); 65 rx += (random.NextDouble()*movement) - (movement/2.0);
68 ry += (random.NextDouble() * movement) - (movement / 2.0); 66 ry += (random.NextDouble()*movement) - (movement/2.0);
69 Raise(rx, ry, size, 1.0); 67 Raise(rx, ry, size, 1.0);
70 } 68 }
71 } 69 }
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs
index 0155791..24df5b9 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs
@@ -27,8 +27,6 @@
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic;
31using System.Text;
32 30
33namespace libTerrain 31namespace libTerrain
34{ 32{
@@ -49,13 +47,13 @@ namespace libTerrain
49 { 47 {
50 for (y = 0; y < h; y++) 48 for (y = 0; y < h; y++)
51 { 49 {
52 map[x, y] = (map[x, y] - min) * (1.0 / (max - min)); 50 map[x, y] = (map[x, y] - min)*(1.0/(max - min));
53 } 51 }
54 } 52 }
55 } 53 }
56 else 54 else
57 { 55 {
58 this.Fill(0.5); 56 Fill(0.5);
59 } 57 }
60 58
61 return this; 59 return this;
@@ -82,7 +80,7 @@ namespace libTerrain
82 { 80 {
83 if (min != max) 81 if (min != max)
84 { 82 {
85 double val = (map[x, y] - min) * (1.0 / max - min); 83 double val = (map[x, y] - min)*(1.0/max - min);
86 val *= maxv - minv; 84 val *= maxv - minv;
87 val += minv; 85 val += minv;
88 86
@@ -179,9 +177,9 @@ namespace libTerrain
179 SetDiff(); 177 SetDiff();
180 178
181 double area = amount; 179 double area = amount;
182 double step = amount / 4.0; 180 double step = amount/4.0;
183 181
184 double[,] manipulate = new double[w, h]; 182 double[,] manipulate = new double[w,h];
185 int x, y; 183 int x, y;
186 double n, l; 184 double n, l;
187 for (x = 0; x < w; x++) 185 for (x = 0; x < w; x++)
@@ -200,7 +198,7 @@ namespace libTerrain
200 } 198 }
201 } 199 }
202 200
203 manipulate[x, y] = average / avgsteps; 201 manipulate[x, y] = average/avgsteps;
204 } 202 }
205 } 203 }
206 map = manipulate; 204 map = manipulate;
@@ -211,7 +209,7 @@ namespace libTerrain
211 SetDiff(); 209 SetDiff();
212 210
213 // Simple pertubation filter 211 // Simple pertubation filter
214 double[,] manipulated = new double[w, h]; 212 double[,] manipulated = new double[w,h];
215 Random generator = new Random(seed); // Seeds FTW! 213 Random generator = new Random(seed); // Seeds FTW!
216 //double amount = 8.0; 214 //double amount = 8.0;
217 215
@@ -220,8 +218,8 @@ namespace libTerrain
220 { 218 {
221 for (y = 0; y < h; y++) 219 for (y = 0; y < h; y++)
222 { 220 {
223 double offset_x = (double)x + (generator.NextDouble() * amount) - (amount / 2.0); 221 double offset_x = (double) x + (generator.NextDouble()*amount) - (amount/2.0);
224 double offset_y = (double)y + (generator.NextDouble() * amount) - (amount / 2.0); 222 double offset_y = (double) y + (generator.NextDouble()*amount) - (amount/2.0);
225 double p = GetBilinearInterpolate(offset_x, offset_y); 223 double p = GetBilinearInterpolate(offset_x, offset_y);
226 manipulated[x, y] = p; 224 manipulated[x, y] = p;
227 } 225 }
@@ -232,7 +230,7 @@ namespace libTerrain
232 public void PertubationMask(Channel mask) 230 public void PertubationMask(Channel mask)
233 { 231 {
234 // Simple pertubation filter 232 // Simple pertubation filter
235 double[,] manipulated = new double[w, h]; 233 double[,] manipulated = new double[w,h];
236 Random generator = new Random(seed); // Seeds FTW! 234 Random generator = new Random(seed); // Seeds FTW!
237 //double amount = 8.0; 235 //double amount = 8.0;
238 236
@@ -244,8 +242,8 @@ namespace libTerrain
244 for (y = 0; y < h; y++) 242 for (y = 0; y < h; y++)
245 { 243 {
246 amount = mask.map[x, y]; 244 amount = mask.map[x, y];
247 double offset_x = (double)x + (generator.NextDouble() * amount) - (amount / 2.0); 245 double offset_x = (double) x + (generator.NextDouble()*amount) - (amount/2.0);
248 double offset_y = (double)y + (generator.NextDouble() * amount) - (amount / 2.0); 246 double offset_y = (double) y + (generator.NextDouble()*amount) - (amount/2.0);
249 247
250 if (offset_x > w) 248 if (offset_x > w)
251 offset_x = w - 1; 249 offset_x = w - 1;
@@ -267,7 +265,7 @@ namespace libTerrain
267 public void Distort(Channel mask, double str) 265 public void Distort(Channel mask, double str)
268 { 266 {
269 // Simple pertubation filter 267 // Simple pertubation filter
270 double[,] manipulated = new double[w, h]; 268 double[,] manipulated = new double[w,h];
271 269
272 double amount; 270 double amount;
273 271
@@ -277,8 +275,8 @@ namespace libTerrain
277 for (y = 0; y < h; y++) 275 for (y = 0; y < h; y++)
278 { 276 {
279 amount = mask.map[x, y]; 277 amount = mask.map[x, y];
280 double offset_x = (double)x + (amount * str) - (0.5 * str); 278 double offset_x = (double) x + (amount*str) - (0.5*str);
281 double offset_y = (double)y + (amount * str) - (0.5 * str); 279 double offset_y = (double) y + (amount*str) - (0.5*str);
282 280
283 if (offset_x > w) 281 if (offset_x > w)
284 offset_x = w - 1; 282 offset_x = w - 1;
@@ -295,13 +293,12 @@ namespace libTerrain
295 } 293 }
296 } 294 }
297 map = manipulated; 295 map = manipulated;
298
299 } 296 }
300 297
301 public void Distort(Channel mask, Channel mask2, double str) 298 public void Distort(Channel mask, Channel mask2, double str)
302 { 299 {
303 // Simple pertubation filter 300 // Simple pertubation filter
304 double[,] manipulated = new double[w, h]; 301 double[,] manipulated = new double[w,h];
305 302
306 double amountX; 303 double amountX;
307 double amountY; 304 double amountY;
@@ -313,8 +310,8 @@ namespace libTerrain
313 { 310 {
314 amountX = mask.map[x, y]; 311 amountX = mask.map[x, y];
315 amountY = mask2.map[x, y]; 312 amountY = mask2.map[x, y];
316 double offset_x = (double)x + (amountX * str) - (0.5 * str); 313 double offset_x = (double) x + (amountX*str) - (0.5*str);
317 double offset_y = (double)y + (amountY * str) - (0.5 * str); 314 double offset_y = (double) y + (amountY*str) - (0.5*str);
318 315
319 if (offset_x > w) 316 if (offset_x > w)
320 offset_x = w - 1; 317 offset_x = w - 1;
@@ -331,7 +328,6 @@ namespace libTerrain
331 } 328 }
332 } 329 }
333 map = manipulated; 330 map = manipulated;
334
335 } 331 }
336 332
337 public Channel Blend(Channel other, double amount) 333 public Channel Blend(Channel other, double amount)
@@ -360,4 +356,4 @@ namespace libTerrain
360 return this; 356 return this;
361 } 357 }
362 } 358 }
363} 359} \ No newline at end of file
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs
index ca93c25..c8584e8 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs
@@ -27,8 +27,6 @@
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic;
31using System.Text;
32 30
33namespace libTerrain 31namespace libTerrain
34{ 32{
@@ -74,17 +72,18 @@ namespace libTerrain
74 /// <param name="carry">The percentage of rock which can be picked up to pickup 0..1</param> 72 /// <param name="carry">The percentage of rock which can be picked up to pickup 0..1</param>
75 /// <param name="rounds">The number of erosion rounds (recommended: 25+)</param> 73 /// <param name="rounds">The number of erosion rounds (recommended: 25+)</param>
76 /// <param name="lowest">Drop sediment at the lowest point?</param> 74 /// <param name="lowest">Drop sediment at the lowest point?</param>
77 public void AerobicErosion(double windspeed, double pickupTalusMinimum, double dropTalusMinimum, double carry, int rounds, bool lowest, bool usingFluidDynamics) 75 public void AerobicErosion(double windspeed, double pickupTalusMinimum, double dropTalusMinimum, double carry,
76 int rounds, bool lowest, bool usingFluidDynamics)
78 { 77 {
79 bool debugImages = false; 78 bool debugImages = false;
80 79
81 Channel wind = new Channel(w, h) ; 80 Channel wind = new Channel(w, h);
82 Channel sediment = new Channel(w, h); 81 Channel sediment = new Channel(w, h);
83 int x, y, i, j; 82 int x, y, i, j;
84 83
85 this.Normalise(); 84 Normalise();
86 85
87 wind = this.Copy(); 86 wind = Copy();
88 wind.Noise(); 87 wind.Noise();
89 88
90 if (debugImages) 89 if (debugImages)
@@ -120,7 +119,7 @@ namespace libTerrain
120 surfacearea += Math.Abs(target - me); 119 surfacearea += Math.Abs(target - me);
121 } 120 }
122 121
123 double amount = surfacearea * wind.map[x, y] * carry; 122 double amount = surfacearea*wind.map[x, y]*carry;
124 123
125 if (amount < 0) 124 if (amount < 0)
126 amount = 0; 125 amount = 0;
@@ -147,7 +146,7 @@ namespace libTerrain
147 } 146 }
148 else 147 else
149 { 148 {
150 wind.Pertubation(15); // Can do better later 149 wind.Pertubation(15); // Can do better later
151 wind.seed++; 150 wind.seed++;
152 sediment.Pertubation(10); // Sediment is blown around a bit 151 sediment.Pertubation(10); // Sediment is blown around a bit
153 sediment.seed++; 152 sediment.seed++;
@@ -175,12 +174,12 @@ namespace libTerrain
175 174
176 if (target < min && lowest) 175 if (target < min && lowest)
177 { 176 {
178 minside = (int[])coords.Clone(); 177 minside = (int[]) coords.Clone();
179 min = target; 178 min = target;
180 } 179 }
181 } 180 }
182 181
183 double amount = surfacearea * (1.0 - wind.map[x, y]) * carry; 182 double amount = surfacearea*(1.0 - wind.map[x, y])*carry;
184 183
185 if (amount < 0) 184 if (amount < 0)
186 amount = 0; 185 amount = 0;
@@ -199,7 +198,7 @@ namespace libTerrain
199 wind.Normalise(); 198 wind.Normalise();
200 wind *= windspeed; 199 wind *= windspeed;
201 200
202 this.Normalise(); 201 Normalise();
203 } 202 }
204 203
205 Channel myself = this; 204 Channel myself = this;
@@ -207,7 +206,7 @@ namespace libTerrain
207 myself.Normalise(); 206 myself.Normalise();
208 207
209 if (debugImages) 208 if (debugImages)
210 this.SaveImage("testimg/output.png"); 209 SaveImage("testimg/output.png");
211 } 210 }
212 } 211 }
213} \ No newline at end of file 212} \ No newline at end of file
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/HydraulicErosion.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/HydraulicErosion.cs
index 4f58f71..0e47e1b 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/HydraulicErosion.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/HydraulicErosion.cs
@@ -27,8 +27,6 @@
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic;
31using System.Text;
32 30
33namespace libTerrain 31namespace libTerrain
34{ 32{
@@ -44,7 +42,7 @@ namespace libTerrain
44 Channel waterFlow = new Channel(w, h); 42 Channel waterFlow = new Channel(w, h);
45 43
46 NeighbourSystem type = NeighbourSystem.Moore; 44 NeighbourSystem type = NeighbourSystem.Moore;
47 int NEIGHBOUR_ME = 4; 45 int NEIGHBOUR_ME = 4;
48 46
49 int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5; 47 int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5;
50 48
@@ -52,7 +50,7 @@ namespace libTerrain
52 { 50 {
53 water += rain; 51 water += rain;
54 52
55 sediment = terrain * water; 53 sediment = terrain*water;
56 terrain -= sediment; 54 terrain -= sediment;
57 55
58 for (int x = 1; x < w - 1; x++) 56 for (int x = 1; x < w - 1; x++)
@@ -72,7 +70,8 @@ namespace libTerrain
72 coords[0] += x; 70 coords[0] += x;
73 coords[1] += y; 71 coords[1] += y;
74 72
75 heights[j] = map[coords[0], coords[1]] + water.map[coords[0], coords[1]] + sediment.map[coords[0], coords[1]]; 73 heights[j] = map[coords[0], coords[1]] + water.map[coords[0], coords[1]] +
74 sediment.map[coords[0], coords[1]];
76 diffs[j] = heightCenter - heights[j]; 75 diffs[j] = heightCenter - heights[j];
77 } 76 }
78 } 77 }
@@ -97,13 +96,13 @@ namespace libTerrain
97 if (totalCellsCounted == 1) 96 if (totalCellsCounted == 1)
98 continue; 97 continue;
99 98
100 double averageHeight = totalHeight / totalCellsCounted; 99 double averageHeight = totalHeight/totalCellsCounted;
101 double waterAmount = Math.Min(water.map[x, y], heightCenter - averageHeight); 100 double waterAmount = Math.Min(water.map[x, y], heightCenter - averageHeight);
102 101
103 // TODO: Check this. 102 // TODO: Check this.
104 waterFlow.map[x, y] += waterFlow.map[x, y] - waterAmount; 103 waterFlow.map[x, y] += waterFlow.map[x, y] - waterAmount;
105 104
106 double totalInverseDiff = waterAmount / totalHeightDiff; 105 double totalInverseDiff = waterAmount/totalHeightDiff;
107 106
108 for (int j = 0; j < NEIGHBOUR_MAX; j++) 107 for (int j = 0; j < NEIGHBOUR_MAX; j++)
109 { 108 {
@@ -115,7 +114,8 @@ namespace libTerrain
115 114
116 if (diffs[j] > 0) 115 if (diffs[j] > 0)
117 { 116 {
118 waterFlow.SetWrap(coords[0], coords[1], waterFlow.map[coords[0], coords[1]] + diffs[j] * totalInverseDiff); 117 waterFlow.SetWrap(coords[0], coords[1],
118 waterFlow.map[coords[0], coords[1]] + diffs[j]*totalInverseDiff);
119 } 119 }
120 } 120 }
121 } 121 }
@@ -131,7 +131,7 @@ namespace libTerrain
131 { 131 {
132 for (int y = 0; y < h; y++) 132 for (int y = 0; y < h; y++)
133 { 133 {
134 double deposition = sediment.map[x, y] - water.map[x, y] * solubility; 134 double deposition = sediment.map[x, y] - water.map[x, y]*solubility;
135 if (deposition > 0) 135 if (deposition > 0)
136 { 136 {
137 sediment.map[x, y] -= deposition; 137 sediment.map[x, y] -= deposition;
@@ -139,7 +139,6 @@ namespace libTerrain
139 } 139 }
140 } 140 }
141 } 141 }
142
143 } 142 }
144 } 143 }
145 } 144 }
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs
index 401cf95..8c16d7c 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs
@@ -26,10 +26,6 @@
26* 26*
27*/ 27*/
28 28
29using System;
30using System.Collections.Generic;
31using System.Text;
32
33namespace libTerrain 29namespace libTerrain
34{ 30{
35 partial class Channel 31 partial class Channel
@@ -42,7 +38,7 @@ namespace libTerrain
42 38
43 private static int nsIX(int i, int j, int N) 39 private static int nsIX(int i, int j, int N)
44 { 40 {
45 return ((i) + (N + 2) * (j)); 41 return ((i) + (N + 2)*(j));
46 } 42 }
47 43
48 private static void nsSwap(ref double x0, ref double x) 44 private static void nsSwap(ref double x0, ref double x)
@@ -62,10 +58,10 @@ namespace libTerrain
62 private void nsAddSource(int N, ref double[] x, ref double[] s, double dt) 58 private void nsAddSource(int N, ref double[] x, ref double[] s, double dt)
63 { 59 {
64 int i; 60 int i;
65 int size = (N + 2) * (N + 2); 61 int size = (N + 2)*(N + 2);
66 for (i = 0; i < size; i++) 62 for (i = 0; i < size; i++)
67 { 63 {
68 x[i] += dt * s[i]; 64 x[i] += dt*s[i];
69 } 65 }
70 } 66 }
71 67
@@ -74,15 +70,15 @@ namespace libTerrain
74 int i; 70 int i;
75 for (i = 0; i <= N; i++) 71 for (i = 0; i <= N; i++)
76 { 72 {
77 x[nsIX(0, i, N)] = b == 1 ? -x[nsIX(1, i, N)] : x[nsIX(1, i, N)]; 73 x[nsIX(0, i, N)] = b == 1 ? -x[nsIX(1, i, N)] : x[nsIX(1, i, N)];
78 x[nsIX(0, N + 1, N)] = b == 1 ? -x[nsIX(N, i, N)] : x[nsIX(N, i, N)]; 74 x[nsIX(0, N + 1, N)] = b == 1 ? -x[nsIX(N, i, N)] : x[nsIX(N, i, N)];
79 x[nsIX(i, 0, N)] = b == 2 ? -x[nsIX(i, 1, N)] : x[nsIX(i, 1, N)]; 75 x[nsIX(i, 0, N)] = b == 2 ? -x[nsIX(i, 1, N)] : x[nsIX(i, 1, N)];
80 x[nsIX(i, N + 1, N)] = b == 2 ? -x[nsIX(i, N, N)] : x[nsIX(i, N, N)]; 76 x[nsIX(i, N + 1, N)] = b == 2 ? -x[nsIX(i, N, N)] : x[nsIX(i, N, N)];
81 } 77 }
82 x[nsIX(0, 0, N)] = 0.5f * (x[nsIX(1, 0, N)] + x[nsIX(0, 1, N)]); 78 x[nsIX(0, 0, N)] = 0.5f*(x[nsIX(1, 0, N)] + x[nsIX(0, 1, N)]);
83 x[nsIX(0, N + 1, N)] = 0.5f * (x[nsIX(1, N + 1, N)] + x[nsIX(0, N, N)]); 79 x[nsIX(0, N + 1, N)] = 0.5f*(x[nsIX(1, N + 1, N)] + x[nsIX(0, N, N)]);
84 x[nsIX(N + 1, 0, N)] = 0.5f * (x[nsIX(N, 0, N)] + x[nsIX(N + 1, 1, N)]); 80 x[nsIX(N + 1, 0, N)] = 0.5f*(x[nsIX(N, 0, N)] + x[nsIX(N + 1, 1, N)]);
85 x[nsIX(N + 1, N + 1, N)] = 0.5f * (x[nsIX(N, N + 1, N)] + x[nsIX(N + 1, N, N)]); 81 x[nsIX(N + 1, N + 1, N)] = 0.5f*(x[nsIX(N, N + 1, N)] + x[nsIX(N + 1, N, N)]);
86 } 82 }
87 83
88 private void nsLinSolve(int N, int b, ref double[] x, ref double[] x0, double a, double c) 84 private void nsLinSolve(int N, int b, ref double[] x, ref double[] x0, double a, double c)
@@ -92,11 +88,11 @@ namespace libTerrain
92 { 88 {
93 for (j = 1; j <= N; j++) 89 for (j = 1; j <= N; j++)
94 { 90 {
95 x[nsIX(i, j, N)] = (x0[nsIX(i, j, N)] + a * 91 x[nsIX(i, j, N)] = (x0[nsIX(i, j, N)] + a*
96 (x[nsIX(i - 1, j, N)] + 92 (x[nsIX(i - 1, j, N)] +
97 x[nsIX(i + 1, j, N)] + 93 x[nsIX(i + 1, j, N)] +
98 x[nsIX(i, j - 1, N)] + x[nsIX(i, j + 1, N)]) 94 x[nsIX(i, j - 1, N)] + x[nsIX(i, j + 1, N)])
99 ) / c; 95 )/c;
100 } 96 }
101 } 97 }
102 98
@@ -105,8 +101,8 @@ namespace libTerrain
105 101
106 private void nsDiffuse(int N, int b, ref double[] x, ref double[] x0, double diff, double dt) 102 private void nsDiffuse(int N, int b, ref double[] x, ref double[] x0, double diff, double dt)
107 { 103 {
108 double a = dt * diff * N * N; 104 double a = dt*diff*N*N;
109 nsLinSolve(N, b, ref x, ref x0, a, 1 + 4 * a); 105 nsLinSolve(N, b, ref x, ref x0, a, 1 + 4*a);
110 } 106 }
111 107
112 private void nsAdvect(int N, int b, ref double[] d, ref double[] d0, ref double[] u, ref double[] v, double dt) 108 private void nsAdvect(int N, int b, ref double[] d, ref double[] d0, ref double[] u, ref double[] v, double dt)
@@ -114,27 +110,27 @@ namespace libTerrain
114 int i, j, i0, j0, i1, j1; 110 int i, j, i0, j0, i1, j1;
115 double x, y, s0, t0, s1, t1, dt0; 111 double x, y, s0, t0, s1, t1, dt0;
116 112
117 dt0 = dt * N; 113 dt0 = dt*N;
118 114
119 for (i = 1; i <= N; i++) 115 for (i = 1; i <= N; i++)
120 { 116 {
121 for (j = 1; j <= N; j++) 117 for (j = 1; j <= N; j++)
122 { 118 {
123 x = i - dt0 * u[nsIX(i, j, N)]; 119 x = i - dt0*u[nsIX(i, j, N)];
124 y = j - dt0 * v[nsIX(i, j, N)]; 120 y = j - dt0*v[nsIX(i, j, N)];
125 121
126 if (x < 0.5) 122 if (x < 0.5)
127 x = 0.5; 123 x = 0.5;
128 if (x > N + 0.5) 124 if (x > N + 0.5)
129 x = N + 0.5; 125 x = N + 0.5;
130 i0 = (int)x; 126 i0 = (int) x;
131 i1 = i0 + 1; 127 i1 = i0 + 1;
132 128
133 if (y < 0.5) 129 if (y < 0.5)
134 y = 0.5; 130 y = 0.5;
135 if (y > N + 0.5) 131 if (y > N + 0.5)
136 y = N + 0.5; 132 y = N + 0.5;
137 j0 = (int)y; 133 j0 = (int) y;
138 j1 = j0 + 1; 134 j1 = j0 + 1;
139 135
140 s1 = x - i0; 136 s1 = x - i0;
@@ -142,8 +138,8 @@ namespace libTerrain
142 t1 = y - j0; 138 t1 = y - j0;
143 t0 = 1 - t1; 139 t0 = 1 - t1;
144 140
145 d[nsIX(i, j, N)] = s0 * (t0 * d0[nsIX(i0, j0, N)] + t1 * d0[nsIX(i0, j1, N)]) + 141 d[nsIX(i, j, N)] = s0*(t0*d0[nsIX(i0, j0, N)] + t1*d0[nsIX(i0, j1, N)]) +
146 s1 * (t0 * d0[nsIX(i1, j0, N)] + t1 * d0[nsIX(i1, j1, N)]); 142 s1*(t0*d0[nsIX(i1, j0, N)] + t1*d0[nsIX(i1, j1, N)]);
147 } 143 }
148 } 144 }
149 145
@@ -158,7 +154,9 @@ namespace libTerrain
158 { 154 {
159 for (j = 1; j <= N; j++) 155 for (j = 1; j <= N; j++)
160 { 156 {
161 div[nsIX(i, j, N)] = -0.5 * (u[nsIX(i + 1, j, N)] - u[nsIX(i - 1, j, N)] + v[nsIX(i, j + 1, N)] - v[nsIX(i, j - 1, N)]) / N; 157 div[nsIX(i, j, N)] = -0.5*
158 (u[nsIX(i + 1, j, N)] - u[nsIX(i - 1, j, N)] + v[nsIX(i, j + 1, N)] -
159 v[nsIX(i, j - 1, N)])/N;
162 p[nsIX(i, j, N)] = 0; 160 p[nsIX(i, j, N)] = 0;
163 } 161 }
164 } 162 }
@@ -172,8 +170,8 @@ namespace libTerrain
172 { 170 {
173 for (j = 1; j <= N; j++) 171 for (j = 1; j <= N; j++)
174 { 172 {
175 u[nsIX(i, j, N)] -= 0.5 * N * (p[nsIX(i + 1, j, N)] - p[nsIX(i - 1, j, N)]); 173 u[nsIX(i, j, N)] -= 0.5*N*(p[nsIX(i + 1, j, N)] - p[nsIX(i - 1, j, N)]);
176 v[nsIX(i, j, N)] -= 0.5 * N * (p[nsIX(i, j + 1, N)] - p[nsIX(i, j - 1, N)]); 174 v[nsIX(i, j, N)] -= 0.5*N*(p[nsIX(i, j + 1, N)] - p[nsIX(i, j - 1, N)]);
177 } 175 }
178 } 176 }
179 177
@@ -181,7 +179,8 @@ namespace libTerrain
181 nsSetBnd(N, 2, ref v); 179 nsSetBnd(N, 2, ref v);
182 } 180 }
183 181
184 private void nsDensStep(int N, ref double[] x, ref double[] x0, ref double[] u, ref double[] v, double diff, double dt) 182 private void nsDensStep(int N, ref double[] x, ref double[] x0, ref double[] u, ref double[] v, double diff,
183 double dt)
185 { 184 {
186 nsAddSource(N, ref x, ref x0, dt); 185 nsAddSource(N, ref x, ref x0, dt);
187 nsSwap(ref x0, ref x); 186 nsSwap(ref x0, ref x);
@@ -190,7 +189,8 @@ namespace libTerrain
190 nsAdvect(N, 0, ref x, ref x0, ref u, ref v, dt); 189 nsAdvect(N, 0, ref x, ref x0, ref u, ref v, dt);
191 } 190 }
192 191
193 private void nsVelStep(int N, ref double[] u, ref double[] v, ref double[] u0, ref double[] v0, double visc, double dt) 192 private void nsVelStep(int N, ref double[] u, ref double[] v, ref double[] u0, ref double[] v0, double visc,
193 double dt)
194 { 194 {
195 nsAddSource(N, ref u, ref u0, dt); 195 nsAddSource(N, ref u, ref u0, dt);
196 nsAddSource(N, ref v, ref v0, dt); 196 nsAddSource(N, ref v, ref v0, dt);
@@ -236,17 +236,17 @@ namespace libTerrain
236 236
237 private void nsSimulate(int N, int rounds, double dt, double diff, double visc) 237 private void nsSimulate(int N, int rounds, double dt, double diff, double visc)
238 { 238 {
239 int size = (N * 2) * (N * 2); 239 int size = (N*2)*(N*2);
240 240
241 double[] u = new double[size]; // Force, X axis 241 double[] u = new double[size]; // Force, X axis
242 double[] v = new double[size]; // Force, Y axis 242 double[] v = new double[size]; // Force, Y axis
243 double[] u_prev = new double[size]; 243 double[] u_prev = new double[size];
244 double[] v_prev = new double[size]; 244 double[] v_prev = new double[size];
245 double[] dens = new double[size]; 245 double[] dens = new double[size];
246 double[] dens_prev = new double[size]; 246 double[] dens_prev = new double[size];
247 247
248 nsDoublesToBuffer(this.map, N, ref dens); 248 nsDoublesToBuffer(map, N, ref dens);
249 nsDoublesToBuffer(this.map, N, ref dens_prev); 249 nsDoublesToBuffer(map, N, ref dens_prev);
250 250
251 for (int i = 0; i < rounds; i++) 251 for (int i = 0; i < rounds; i++)
252 { 252 {
@@ -258,7 +258,7 @@ namespace libTerrain
258 nsDensStep(N, ref dens, ref dens_prev, ref u, ref v, diff, dt); 258 nsDensStep(N, ref dens, ref dens_prev, ref u, ref v, diff, dt);
259 } 259 }
260 260
261 nsBufferToDoubles(ref dens, N, ref this.map); 261 nsBufferToDoubles(ref dens, N, ref map);
262 } 262 }
263 263
264 /// <summary> 264 /// <summary>
@@ -270,14 +270,14 @@ namespace libTerrain
270 /// <param name="visc">Fluid viscosity (Recommended: 0.0)</param> 270 /// <param name="visc">Fluid viscosity (Recommended: 0.0)</param>
271 public void navierStokes(int rounds, double dt, double diff, double visc) 271 public void navierStokes(int rounds, double dt, double diff, double visc)
272 { 272 {
273 nsSimulate(this.h, rounds, dt, diff, visc); 273 nsSimulate(h, rounds, dt, diff, visc);
274 } 274 }
275 275
276 public void navierStokes(int rounds, double dt, double diff, double visc, ref double[,] uret, ref double[,] vret) 276 public void navierStokes(int rounds, double dt, double diff, double visc, ref double[,] uret, ref double[,] vret)
277 { 277 {
278 int N = this.h; 278 int N = h;
279 279
280 int size = (N * 2) * (N * 2); 280 int size = (N*2)*(N*2);
281 281
282 double[] u = new double[size]; // Force, X axis 282 double[] u = new double[size]; // Force, X axis
283 double[] v = new double[size]; // Force, Y axis 283 double[] v = new double[size]; // Force, Y axis
@@ -286,8 +286,8 @@ namespace libTerrain
286 double[] dens = new double[size]; 286 double[] dens = new double[size];
287 double[] dens_prev = new double[size]; 287 double[] dens_prev = new double[size];
288 288
289 nsDoublesToBuffer(this.map, N, ref dens); 289 nsDoublesToBuffer(map, N, ref dens);
290 nsDoublesToBuffer(this.map, N, ref dens_prev); 290 nsDoublesToBuffer(map, N, ref dens_prev);
291 291
292 for (int i = 0; i < rounds; i++) 292 for (int i = 0; i < rounds; i++)
293 { 293 {
@@ -301,7 +301,7 @@ namespace libTerrain
301 301
302 nsBufferToDoubles(ref u, N, ref uret); 302 nsBufferToDoubles(ref u, N, ref uret);
303 nsBufferToDoubles(ref v, N, ref vret); 303 nsBufferToDoubles(ref v, N, ref vret);
304 nsBufferToDoubles(ref dens, N, ref this.map); 304 nsBufferToDoubles(ref dens, N, ref map);
305 } 305 }
306 } 306 }
307} \ No newline at end of file 307} \ No newline at end of file
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/ThermalWeathering.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/ThermalWeathering.cs
index 9148c3c..0ca3d48 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/ThermalWeathering.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/ThermalWeathering.cs
@@ -26,10 +26,6 @@
26* 26*
27*/ 27*/
28 28
29using System;
30using System.Collections.Generic;
31using System.Text;
32
33namespace libTerrain 29namespace libTerrain
34{ 30{
35 partial class Channel 31 partial class Channel
@@ -47,10 +43,11 @@ namespace libTerrain
47 double[,] lastFrame; 43 double[,] lastFrame;
48 double[,] thisFrame; 44 double[,] thisFrame;
49 45
50 lastFrame = (double[,])map.Clone(); 46 lastFrame = (double[,]) map.Clone();
51 thisFrame = (double[,])map.Clone(); 47 thisFrame = (double[,]) map.Clone();
52 48
53 NeighbourSystem type = NeighbourSystem.Moore; // Using moore neighbourhood (twice as computationally expensive) 49 NeighbourSystem type = NeighbourSystem.Moore;
50 // Using moore neighbourhood (twice as computationally expensive)
54 int NEIGHBOUR_ME = 4; // I am always 4 in both systems. 51 int NEIGHBOUR_ME = 4; // I am always 4 in both systems.
55 52
56 int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5; 53 int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5;
@@ -88,19 +85,18 @@ namespace libTerrain
88 85
89 if (target > heightF + talus) 86 if (target > heightF + talus)
90 { 87 {
91 double calc = c * ((target - heightF) - talus); 88 double calc = c*((target - heightF) - talus);
92 heightF += calc; 89 heightF += calc;
93 target -= calc; 90 target -= calc;
94 } 91 }
95 92
96 thisFrame[x, y] = heightF; 93 thisFrame[x, y] = heightF;
97 thisFrame[coords[0], coords[1]] = target; 94 thisFrame[coords[0], coords[1]] = target;
98
99 } 95 }
100 } 96 }
101 } 97 }
102 } 98 }
103 lastFrame = (double[,])thisFrame.Clone(); 99 lastFrame = (double[,]) thisFrame.Clone();
104 } 100 }
105 101
106 map = thisFrame; 102 map = thisFrame;
@@ -109,4 +105,4 @@ namespace libTerrain
109 return this; 105 return this;
110 } 106 }
111 } 107 }
112} 108} \ No newline at end of file
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Neighbours.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Neighbours.cs
index 316bd9a..4004747 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Neighbours.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Neighbours.cs
@@ -26,19 +26,15 @@
26* 26*
27*/ 27*/
28 28
29using System;
30using System.Collections.Generic;
31using System.Text;
32
33namespace libTerrain 29namespace libTerrain
34{ 30{
35 partial class Channel 31 partial class Channel
36 { 32 {
37 enum NeighbourSystem 33 private enum NeighbourSystem
38 { 34 {
39 Moore, 35 Moore,
40 VonNeumann 36 VonNeumann
41 }; 37 } ;
42 38
43 private int[] Neighbours(NeighbourSystem type, int index) 39 private int[] Neighbours(NeighbourSystem type, int index)
44 { 40 {
@@ -138,4 +134,4 @@ namespace libTerrain
138 return coord; 134 return coord;
139 } 135 }
140 } 136 }
141} 137} \ No newline at end of file
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs
index 0306e58..ae7530c 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs
@@ -27,8 +27,6 @@
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic;
31using System.Text;
32 30
33namespace libTerrain 31namespace libTerrain
34{ 32{
@@ -138,7 +136,7 @@ namespace libTerrain
138 { 136 {
139 for (y = 0; y < A.h; y++) 137 for (y = 0; y < A.h; y++)
140 { 138 {
141 A.map[x, y] = Math.Pow(A.map[x,y],B.map[x, y]); 139 A.map[x, y] = Math.Pow(A.map[x, y], B.map[x, y]);
142 } 140 }
143 } 141 }
144 142
@@ -230,7 +228,7 @@ namespace libTerrain
230 { 228 {
231 for (y = 0; y < A.h; y++) 229 for (y = 0; y < A.h; y++)
232 { 230 {
233 A.map[x, y] = Math.Pow(A.map[x,y],B); 231 A.map[x, y] = Math.Pow(A.map[x, y], B);
234 } 232 }
235 } 233 }
236 234
@@ -238,6 +236,5 @@ namespace libTerrain
238 236
239 return A; 237 return A;
240 } 238 }
241
242 } 239 }
243} 240} \ No newline at end of file
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Tools/Point2D.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Tools/Point2D.cs
index 9985f03..1d52da9 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Tools/Point2D.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Tools/Point2D.cs
@@ -26,10 +26,6 @@
26* 26*
27*/ 27*/
28 28
29using System;
30using System.Collections.Generic;
31using System.Text;
32
33namespace libTerrain 29namespace libTerrain
34{ 30{
35 public class Point2D 31 public class Point2D
@@ -43,4 +39,4 @@ namespace libTerrain
43 y = Y; 39 y = Y;
44 } 40 }
45 } 41 }
46} 42} \ No newline at end of file
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Tools/Tools.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Tools/Tools.cs
index 3207f15..d805794 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Tools/Tools.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Tools/Tools.cs
@@ -27,33 +27,34 @@
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic;
31using System.Text;
32 30
33namespace libTerrain 31namespace libTerrain
34{ 32{
35 class Tools 33 internal class Tools
36 { 34 {
37 public static double LinearInterpolate(double a, double b, double amount) 35 public static double LinearInterpolate(double a, double b, double amount)
38 { 36 {
39 return a + ((b - a) * amount); 37 return a + ((b - a)*amount);
40 } 38 }
41 39
42 public static double ExponentialInterpolate(double a, double b, double amount) 40 public static double ExponentialInterpolate(double a, double b, double amount)
43 { 41 {
44 a = Math.Pow(a, amount); 42 a = Math.Pow(a, amount);
45 b = Math.Pow(b - a, 1.0 - amount); 43 b = Math.Pow(b - a, 1.0 - amount);
46 return a+b; 44 return a + b;
47 } 45 }
48 46
49 public static int PowerOf2Log2(int n) { 47 public static int PowerOf2Log2(int n)
50 for (int i = 0; i < 31; i++) { 48 {
51 if ((n & 1) == 1) { 49 for (int i = 0; i < 31; i++)
52 return i; 50 {
53 } 51 if ((n & 1) == 1)
54 n >>= 1; 52 {
55 } 53 return i;
56 return 0; 54 }
57 } 55 n >>= 1;
56 }
57 return 0;
58 }
58 } 59 }
59} 60} \ No newline at end of file