From 67e12b95ea7b68f4904a7484d77ecfd787d16d0c Mon Sep 17 00:00:00 2001
From: lbsa71
Date: Tue, 30 Oct 2007 09:05:31 +0000
Subject: * Optimized usings * Shortened type references * Removed redundant
'this' qualifier
---
.../Properties/AssemblyInfo.cs | 31 ++--
.../Region/Terrain.BasicTerrain/TerrainEngine.cs | 169 +++++++++++----------
.../Region/Terrain.BasicTerrain/TerrainFilter.cs | 8 +-
.../libTerrainBSD/Bitmap/Bitmap.cs | 20 ++-
.../libTerrainBSD/Channel/Channel.cs | 18 +--
.../libTerrainBSD/Channel/Common.cs | 33 ++--
.../libTerrainBSD/Channel/Editing/Flatten.cs | 29 ++--
.../libTerrainBSD/Channel/Editing/Raise.cs | 14 +-
.../libTerrainBSD/Channel/File.cs | 15 +-
.../libTerrainBSD/Channel/Generators/Fracture.cs | 10 +-
.../libTerrainBSD/Channel/Generators/Gradient.cs | 5 -
.../Channel/Generators/HillPlanter.cs | 77 +++++-----
.../libTerrainBSD/Channel/Generators/Noise.cs | 4 +-
.../libTerrainBSD/Channel/Generators/Spiral.cs | 47 +++---
.../libTerrainBSD/Channel/Generators/Voronoi.cs | 35 +++--
.../libTerrainBSD/Channel/Generators/Worms.cs | 14 +-
.../libTerrainBSD/Channel/Grid.cs | 42 +++--
.../Channel/Manipulators/AerobicErosion.cs | 23 ++-
.../Channel/Manipulators/HydraulicErosion.cs | 19 ++-
.../Channel/Manipulators/NavierStokes.cs | 100 ++++++------
.../Channel/Manipulators/ThermalWeathering.cs | 18 +--
.../libTerrainBSD/Channel/Neighbours.cs | 10 +-
.../libTerrainBSD/Channel/Operators.cs | 9 +-
.../libTerrainBSD/Tools/Point2D.cs | 6 +-
.../libTerrainBSD/Tools/Tools.cs | 31 ++--
25 files changed, 379 insertions(+), 408 deletions(-)
(limited to 'OpenSim/Region/Terrain.BasicTerrain')
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 @@
-/*
+/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
@@ -27,25 +27,29 @@
*/
using System.Reflection;
using System.Runtime.InteropServices;
+
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
-[assembly: AssemblyTitle("OpenSim.Region.Terrain.BasicTerrain")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("OpenSim.Region.Terrain.BasicTerrain")]
-[assembly: AssemblyCopyright("Copyright © 2007")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
+
+[assembly : AssemblyTitle("OpenSim.Region.Terrain.BasicTerrain")]
+[assembly : AssemblyDescription("")]
+[assembly : AssemblyConfiguration("")]
+[assembly : AssemblyCompany("")]
+[assembly : AssemblyProduct("OpenSim.Region.Terrain.BasicTerrain")]
+[assembly : AssemblyCopyright("Copyright © 2007")]
+[assembly : AssemblyTrademark("")]
+[assembly : AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
+
+[assembly : ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("3263f5b5-0a41-4ed5-91a2-9baaaeecc849")]
+
+[assembly : Guid("3263f5b5-0a41-4ed5-91a2-9baaaeecc849")]
// Version information for an assembly consists of the following four values:
//
@@ -56,5 +60,6 @@ using System.Runtime.InteropServices;
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+
+[assembly : AssemblyVersion("1.0.0.0")]
+[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;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
+using System.Globalization;
using System.IO;
+using System.Threading;
using libTerrain;
using OpenJPEGNet;
-using OpenSim.Framework.Interfaces;
-using System.Globalization;
using OpenSim.Framework;
namespace OpenSim.Region.Terrain
@@ -51,7 +51,7 @@ namespace OpenSim.Region.Terrain
public class TerrainEngine
{
- public static System.Threading.Mutex fileIOLock = new System.Threading.Mutex();
+ public static Mutex fileIOLock = new Mutex();
///
/// Plugin library for scripts
@@ -95,12 +95,13 @@ namespace OpenSim.Region.Terrain
///
public int tainted;
- int w, h;
+ private int w, h;
///
/// Used to determine what offset to use when loading singular heightmaps across multiple sims
///
private int offsetX;
+
private int offsetY;
@@ -139,13 +140,13 @@ namespace OpenSim.Region.Terrain
public bool Tainted(int x, int y)
{
- return (heightmap.diff[x / 16, y / 16] != 0);
+ return (heightmap.diff[x/16, y/16] != 0);
}
public void ResetTaint()
{
tainted = 0;
- heightmap.diff = new int[w / 16, h / 16];
+ heightmap.diff = new int[w/16,h/16];
}
//Testing to see if moving the TerraForming packet handling code into here works well
@@ -158,40 +159,40 @@ namespace OpenSim.Region.Terrain
/// The action to be performed
/// Distance from the north border where the cursor is located
/// Distance from the west border where the cursor is located
- public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west, IClientAPI remoteUser)
+ public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west,
+ IClientAPI remoteUser)
{
-
// Shiny.
- double size = (double)(1 << brushsize);
+ double size = (double) (1 << brushsize);
switch (action)
{
case 0:
// flatten terrain
- this.FlattenTerrain(west, north, size, (double)seconds / 5.0);
+ FlattenTerrain(west, north, size, (double) seconds/5.0);
break;
case 1:
// raise terrain
- this.RaiseTerrain(west, north, size, (double)seconds / 5.0);
+ RaiseTerrain(west, north, size, (double) seconds/5.0);
break;
case 2:
//lower terrain
- this.LowerTerrain(west, north, size, (double)seconds / 5.0);
+ LowerTerrain(west, north, size, (double) seconds/5.0);
break;
case 3:
// smooth terrain
- this.SmoothTerrain(west, north, size, (double)seconds / 5.0);
+ SmoothTerrain(west, north, size, (double) seconds/5.0);
break;
case 4:
// noise
- this.NoiseTerrain(west, north, size, (double)seconds / 5.0);
+ NoiseTerrain(west, north, size, (double) seconds/5.0);
break;
case 5:
// revert
- this.RevertTerrain(west, north, size, (double)seconds / 5.0);
+ RevertTerrain(west, north, size, (double) seconds/5.0);
break;
- // CLIENT EXTENSIONS GO HERE
+ // CLIENT EXTENSIONS GO HERE
case 128:
// erode-thermal
break;
@@ -207,9 +208,9 @@ namespace OpenSim.Region.Terrain
{
for (int y = 0; y < 16; y++)
{
- if (this.Tainted(x * 16, y * 16))
+ if (Tainted(x*16, y*16))
{
- remoteUser.SendLayerData(x, y, this.GetHeights1D());
+ remoteUser.SendLayerData(x, y, GetHeights1D());
}
}
}
@@ -249,12 +250,12 @@ namespace OpenSim.Region.Terrain
/// A float[65536] array containing the heightmap
public float[] GetHeights1D()
{
- float[] heights = new float[w * h];
+ float[] heights = new float[w*h];
int i;
- for (i = 0; i < w * h; i++)
+ for (i = 0; i < w*h; i++)
{
- heights[i] = (float)heightmap.map[i % w, i / w];
+ heights[i] = (float) heightmap.map[i%w, i/w];
}
return heights;
@@ -266,13 +267,13 @@ namespace OpenSim.Region.Terrain
/// An array of 256,256 values containing the heightmap
public float[,] GetHeights2D()
{
- float[,] heights = new float[w, h];
+ float[,] heights = new float[w,h];
int x, y;
for (x = 0; x < w; x++)
{
for (y = 0; y < h; y++)
{
- heights[x, y] = (float)heightmap.map[x, y];
+ heights[x, y] = (float) heightmap.map[x, y];
}
}
return heights;
@@ -294,9 +295,9 @@ namespace OpenSim.Region.Terrain
public void GetHeights1D(float[] heights)
{
int i;
- for (i = 0; i < w * h; i++)
+ for (i = 0; i < w*h; i++)
{
- heightmap.map[i % w, i / w] = heights[i];
+ heightmap.map[i%w, i/w] = heights[i];
}
tainted++;
@@ -313,7 +314,7 @@ namespace OpenSim.Region.Terrain
{
for (y = 0; y < h; y++)
{
- heightmap.Set(x, y, (double)heights[x, y]);
+ heightmap.Set(x, y, (double) heights[x, y]);
}
}
SaveRevertMap();
@@ -376,28 +377,36 @@ namespace OpenSim.Region.Terrain
try
{
-
switch (command)
{
case "help":
resultText += "terrain regenerate - rebuilds the sims terrain using a default algorithm\n";
- resultText += "terrain hills \n";
+ resultText +=
+ "terrain hills \n";
resultText += " type should be spheres, blocks, cones, or squared\n";
- resultText += "terrain voronoi - generates a worley fractal with X points per block";
+ resultText +=
+ "terrain voronoi - generates a worley fractal with X points per block";
resultText += "terrain seed - sets the random seed value to \n";
- resultText += "terrain load - loads a terrain from disk, type can be 'F32', 'F64', 'RAW' or 'IMG'\n";
- resultText += "terrain save - saves a terrain to disk, type can be 'F32', 'F64', 'PNG', 'RAW' or 'HIRAW'\n";
- resultText += "terrain save grdmap - creates a PNG snapshot of the region using a named gradient map\n";
- resultText += "terrain rescale - rescales a terrain to be between and meters high\n";
+ resultText +=
+ "terrain load - loads a terrain from disk, type can be 'F32', 'F64', 'RAW' or 'IMG'\n";
+ resultText +=
+ "terrain save - saves a terrain to disk, type can be 'F32', 'F64', 'PNG', 'RAW' or 'HIRAW'\n";
+ resultText +=
+ "terrain save grdmap - creates a PNG snapshot of the region using a named gradient map\n";
+ resultText +=
+ "terrain rescale - rescales a terrain to be between and meters high\n";
resultText += "terrain fill - fills a terrain at the specified height\n";
- resultText += "terrain erode aerobic \n";
+ resultText +=
+ "terrain erode aerobic \n";
resultText += "terrain erode thermal \n";
resultText += "terrain erode hydraulic \n";
resultText += "terrain multiply - multiplies a terrain by \n";
resultText += "terrain revert - reverts the terrain to the stored original\n";
resultText += "terrain bake - saves the current terrain into the revert map\n";
- resultText += "terrain csfilter - loads a new filter from the specified .cs file\n";
- resultText += "terrain jsfilter - loads a new filter from the specified .js file\n";
+ resultText +=
+ "terrain csfilter - loads a new filter from the specified .cs file\n";
+ resultText +=
+ "terrain jsfilter - loads a new filter from the specified .js file\n";
foreach (KeyValuePair filter in customFilters.filters)
{
resultText += filter.Value.Help();
@@ -466,8 +475,8 @@ namespace OpenSim.Region.Terrain
case "load":
string filenameL = args[2].Replace("%name%", simName);
- filenameL = filenameL.Replace("%x%", this.offsetX.ToString());
- filenameL = filenameL.Replace("%y%", this.offsetY.ToString());
+ filenameL = filenameL.Replace("%x%", offsetX.ToString());
+ filenameL = filenameL.Replace("%y%", offsetY.ToString());
switch (args[1].ToLower())
{
@@ -499,11 +508,11 @@ namespace OpenSim.Region.Terrain
{
case "f32":
LoadFromFileF32(args[2], Convert.ToInt32(args[3]), Convert.ToInt32(args[4]),
- Convert.ToInt32(args[5]), Convert.ToInt32(args[6]));
+ Convert.ToInt32(args[5]), Convert.ToInt32(args[6]));
break;
case "img":
LoadFromFileIMG(args[2], Convert.ToInt32(args[3]), Convert.ToInt32(args[4]),
- Convert.ToInt32(args[5]), Convert.ToInt32(args[6]));
+ Convert.ToInt32(args[5]), Convert.ToInt32(args[6]));
break;
default:
resultText = "Unknown or unsupported image or data format";
@@ -513,8 +522,8 @@ namespace OpenSim.Region.Terrain
case "save":
string filename = args[2].Replace("%name%", simName);
- filename = filename.Replace("%x%", this.offsetX.ToString());
- filename = filename.Replace("%y%", this.offsetY.ToString());
+ filename = filename.Replace("%x%", offsetX.ToString());
+ filename = filename.Replace("%y%", offsetY.ToString());
switch (args[1].ToLower())
{
@@ -589,15 +598,20 @@ namespace OpenSim.Region.Terrain
{
case "aerobic":
// WindSpeed, PickupMinimum,DropMinimum,Carry,Rounds,Lowest
- 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]));
+ 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]));
break;
case "thermal":
- heightmap.ThermalWeathering(Convert.ToDouble(args[2]), Convert.ToInt32(args[3]), Convert.ToDouble(args[4]));
+ heightmap.ThermalWeathering(Convert.ToDouble(args[2]), Convert.ToInt32(args[3]),
+ Convert.ToDouble(args[4]));
break;
case "hydraulic":
Channel rainMap = new Channel(w, h);
rainMap.Fill(Convert.ToDouble(args[2]));
- heightmap.HydraulicErosion(rainMap, Convert.ToDouble(args[3]), Convert.ToDouble(args[4]), Convert.ToInt32(args[5]), Convert.ToInt32(args[6]));
+ heightmap.HydraulicErosion(rainMap, Convert.ToDouble(args[3]), Convert.ToDouble(args[4]),
+ Convert.ToInt32(args[5]), Convert.ToInt32(args[6]));
break;
default:
resultText = "Unknown erosion type";
@@ -624,8 +638,10 @@ namespace OpenSim.Region.Terrain
if (args.GetLength(0) > 2)
{
int.TryParse(args[2].ToString(), out count);
- double.TryParse(args[3].ToString(), NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo, out sizeMin);
- double.TryParse(args[4].ToString(), NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo, out sizeRange);
+ double.TryParse(args[3].ToString(), NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo,
+ out sizeMin);
+ double.TryParse(args[4].ToString(), NumberStyles.AllowDecimalPoint, Culture.NumberFormatInfo,
+ out sizeRange);
bool.TryParse(args[5].ToString(), out island);
bool.TryParse(args[6].ToString(), out additive);
bool.TryParse(args[7].ToString(), out noisy);
@@ -669,7 +685,7 @@ namespace OpenSim.Region.Terrain
/// Maximum value of the new array
public void SetRange(float min, float max)
{
- heightmap.Normalise((double)min, (double)max);
+ heightmap.Normalise((double) min, (double) max);
tainted++;
}
@@ -713,7 +729,7 @@ namespace OpenSim.Region.Terrain
{
for (x = 0; x < w; x++)
{
- heightmap.map[x, y] = (double)bs.ReadSingle();
+ heightmap.map[x, y] = (double) bs.ReadSingle();
}
}
@@ -736,11 +752,10 @@ namespace OpenSim.Region.Terrain
fileIOLock.WaitOne();
try
{
+ int sectionToLoadX = ((offsetX - lowerboundX)*w);
+ int sectionToLoadY = ((offsetY - lowerboundY)*h);
- int sectionToLoadX = ((this.offsetX - lowerboundX) * this.w);
- int sectionToLoadY = ((this.offsetY - lowerboundY) * this.h);
-
- double[,] tempMap = new double[dimensionX, dimensionY];
+ double[,] tempMap = new double[dimensionX,dimensionY];
FileInfo file = new FileInfo(filename);
FileStream s = file.Open(FileMode.Open, FileAccess.Read);
@@ -751,7 +766,7 @@ namespace OpenSim.Region.Terrain
{
for (y = 0; y < dimensionY; y++)
{
- tempMap[x, y] = (double)bs.ReadSingle();
+ tempMap[x, y] = (double) bs.ReadSingle();
}
}
@@ -784,19 +799,19 @@ namespace OpenSim.Region.Terrain
/// Where sim coords begin for this patch
public void LoadFromFileIMG(string filename, int dimensionX, int dimensionY, int lowerboundX, int lowerboundY)
{
- int sectionToLoadX = ((this.offsetX - lowerboundX) * this.w);
- int sectionToLoadY = ((this.offsetY - lowerboundY) * this.h);
+ int sectionToLoadX = ((offsetX - lowerboundX)*w);
+ int sectionToLoadY = ((offsetY - lowerboundY)*h);
- double[,] tempMap = new double[dimensionX, dimensionY];
+ double[,] tempMap = new double[dimensionX,dimensionY];
- System.Drawing.Bitmap lgrBmp = new Bitmap(filename);
+ Bitmap lgrBmp = new Bitmap(filename);
int x, y;
for (x = 0; x < dimensionX; x++)
{
for (y = 0; y < dimensionY; y++)
{
- tempMap[x, y] = (float)lgrBmp.GetPixel(x, y).GetBrightness();
+ tempMap[x, y] = (float) lgrBmp.GetPixel(x, y).GetBrightness();
}
}
@@ -826,7 +841,7 @@ namespace OpenSim.Region.Terrain
{
for (x = 0; x < w; x++)
{
- heightmap.map[x, y] = (double)bs.ReadByte() * ((double)bs.ReadByte() / 127.0);
+ heightmap.map[x, y] = (double) bs.ReadByte()*((double) bs.ReadByte()/127.0);
bs.ReadBytes(11); // Advance the stream to next bytes.
}
}
@@ -875,7 +890,7 @@ namespace OpenSim.Region.Terrain
{
for (x = 0; x < w; x++)
{
- bs.Write((float)heightmap.Get(x, y));
+ bs.Write((float) heightmap.Get(x, y));
}
}
@@ -897,27 +912,27 @@ namespace OpenSim.Region.Terrain
int x, y;
// Used for the 'green' channel.
- byte avgMultiplier = (byte)heightmap.Avg();
- byte backupMultiplier = (byte)revertmap.Avg();
+ byte avgMultiplier = (byte) heightmap.Avg();
+ byte backupMultiplier = (byte) revertmap.Avg();
// Limit the multiplier so it can represent points >64m.
if (avgMultiplier > 196)
avgMultiplier = 196;
- if(backupMultiplier > 196)
+ if (backupMultiplier > 196)
backupMultiplier = 196;
// Make sure it's at least one to prevent a div by zero
if (avgMultiplier < 1)
avgMultiplier = 1;
- if(backupMultiplier < 1)
+ if (backupMultiplier < 1)
backupMultiplier = 1;
for (y = 0; y < h; y++)
{
for (x = 0; x < h; x++)
{
- byte red = (byte)(heightmap.Get(x, y) / ((double)avgMultiplier / 128.0));
+ byte red = (byte) (heightmap.Get(x, y)/((double) avgMultiplier/128.0));
byte green = avgMultiplier;
- byte blue = (byte)watermap.Get(x, y);
+ byte blue = (byte) watermap.Get(x, y);
byte alpha1 = 0; // Land Parcels
byte alpha2 = 0; // For Sale Land
byte alpha3 = 0; // Public Edit Object
@@ -926,7 +941,7 @@ namespace OpenSim.Region.Terrain
byte alpha6 = 255; // Flying Allowed
byte alpha7 = 255; // Create Landmark
byte alpha8 = 255; // Outside Scripts
- byte alpha9 = (byte)(revertmap.Get(x, y) / ((double)backupMultiplier / 128.0));
+ byte alpha9 = (byte) (revertmap.Get(x, y)/((double) backupMultiplier/128.0));
byte alpha10 = backupMultiplier;
binStream.Write(red);
@@ -966,7 +981,7 @@ namespace OpenSim.Region.Terrain
{
for (j = 0; j < 256; j++)
{
- lookupHeightTable[i + (j * 256)] = ((double)i * ((double)j / 127.0));
+ lookupHeightTable[i + (j*256)] = ((double) i*((double) j/127.0));
}
}
@@ -988,9 +1003,9 @@ namespace OpenSim.Region.Terrain
}
}
- byte red = (byte)(index & 0xFF);
- byte green = (byte)((index >> 8) & 0xFF);
- byte blue = (byte)watermap.Get(x, y);
+ byte red = (byte) (index & 0xFF);
+ byte green = (byte) ((index >> 8) & 0xFF);
+ byte blue = (byte) watermap.Get(x, y);
byte alpha1 = 0; // Land Parcels
byte alpha2 = 0; // For Sale Land
byte alpha3 = 0; // Public Edit Object
@@ -1140,7 +1155,7 @@ namespace OpenSim.Region.Terrain
smoothed.Smooth(amount);
Channel mask = new Channel();
- mask.Raise(rx,ry,size,amount);
+ mask.Raise(rx, ry, size, amount);
heightmap.Blend(smoothed, mask);
}
@@ -1221,8 +1236,7 @@ namespace OpenSim.Region.Terrain
{
Bitmap bmp = TerrainToBitmap(gradientmap);
- imageData = OpenJPEG.EncodeFromImage(bmp, true );
-
+ imageData = OpenJPEG.EncodeFromImage(bmp, true);
}
catch (Exception e)
{
@@ -1252,12 +1266,11 @@ namespace OpenSim.Region.Terrain
for (int x = 0; x < copy.w; x++)
{
// 512 is the largest possible height before colours clamp
- int colorindex = (int)(Math.Max(Math.Min(1.0, copy.Get(x, y) / 512.0), 0.0) * (pallete - 1));
+ int colorindex = (int) (Math.Max(Math.Min(1.0, copy.Get(x, y)/512.0), 0.0)*(pallete - 1));
bmp.SetPixel(x, y, colours[colorindex]);
}
}
return bmp;
}
-
}
-}
+}
\ 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
{
foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes())
{
- Type testInterface = pluginType.GetInterface("ITerrainFilter",true);
+ Type testInterface = pluginType.GetInterface("ITerrainFilter", true);
if (testInterface != null)
{
- ITerrainFilter filter = (ITerrainFilter)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString());
+ ITerrainFilter filter =
+ (ITerrainFilter) compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString());
string filterName = filter.Register();
Console.WriteLine("Plugin: " + filterName + " loaded.");
@@ -107,7 +108,6 @@ namespace OpenSim.Region.Terrain
}
}
}
-
}
public void LoadFilterCSharp(string filename)
@@ -122,4 +122,4 @@ namespace OpenSim.Region.Terrain
LoadFilter(compiler, filename);
}
}
-}
+}
\ 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 @@
*
*/
-using System;
-using System.Collections.Generic;
-using System.Text;
using System.Drawing;
+using System.Drawing.Imaging;
namespace libTerrain
{
- class Raster
+ internal class Raster
{
- int w;
- int h;
- Bitmap bmp;
+ private int w;
+ private int h;
+ private Bitmap bmp;
///
/// Creates a new Raster channel for use with bitmap or GDI functions
@@ -48,7 +46,7 @@ namespace libTerrain
{
w = width;
h = height;
- bmp = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
+ bmp = new Bitmap(width, height, PixelFormat.Format24bppRgb);
}
///
@@ -65,7 +63,7 @@ namespace libTerrain
for (y = 0; y < bmp.Height; y++)
{
Color val = bmp.GetPixel(x, y);
- chan.map[x, y] = (((double)val.R + (double)val.G + (double)val.B) / 3.0) / 255.0;
+ chan.map[x, y] = (((double) val.R + (double) val.G + (double) val.B)/3.0)/255.0;
}
}
@@ -86,7 +84,7 @@ namespace libTerrain
sf.LineAlignment = StringAlignment.Center;
Graphics gd = Graphics.FromImage(bmp);
- gd.DrawString(txt, new Font(font, (float)size), new SolidBrush(Color.White), area, sf);
+ gd.DrawString(txt, new Font(font, (float) size), new SolidBrush(Color.White), area, sf);
}
}
-}
+}
\ 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 @@
*
*/
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-
-/* Channel
+ /* Channel
* A channel is a single heightmap array
* */
@@ -50,17 +45,16 @@ namespace libTerrain
{
w = 256;
h = 256;
- map = new double[w, h];
- diff = new int[(int)(w / 16), (int)(h / 16)];
+ map = new double[w,h];
+ diff = new int[(int) (w/16),(int) (h/16)];
}
public Channel(int width, int height)
{
w = width;
h = height;
- map = new double[w, h];
- diff = new int[(int)(w / 16), (int)(h / 16)];
+ map = new double[w,h];
+ diff = new int[(int) (w/16),(int) (h/16)];
}
-
}
-}
+}
\ 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 @@
using System;
-using System.Collections.Generic;
-using System.Text;
namespace libTerrain
{
@@ -39,6 +37,7 @@ namespace libTerrain
{
return w;
}
+
public int GetHeight()
{
return h;
@@ -47,7 +46,7 @@ namespace libTerrain
public Channel Copy()
{
Channel x = new Channel(w, h);
- x.map = (double[,])this.map.Clone();
+ x.map = (double[,]) map.Clone();
return x;
}
@@ -58,9 +57,9 @@ namespace libTerrain
public void SetDiff(int val)
{
- for (int x = 0; x < w / 16; x++)
+ for (int x = 0; x < w/16; x++)
{
- for (int y = 0; y < h / 16; y++)
+ for (int y = 0; y < h/16; y++)
{
diff[x, y] = val;
}
@@ -69,7 +68,7 @@ namespace libTerrain
public void SetDiff(int x, int y)
{
- diff[x / 16, y / 16]++;
+ diff[x/16, y/16]++;
}
public void Set(int x, int y, double val)
@@ -124,10 +123,10 @@ namespace libTerrain
y = 0.0;
int stepSize = 1;
- double h00 = Get((int)x, (int)y);
- double h10 = Get((int)x + stepSize, (int)y);
- double h01 = Get((int)x, (int)y + stepSize);
- double h11 = Get((int)x + stepSize, (int)y + stepSize);
+ double h00 = Get((int) x, (int) y);
+ double h10 = Get((int) x + stepSize, (int) y);
+ double h01 = Get((int) x, (int) y + stepSize);
+ double h11 = Get((int) x + stepSize, (int) y + stepSize);
double h1 = h00;
double h2 = h10;
double h3 = h01;
@@ -136,9 +135,9 @@ namespace libTerrain
double a10 = h2 - h1;
double a01 = h3 - h1;
double a11 = h1 - h2 - h3 + h4;
- double partialx = x - (int)x;
- double partialz = y - (int)y;
- double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz);
+ double partialx = x - (int) x;
+ double partialz = y - (int) y;
+ double hi = a00 + (a10*partialx) + (a01*partialz) + (a11*partialx*partialz);
return hi;
}
@@ -159,7 +158,7 @@ namespace libTerrain
{
SetDiff(x, y);
- map[x % w, y % h] = val;
+ map[x%w, y%h] = val;
}
public void SetWrapClip(int x, int y, double val)
@@ -171,7 +170,7 @@ namespace libTerrain
if (val < 0.0)
val = 0.0;
- map[x % w, y % h] = val;
+ map[x%w, y%h] = val;
}
public void Fill(double val)
@@ -255,7 +254,7 @@ namespace libTerrain
public double Avg()
{
- return Sum() / (w * h);
+ return Sum()/(w*h);
}
public bool ContainsNaN()
@@ -274,4 +273,4 @@ namespace libTerrain
return false;
}
}
-}
+}
\ 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 @@
using System;
-using System.Collections.Generic;
-using System.Text;
namespace libTerrain
{
@@ -58,12 +56,12 @@ namespace libTerrain
// Establish the average height under the area
Channel newmap = new Channel(w, h);
- newmap.map = (double[,])map.Clone();
+ newmap.map = (double[,]) map.Clone();
newmap *= temp;
double total_terrain = newmap.Sum();
- double avg_height = total_terrain / total_mod;
+ double avg_height = total_terrain/total_mod;
// Create a flat terrain using the average height
Channel flat = new Channel(w, h);
@@ -72,7 +70,6 @@ namespace libTerrain
// Blend the current terrain with the average height terrain
// using the "raised" empty terrain as a mask
Blend(flat, temp);
-
}
private void FlattenFast(double rx, double ry, double size, double amount)
@@ -81,10 +78,10 @@ namespace libTerrain
double avg = 0;
double div = 0;
- int minX = Math.Max(0, (int)(rx - (size + 1)));
- int maxX = Math.Min(w, (int)(rx + (size + 1)));
- int minY = Math.Max(0, (int)(ry - (size + 1)));
- int maxY = Math.Min(h, (int)(ry + (size + 1)));
+ int minX = Math.Max(0, (int) (rx - (size + 1)));
+ int maxX = Math.Min(w, (int) (rx + (size + 1)));
+ int minY = Math.Max(0, (int) (ry - (size + 1)));
+ int maxY = Math.Min(h, (int) (ry + (size + 1)));
for (x = minX; x < maxX; x++)
{
@@ -92,17 +89,17 @@ namespace libTerrain
{
double z = size;
z *= z;
- z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
+ z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry));
if (z < 0)
z = 0;
- avg += z * amount;
+ avg += z*amount;
div += z;
}
}
- double height = avg / div;
+ double height = avg/div;
for (x = minX; x < maxX; x++)
{
@@ -110,7 +107,7 @@ namespace libTerrain
{
double z = size;
z *= z;
- z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
+ z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry));
if (z < 0)
z = 0;
@@ -123,19 +120,19 @@ namespace libTerrain
public void Flatten(Channel mask, double amount)
{
// Generate the mask
- Channel temp = mask * amount;
+ Channel temp = mask*amount;
temp.Clip(0, 1); // Cut off out-of-bounds values
double total_mod = temp.Sum();
// Establish the average height under the area
Channel map = new Channel(w, h);
- map.map = (double[,])this.map.Clone();
+ map.map = (double[,]) this.map.Clone();
map *= temp;
double total_terrain = map.Sum();
- double avg_height = total_terrain / total_mod;
+ double avg_height = total_terrain/total_mod;
// Create a flat terrain using the average height
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 @@
using System;
-using System.Collections.Generic;
-using System.Text;
namespace libTerrain
{
@@ -63,12 +61,12 @@ namespace libTerrain
{
double z = size;
z *= z;
- z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
+ z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry));
if (z < 0)
z = 0;
- Set(x, y, map[x, y] + (z * amount));
+ Set(x, y, map[x, y] + (z*amount));
}
}
}
@@ -88,12 +86,12 @@ namespace libTerrain
for (y = 0; y < h; y++)
{
double z = size;
- z -= Math.Sqrt(((x - rx) * (x - rx)) + ((y - ry) * (y - ry)));
+ z -= Math.Sqrt(((x - rx)*(x - rx)) + ((y - ry)*(y - ry)));
if (z < 0)
z = 0;
- Set(x, y, map[x, y] + (z * amount));
+ Set(x, y, map[x, y] + (z*amount));
}
}
}
@@ -126,12 +124,12 @@ namespace libTerrain
{
double z = size;
z *= z;
- z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
+ z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry));
if (z < 0)
z = 0;
- Set(x, y, map[x, y] - (z * amount));
+ Set(x, y, map[x, y] - (z*amount));
}
}
}
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 @@
*/
using System;
-using System.Collections.Generic;
-using System.Text;
using System.Drawing;
+using System.Drawing.Imaging;
namespace libTerrain
{
@@ -48,7 +47,7 @@ namespace libTerrain
for (y = 0; y < bit.Height; y++)
{
Color val = bit.GetPixel(x, y);
- chan.map[x, y] = (((double)val.R + (double)val.G + (double)val.B) / 3.0) / 255.0;
+ chan.map[x, y] = (((double) val.R + (double) val.G + (double) val.B)/3.0)/255.0;
}
}
@@ -57,21 +56,21 @@ namespace libTerrain
public void SaveImage(string filename)
{
- Channel outmap = this.Copy();
+ Channel outmap = Copy();
outmap.Normalise();
- Bitmap bit = new Bitmap(w, h, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
+ Bitmap bit = new Bitmap(w, h, PixelFormat.Format24bppRgb);
int x, y;
for (x = 0; x < w; x++)
{
for (y = 0; y < h; y++)
{
- int val = Math.Min(255, (int)(outmap.map[x,y] * 255));
- Color col = Color.FromArgb(val,val,val);
+ int val = Math.Min(255, (int) (outmap.map[x, y]*255));
+ Color col = Color.FromArgb(val, val, val);
bit.SetPixel(x, y, col);
}
}
bit.Save(filename);
}
}
-}
+}
\ 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 @@
*/
using System;
-using System.Collections.Generic;
-using System.Text;
namespace libTerrain
{
@@ -60,19 +58,19 @@ namespace libTerrain
}
if (val < 512)
{
- ret[0] = (val % 256);
+ ret[0] = (val%256);
ret[1] = 255;
return ret;
}
if (val < 768)
{
ret[0] = 255;
- ret[1] = 255 - (val % 256);
+ ret[1] = 255 - (val%256);
return ret;
}
if (val < 1024)
{
- ret[0] = 255 - (val % 256);
+ ret[0] = 255 - (val%256);
ret[1] = 255;
return ret;
}
@@ -100,7 +98,7 @@ namespace libTerrain
{
for (int y = 0; y < h; y++)
{
- double miny = Tools.LinearInterpolate(a[1], b[1], (double)x / (double)w);
+ double miny = Tools.LinearInterpolate(a[1], b[1], (double) x/(double) w);
if (v >= 0.5)
{
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 @@
*
*/
-using System;
-using System.Collections.Generic;
-using System.Text;
-
namespace libTerrain
{
partial class Channel
{
-
public void GradientCube()
{
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 @@
*/
using System;
-using System.Collections.Generic;
-using System.Text;
namespace libTerrain
{
@@ -44,7 +42,8 @@ namespace libTerrain
/// Whether to bias hills towards the center of the map
/// Whether to add hills together or to pick the largest value
/// Generates hill-shaped noise instead of consistent hills
- public void HillsSpheres(int number, double scale_min, double scale_range, bool island, bool additive, bool noisy)
+ public void HillsSpheres(int number, double scale_min, double scale_range, bool island, bool additive,
+ bool noisy)
{
SetDiff();
@@ -55,20 +54,20 @@ namespace libTerrain
for (i = 0; i < number; i++)
{
- double rx = Math.Min(255.0, random.NextDouble() * w);
- double ry = Math.Min(255.0, random.NextDouble() * h);
+ double rx = Math.Min(255.0, random.NextDouble()*w);
+ double ry = Math.Min(255.0, random.NextDouble()*h);
double rand = random.NextDouble();
if (island)
{
// Move everything towards the center
- rx -= w / 2;
+ rx -= w/2;
rx /= 2;
- rx += w / 2;
+ rx += w/2;
- ry -= h / 2;
+ ry -= h/2;
ry /= 2;
- ry += h / 2;
+ ry += h/2;
}
for (x = 0; x < w; x++)
@@ -78,9 +77,9 @@ namespace libTerrain
if (noisy)
rand = random.NextDouble();
- double z = (scale_min + (scale_range * rand));
+ double z = (scale_min + (scale_range*rand));
z *= z;
- z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
+ z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry));
if (z < 0)
z = 0;
@@ -121,20 +120,20 @@ namespace libTerrain
for (i = 0; i < number; i++)
{
- double rx = Math.Min(255.0, random.NextDouble() * w);
- double ry = Math.Min(255.0, random.NextDouble() * h);
+ double rx = Math.Min(255.0, random.NextDouble()*w);
+ double ry = Math.Min(255.0, random.NextDouble()*h);
double rand = random.NextDouble();
if (island)
{
// Move everything towards the center
- rx -= w / 2;
+ rx -= w/2;
rx /= 2;
- rx += w / 2;
+ rx += w/2;
- ry -= h / 2;
+ ry -= h/2;
ry /= 2;
- ry += h / 2;
+ ry += h/2;
}
for (x = 0; x < w; x++)
@@ -144,8 +143,8 @@ namespace libTerrain
if (noisy)
rand = random.NextDouble();
- double z = (scale_min + (scale_range * rand));
- z -= Math.Sqrt(((x - rx) * (x - rx)) + ((y - ry) * (y - ry)));
+ double z = (scale_min + (scale_range*rand));
+ z -= Math.Sqrt(((x - rx)*(x - rx)) + ((y - ry)*(y - ry)));
if (z < 0)
z = 0;
@@ -176,20 +175,20 @@ namespace libTerrain
for (i = 0; i < number; i++)
{
- double rx = Math.Min(255.0, random.NextDouble() * w);
- double ry = Math.Min(255.0, random.NextDouble() * h);
+ double rx = Math.Min(255.0, random.NextDouble()*w);
+ double ry = Math.Min(255.0, random.NextDouble()*h);
double rand = random.NextDouble();
if (island)
{
// Move everything towards the center
- rx -= w / 2;
+ rx -= w/2;
rx /= 2;
- rx += w / 2;
+ rx += w/2;
- ry -= h / 2;
+ ry -= h/2;
ry /= 2;
- ry += h / 2;
+ ry += h/2;
}
for (x = 0; x < w; x++)
@@ -199,8 +198,8 @@ namespace libTerrain
if (noisy)
rand = random.NextDouble();
- double z = (scale_min + (scale_range * rand));
- z -= Math.Abs(x-rx) + Math.Abs(y-ry);
+ double z = (scale_min + (scale_range*rand));
+ z -= Math.Abs(x - rx) + Math.Abs(y - ry);
//z -= Math.Sqrt(((x - rx) * (x - rx)) + ((y - ry) * (y - ry)));
if (z < 0)
@@ -221,7 +220,8 @@ namespace libTerrain
Normalise();
}
- public void HillsSquared(int number, double scale_min, double scale_range, bool island, bool additive, bool noisy)
+ public void HillsSquared(int number, double scale_min, double scale_range, bool island, bool additive,
+ bool noisy)
{
SetDiff();
@@ -232,20 +232,20 @@ namespace libTerrain
for (i = 0; i < number; i++)
{
- double rx = Math.Min(255.0, random.NextDouble() * w);
- double ry = Math.Min(255.0, random.NextDouble() * h);
+ double rx = Math.Min(255.0, random.NextDouble()*w);
+ double ry = Math.Min(255.0, random.NextDouble()*h);
double rand = random.NextDouble();
if (island)
{
// Move everything towards the center
- rx -= w / 2;
+ rx -= w/2;
rx /= 2;
- rx += w / 2;
+ rx += w/2;
- ry -= h / 2;
+ ry -= h/2;
ry /= 2;
- ry += h / 2;
+ ry += h/2;
}
for (x = 0; x < w; x++)
@@ -255,11 +255,11 @@ namespace libTerrain
if (noisy)
rand = random.NextDouble();
- double z = (scale_min + (scale_range * rand));
- z *= z * z * z;
+ double z = (scale_min + (scale_range*rand));
+ z *= z*z*z;
double dx = Math.Abs(x - rx);
double dy = Math.Abs(y - ry);
- z -= (dx * dx * dx * dx) + (dy * dy * dy * dy);
+ z -= (dx*dx*dx*dx) + (dy*dy*dy*dy);
if (z < 0)
z = 0;
@@ -278,6 +278,5 @@ namespace libTerrain
Normalise();
}
-
}
-}
+}
\ 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 @@
*/
using System;
-using System.Collections.Generic;
-using System.Text;
namespace libTerrain
{
@@ -53,4 +51,4 @@ namespace libTerrain
}
}
}
-}
+}
\ 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 @@
using System;
using System.Collections.Generic;
-using System.Text;
namespace libTerrain
{
@@ -36,10 +35,10 @@ namespace libTerrain
{
private double[] CoordinatesToPolar(int x, int y)
{
- double theta = Math.Atan2(x - (w / 2), y - (h / 2));
- double rx = (double)x - ((double)w / 2);
- double ry = (double)y - ((double)h / 2);
- double r = Math.Sqrt((rx * rx) + (ry * ry));
+ double theta = Math.Atan2(x - (w/2), y - (h/2));
+ double rx = (double) x - ((double) w/2);
+ double ry = (double) y - ((double) h/2);
+ double r = Math.Sqrt((rx*rx) + (ry*ry));
double[] coords = new double[2];
coords[0] = r;
@@ -47,15 +46,16 @@ namespace libTerrain
return coords;
}
- public int[] PolarToCoordinates(double r, double theta) {
+ public int[] PolarToCoordinates(double r, double theta)
+ {
double nx;
double ny;
- nx = (double)r * Math.Cos(theta);
- ny = (double)r * Math.Sin(theta);
+ nx = (double) r*Math.Cos(theta);
+ ny = (double) r*Math.Sin(theta);
- nx += w / 2;
- ny += h / 2;
+ nx += w/2;
+ ny += h/2;
if (nx >= w)
nx = w - 1;
@@ -70,8 +70,8 @@ namespace libTerrain
ny = 0;
int[] coords = new int[2];
- coords[0] = (int)nx;
- coords[1] = (int)ny;
+ coords[0] = (int) nx;
+ coords[1] = (int) ny;
return coords;
}
@@ -79,19 +79,19 @@ namespace libTerrain
{
SetDiff();
- Channel n = this.Copy();
+ Channel n = Copy();
int x, y;
for (x = 0; x < w; x++)
{
for (y = 0; y < h; y++)
{
- double[] coords = CoordinatesToPolar(x,y);
+ double[] coords = CoordinatesToPolar(x, y);
- coords[0] += w / 2.0;
- coords[1] += h / 2.0;
+ coords[0] += w/2.0;
+ coords[1] += h/2.0;
- map[x, y] = n.map[(int)coords[0] % n.w, (int)coords[1] % n.h];
+ map[x, y] = n.map[(int) coords[0]%n.w, (int) coords[1]%n.h];
}
}
}
@@ -108,12 +108,13 @@ namespace libTerrain
r += incRadius;
theta += incAngle;
- int[] coords = PolarToCoordinates(r,theta);
+ int[] coords = PolarToCoordinates(r, theta);
Raise(coords[0], coords[1], 20, 1);
}
}
- public void SpiralCells(int steps, double incAngle, double incRadius, double offsetRadius, double offsetAngle, double[] c)
+ public void SpiralCells(int steps, double incAngle, double incRadius, double offsetRadius, double offsetAngle,
+ double[] c)
{
SetDiff();
@@ -128,7 +129,7 @@ namespace libTerrain
theta += incAngle;
int[] coords = PolarToCoordinates(r, theta);
- points.Add(new Point2D(coords[0],coords[1]));
+ points.Add(new Point2D(coords[0], coords[1]));
}
VoronoiDiagram(points, c);
@@ -145,9 +146,9 @@ namespace libTerrain
for (y = 0; y < h; y++)
{
z++;
- double dx = Math.Abs((w / 2) - x);
- double dy = Math.Abs((h / 2) - y);
- map[x, y] += Math.Sin(dx / wid) + Math.Cos(dy / hig);
+ double dx = Math.Abs((w/2) - x);
+ double dy = Math.Abs((h/2) - y);
+ map[x, y] += Math.Sin(dx/wid) + Math.Cos(dy/hig);
}
}
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 @@
using System;
using System.Collections.Generic;
-using System.Text;
namespace libTerrain
{
@@ -57,8 +56,8 @@ namespace libTerrain
{
for (i = 0; i < pointsPerBlock; i++)
{
- double pX = x + (generator.NextDouble() * (double)blockSize);
- double pY = y + (generator.NextDouble() * (double)blockSize);
+ double pX = x + (generator.NextDouble()*(double) blockSize);
+ double pY = y + (generator.NextDouble()*(double) blockSize);
points.Add(new Point2D(pX, pY));
}
@@ -75,10 +74,10 @@ namespace libTerrain
for (i = 0; i < points.Count; i++)
{
double dx, dy;
- dx = Math.Abs((double)x - points[i].x);
- dy = Math.Abs((double)y - points[i].y);
+ dx = Math.Abs((double) x - points[i].x);
+ dy = Math.Abs((double) y - points[i].y);
- distances[i] = (dx * dx + dy * dy);
+ distances[i] = (dx*dx + dy*dy);
}
Array.Sort(distances);
@@ -92,7 +91,7 @@ namespace libTerrain
if (i >= points.Count)
break;
- f += c[i] * distances[i];
+ f += c[i]*distances[i];
}
map[x, y] = f;
@@ -119,10 +118,10 @@ namespace libTerrain
for (i = 0; i < points.Count; i++)
{
double dx, dy;
- dx = Math.Abs((double)x - points[i].x);
- dy = Math.Abs((double)y - points[i].y);
+ dx = Math.Abs((double) x - points[i].x);
+ dy = Math.Abs((double) y - points[i].y);
- distances[i] = (dx * dx + dy * dy);
+ distances[i] = (dx*dx + dy*dy);
}
Array.Sort(distances);
@@ -136,7 +135,7 @@ namespace libTerrain
if (i >= points.Count)
break;
- f += c[i] * distances[i];
+ f += c[i]*distances[i];
}
map[x, y] = f;
@@ -162,8 +161,8 @@ namespace libTerrain
{
for (i = 0; i < pointsPerBlock; i++)
{
- double pX = x + (generator.NextDouble() * (double)blockSize);
- double pY = y + (generator.NextDouble() * (double)blockSize);
+ double pX = x + (generator.NextDouble()*(double) blockSize);
+ double pY = y + (generator.NextDouble()*(double) blockSize);
points.Add(new Point2D(pX, pY));
}
@@ -180,10 +179,10 @@ namespace libTerrain
for (i = 0; i < points.Count; i++)
{
double dx, dy;
- dx = Math.Abs((double)x - points[i].x);
- dy = Math.Abs((double)y - points[i].y);
+ dx = Math.Abs((double) x - points[i].x);
+ dy = Math.Abs((double) y - points[i].y);
- distances[i] = (dx * dx + dy * dy);
+ distances[i] = (dx*dx + dy*dy);
}
//Array.Sort(distances);
@@ -191,7 +190,7 @@ namespace libTerrain
double f = 0.0;
double min = double.MaxValue;
- for (int j = 0; j < distances.Length;j++ )
+ for (int j = 0; j < distances.Length; j++)
{
if (distances[j] < min)
{
@@ -211,4 +210,4 @@ namespace libTerrain
Normalise();
}
}
-}
+}
\ 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 @@
*/
using System;
-using System.Collections.Generic;
-using System.Text;
namespace libTerrain
{
@@ -54,18 +52,18 @@ namespace libTerrain
double rx, ry;
if (centerspawn)
{
- rx = w / 2.0;
- ry = h / 2.0;
+ rx = w/2.0;
+ ry = h/2.0;
}
else
{
- rx = random.NextDouble() * (w - 1);
- ry = random.NextDouble() * (h - 1);
+ rx = random.NextDouble()*(w - 1);
+ ry = random.NextDouble()*(h - 1);
}
for (j = 0; j < rounds; j++)
{
- rx += (random.NextDouble() * movement) - (movement / 2.0);
- ry += (random.NextDouble() * movement) - (movement / 2.0);
+ rx += (random.NextDouble()*movement) - (movement/2.0);
+ ry += (random.NextDouble()*movement) - (movement/2.0);
Raise(rx, ry, size, 1.0);
}
}
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 @@
*/
using System;
-using System.Collections.Generic;
-using System.Text;
namespace libTerrain
{
@@ -49,13 +47,13 @@ namespace libTerrain
{
for (y = 0; y < h; y++)
{
- map[x, y] = (map[x, y] - min) * (1.0 / (max - min));
+ map[x, y] = (map[x, y] - min)*(1.0/(max - min));
}
}
}
else
{
- this.Fill(0.5);
+ Fill(0.5);
}
return this;
@@ -82,7 +80,7 @@ namespace libTerrain
{
if (min != max)
{
- double val = (map[x, y] - min) * (1.0 / max - min);
+ double val = (map[x, y] - min)*(1.0/max - min);
val *= maxv - minv;
val += minv;
@@ -179,9 +177,9 @@ namespace libTerrain
SetDiff();
double area = amount;
- double step = amount / 4.0;
+ double step = amount/4.0;
- double[,] manipulate = new double[w, h];
+ double[,] manipulate = new double[w,h];
int x, y;
double n, l;
for (x = 0; x < w; x++)
@@ -200,7 +198,7 @@ namespace libTerrain
}
}
- manipulate[x, y] = average / avgsteps;
+ manipulate[x, y] = average/avgsteps;
}
}
map = manipulate;
@@ -211,7 +209,7 @@ namespace libTerrain
SetDiff();
// Simple pertubation filter
- double[,] manipulated = new double[w, h];
+ double[,] manipulated = new double[w,h];
Random generator = new Random(seed); // Seeds FTW!
//double amount = 8.0;
@@ -220,8 +218,8 @@ namespace libTerrain
{
for (y = 0; y < h; y++)
{
- double offset_x = (double)x + (generator.NextDouble() * amount) - (amount / 2.0);
- double offset_y = (double)y + (generator.NextDouble() * amount) - (amount / 2.0);
+ double offset_x = (double) x + (generator.NextDouble()*amount) - (amount/2.0);
+ double offset_y = (double) y + (generator.NextDouble()*amount) - (amount/2.0);
double p = GetBilinearInterpolate(offset_x, offset_y);
manipulated[x, y] = p;
}
@@ -232,7 +230,7 @@ namespace libTerrain
public void PertubationMask(Channel mask)
{
// Simple pertubation filter
- double[,] manipulated = new double[w, h];
+ double[,] manipulated = new double[w,h];
Random generator = new Random(seed); // Seeds FTW!
//double amount = 8.0;
@@ -244,8 +242,8 @@ namespace libTerrain
for (y = 0; y < h; y++)
{
amount = mask.map[x, y];
- double offset_x = (double)x + (generator.NextDouble() * amount) - (amount / 2.0);
- double offset_y = (double)y + (generator.NextDouble() * amount) - (amount / 2.0);
+ double offset_x = (double) x + (generator.NextDouble()*amount) - (amount/2.0);
+ double offset_y = (double) y + (generator.NextDouble()*amount) - (amount/2.0);
if (offset_x > w)
offset_x = w - 1;
@@ -267,7 +265,7 @@ namespace libTerrain
public void Distort(Channel mask, double str)
{
// Simple pertubation filter
- double[,] manipulated = new double[w, h];
+ double[,] manipulated = new double[w,h];
double amount;
@@ -277,8 +275,8 @@ namespace libTerrain
for (y = 0; y < h; y++)
{
amount = mask.map[x, y];
- double offset_x = (double)x + (amount * str) - (0.5 * str);
- double offset_y = (double)y + (amount * str) - (0.5 * str);
+ double offset_x = (double) x + (amount*str) - (0.5*str);
+ double offset_y = (double) y + (amount*str) - (0.5*str);
if (offset_x > w)
offset_x = w - 1;
@@ -295,13 +293,12 @@ namespace libTerrain
}
}
map = manipulated;
-
}
public void Distort(Channel mask, Channel mask2, double str)
{
// Simple pertubation filter
- double[,] manipulated = new double[w, h];
+ double[,] manipulated = new double[w,h];
double amountX;
double amountY;
@@ -313,8 +310,8 @@ namespace libTerrain
{
amountX = mask.map[x, y];
amountY = mask2.map[x, y];
- double offset_x = (double)x + (amountX * str) - (0.5 * str);
- double offset_y = (double)y + (amountY * str) - (0.5 * str);
+ double offset_x = (double) x + (amountX*str) - (0.5*str);
+ double offset_y = (double) y + (amountY*str) - (0.5*str);
if (offset_x > w)
offset_x = w - 1;
@@ -331,7 +328,6 @@ namespace libTerrain
}
}
map = manipulated;
-
}
public Channel Blend(Channel other, double amount)
@@ -360,4 +356,4 @@ namespace libTerrain
return this;
}
}
-}
+}
\ 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 @@
*/
using System;
-using System.Collections.Generic;
-using System.Text;
namespace libTerrain
{
@@ -74,17 +72,18 @@ namespace libTerrain
/// The percentage of rock which can be picked up to pickup 0..1
/// The number of erosion rounds (recommended: 25+)
/// Drop sediment at the lowest point?
- public void AerobicErosion(double windspeed, double pickupTalusMinimum, double dropTalusMinimum, double carry, int rounds, bool lowest, bool usingFluidDynamics)
+ public void AerobicErosion(double windspeed, double pickupTalusMinimum, double dropTalusMinimum, double carry,
+ int rounds, bool lowest, bool usingFluidDynamics)
{
bool debugImages = false;
- Channel wind = new Channel(w, h) ;
+ Channel wind = new Channel(w, h);
Channel sediment = new Channel(w, h);
int x, y, i, j;
- this.Normalise();
+ Normalise();
- wind = this.Copy();
+ wind = Copy();
wind.Noise();
if (debugImages)
@@ -120,7 +119,7 @@ namespace libTerrain
surfacearea += Math.Abs(target - me);
}
- double amount = surfacearea * wind.map[x, y] * carry;
+ double amount = surfacearea*wind.map[x, y]*carry;
if (amount < 0)
amount = 0;
@@ -147,7 +146,7 @@ namespace libTerrain
}
else
{
- wind.Pertubation(15); // Can do better later
+ wind.Pertubation(15); // Can do better later
wind.seed++;
sediment.Pertubation(10); // Sediment is blown around a bit
sediment.seed++;
@@ -175,12 +174,12 @@ namespace libTerrain
if (target < min && lowest)
{
- minside = (int[])coords.Clone();
+ minside = (int[]) coords.Clone();
min = target;
}
}
- double amount = surfacearea * (1.0 - wind.map[x, y]) * carry;
+ double amount = surfacearea*(1.0 - wind.map[x, y])*carry;
if (amount < 0)
amount = 0;
@@ -199,7 +198,7 @@ namespace libTerrain
wind.Normalise();
wind *= windspeed;
- this.Normalise();
+ Normalise();
}
Channel myself = this;
@@ -207,7 +206,7 @@ namespace libTerrain
myself.Normalise();
if (debugImages)
- this.SaveImage("testimg/output.png");
+ SaveImage("testimg/output.png");
}
}
}
\ 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 @@
*/
using System;
-using System.Collections.Generic;
-using System.Text;
namespace libTerrain
{
@@ -44,7 +42,7 @@ namespace libTerrain
Channel waterFlow = new Channel(w, h);
NeighbourSystem type = NeighbourSystem.Moore;
- int NEIGHBOUR_ME = 4;
+ int NEIGHBOUR_ME = 4;
int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5;
@@ -52,7 +50,7 @@ namespace libTerrain
{
water += rain;
- sediment = terrain * water;
+ sediment = terrain*water;
terrain -= sediment;
for (int x = 1; x < w - 1; x++)
@@ -72,7 +70,8 @@ namespace libTerrain
coords[0] += x;
coords[1] += y;
- heights[j] = map[coords[0], coords[1]] + water.map[coords[0], coords[1]] + sediment.map[coords[0], coords[1]];
+ heights[j] = map[coords[0], coords[1]] + water.map[coords[0], coords[1]] +
+ sediment.map[coords[0], coords[1]];
diffs[j] = heightCenter - heights[j];
}
}
@@ -97,13 +96,13 @@ namespace libTerrain
if (totalCellsCounted == 1)
continue;
- double averageHeight = totalHeight / totalCellsCounted;
+ double averageHeight = totalHeight/totalCellsCounted;
double waterAmount = Math.Min(water.map[x, y], heightCenter - averageHeight);
// TODO: Check this.
waterFlow.map[x, y] += waterFlow.map[x, y] - waterAmount;
- double totalInverseDiff = waterAmount / totalHeightDiff;
+ double totalInverseDiff = waterAmount/totalHeightDiff;
for (int j = 0; j < NEIGHBOUR_MAX; j++)
{
@@ -115,7 +114,8 @@ namespace libTerrain
if (diffs[j] > 0)
{
- waterFlow.SetWrap(coords[0], coords[1], waterFlow.map[coords[0], coords[1]] + diffs[j] * totalInverseDiff);
+ waterFlow.SetWrap(coords[0], coords[1],
+ waterFlow.map[coords[0], coords[1]] + diffs[j]*totalInverseDiff);
}
}
}
@@ -131,7 +131,7 @@ namespace libTerrain
{
for (int y = 0; y < h; y++)
{
- double deposition = sediment.map[x, y] - water.map[x, y] * solubility;
+ double deposition = sediment.map[x, y] - water.map[x, y]*solubility;
if (deposition > 0)
{
sediment.map[x, y] -= deposition;
@@ -139,7 +139,6 @@ namespace libTerrain
}
}
}
-
}
}
}
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 @@
*
*/
-using System;
-using System.Collections.Generic;
-using System.Text;
-
namespace libTerrain
{
partial class Channel
@@ -42,7 +38,7 @@ namespace libTerrain
private static int nsIX(int i, int j, int N)
{
- return ((i) + (N + 2) * (j));
+ return ((i) + (N + 2)*(j));
}
private static void nsSwap(ref double x0, ref double x)
@@ -62,10 +58,10 @@ namespace libTerrain
private void nsAddSource(int N, ref double[] x, ref double[] s, double dt)
{
int i;
- int size = (N + 2) * (N + 2);
+ int size = (N + 2)*(N + 2);
for (i = 0; i < size; i++)
{
- x[i] += dt * s[i];
+ x[i] += dt*s[i];
}
}
@@ -74,15 +70,15 @@ namespace libTerrain
int i;
for (i = 0; i <= N; i++)
{
- x[nsIX(0, i, N)] = b == 1 ? -x[nsIX(1, i, N)] : x[nsIX(1, i, N)];
- x[nsIX(0, N + 1, N)] = b == 1 ? -x[nsIX(N, i, N)] : x[nsIX(N, i, N)];
- x[nsIX(i, 0, N)] = b == 2 ? -x[nsIX(i, 1, N)] : x[nsIX(i, 1, N)];
- x[nsIX(i, N + 1, N)] = b == 2 ? -x[nsIX(i, N, N)] : x[nsIX(i, N, N)];
+ x[nsIX(0, i, N)] = b == 1 ? -x[nsIX(1, i, N)] : x[nsIX(1, i, N)];
+ x[nsIX(0, N + 1, N)] = b == 1 ? -x[nsIX(N, i, N)] : x[nsIX(N, i, N)];
+ x[nsIX(i, 0, N)] = b == 2 ? -x[nsIX(i, 1, N)] : x[nsIX(i, 1, N)];
+ x[nsIX(i, N + 1, N)] = b == 2 ? -x[nsIX(i, N, N)] : x[nsIX(i, N, N)];
}
- x[nsIX(0, 0, N)] = 0.5f * (x[nsIX(1, 0, N)] + x[nsIX(0, 1, N)]);
- x[nsIX(0, N + 1, N)] = 0.5f * (x[nsIX(1, N + 1, N)] + x[nsIX(0, N, N)]);
- x[nsIX(N + 1, 0, N)] = 0.5f * (x[nsIX(N, 0, N)] + x[nsIX(N + 1, 1, N)]);
- x[nsIX(N + 1, N + 1, N)] = 0.5f * (x[nsIX(N, N + 1, N)] + x[nsIX(N + 1, N, N)]);
+ x[nsIX(0, 0, N)] = 0.5f*(x[nsIX(1, 0, N)] + x[nsIX(0, 1, N)]);
+ x[nsIX(0, N + 1, N)] = 0.5f*(x[nsIX(1, N + 1, N)] + x[nsIX(0, N, N)]);
+ x[nsIX(N + 1, 0, N)] = 0.5f*(x[nsIX(N, 0, N)] + x[nsIX(N + 1, 1, N)]);
+ x[nsIX(N + 1, N + 1, N)] = 0.5f*(x[nsIX(N, N + 1, N)] + x[nsIX(N + 1, N, N)]);
}
private void nsLinSolve(int N, int b, ref double[] x, ref double[] x0, double a, double c)
@@ -92,11 +88,11 @@ namespace libTerrain
{
for (j = 1; j <= N; j++)
{
- x[nsIX(i, j, N)] = (x0[nsIX(i, j, N)] + a *
- (x[nsIX(i - 1, j, N)] +
- x[nsIX(i + 1, j, N)] +
- x[nsIX(i, j - 1, N)] + x[nsIX(i, j + 1, N)])
- ) / c;
+ x[nsIX(i, j, N)] = (x0[nsIX(i, j, N)] + a*
+ (x[nsIX(i - 1, j, N)] +
+ x[nsIX(i + 1, j, N)] +
+ x[nsIX(i, j - 1, N)] + x[nsIX(i, j + 1, N)])
+ )/c;
}
}
@@ -105,8 +101,8 @@ namespace libTerrain
private void nsDiffuse(int N, int b, ref double[] x, ref double[] x0, double diff, double dt)
{
- double a = dt * diff * N * N;
- nsLinSolve(N, b, ref x, ref x0, a, 1 + 4 * a);
+ double a = dt*diff*N*N;
+ nsLinSolve(N, b, ref x, ref x0, a, 1 + 4*a);
}
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
int i, j, i0, j0, i1, j1;
double x, y, s0, t0, s1, t1, dt0;
- dt0 = dt * N;
+ dt0 = dt*N;
for (i = 1; i <= N; i++)
{
for (j = 1; j <= N; j++)
{
- x = i - dt0 * u[nsIX(i, j, N)];
- y = j - dt0 * v[nsIX(i, j, N)];
+ x = i - dt0*u[nsIX(i, j, N)];
+ y = j - dt0*v[nsIX(i, j, N)];
if (x < 0.5)
x = 0.5;
if (x > N + 0.5)
x = N + 0.5;
- i0 = (int)x;
+ i0 = (int) x;
i1 = i0 + 1;
if (y < 0.5)
y = 0.5;
if (y > N + 0.5)
y = N + 0.5;
- j0 = (int)y;
+ j0 = (int) y;
j1 = j0 + 1;
s1 = x - i0;
@@ -142,8 +138,8 @@ namespace libTerrain
t1 = y - j0;
t0 = 1 - t1;
- d[nsIX(i, j, N)] = s0 * (t0 * d0[nsIX(i0, j0, N)] + t1 * d0[nsIX(i0, j1, N)]) +
- s1 * (t0 * d0[nsIX(i1, j0, N)] + t1 * d0[nsIX(i1, j1, N)]);
+ d[nsIX(i, j, N)] = s0*(t0*d0[nsIX(i0, j0, N)] + t1*d0[nsIX(i0, j1, N)]) +
+ s1*(t0*d0[nsIX(i1, j0, N)] + t1*d0[nsIX(i1, j1, N)]);
}
}
@@ -158,7 +154,9 @@ namespace libTerrain
{
for (j = 1; j <= N; j++)
{
- 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;
+ 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;
p[nsIX(i, j, N)] = 0;
}
}
@@ -172,8 +170,8 @@ namespace libTerrain
{
for (j = 1; j <= N; j++)
{
- u[nsIX(i, j, N)] -= 0.5 * N * (p[nsIX(i + 1, j, N)] - p[nsIX(i - 1, j, N)]);
- v[nsIX(i, j, N)] -= 0.5 * N * (p[nsIX(i, j + 1, N)] - p[nsIX(i, j - 1, N)]);
+ u[nsIX(i, j, N)] -= 0.5*N*(p[nsIX(i + 1, j, N)] - p[nsIX(i - 1, j, N)]);
+ v[nsIX(i, j, N)] -= 0.5*N*(p[nsIX(i, j + 1, N)] - p[nsIX(i, j - 1, N)]);
}
}
@@ -181,7 +179,8 @@ namespace libTerrain
nsSetBnd(N, 2, ref v);
}
- private void nsDensStep(int N, ref double[] x, ref double[] x0, ref double[] u, ref double[] v, double diff, double dt)
+ private void nsDensStep(int N, ref double[] x, ref double[] x0, ref double[] u, ref double[] v, double diff,
+ double dt)
{
nsAddSource(N, ref x, ref x0, dt);
nsSwap(ref x0, ref x);
@@ -190,7 +189,8 @@ namespace libTerrain
nsAdvect(N, 0, ref x, ref x0, ref u, ref v, dt);
}
- private void nsVelStep(int N, ref double[] u, ref double[] v, ref double[] u0, ref double[] v0, double visc, double dt)
+ private void nsVelStep(int N, ref double[] u, ref double[] v, ref double[] u0, ref double[] v0, double visc,
+ double dt)
{
nsAddSource(N, ref u, ref u0, dt);
nsAddSource(N, ref v, ref v0, dt);
@@ -236,17 +236,17 @@ namespace libTerrain
private void nsSimulate(int N, int rounds, double dt, double diff, double visc)
{
- int size = (N * 2) * (N * 2);
+ int size = (N*2)*(N*2);
- double[] u = new double[size]; // Force, X axis
- double[] v = new double[size]; // Force, Y axis
- double[] u_prev = new double[size];
- double[] v_prev = new double[size];
- double[] dens = new double[size];
- double[] dens_prev = new double[size];
+ double[] u = new double[size]; // Force, X axis
+ double[] v = new double[size]; // Force, Y axis
+ double[] u_prev = new double[size];
+ double[] v_prev = new double[size];
+ double[] dens = new double[size];
+ double[] dens_prev = new double[size];
- nsDoublesToBuffer(this.map, N, ref dens);
- nsDoublesToBuffer(this.map, N, ref dens_prev);
+ nsDoublesToBuffer(map, N, ref dens);
+ nsDoublesToBuffer(map, N, ref dens_prev);
for (int i = 0; i < rounds; i++)
{
@@ -258,7 +258,7 @@ namespace libTerrain
nsDensStep(N, ref dens, ref dens_prev, ref u, ref v, diff, dt);
}
- nsBufferToDoubles(ref dens, N, ref this.map);
+ nsBufferToDoubles(ref dens, N, ref map);
}
///
@@ -270,14 +270,14 @@ namespace libTerrain
/// Fluid viscosity (Recommended: 0.0)
public void navierStokes(int rounds, double dt, double diff, double visc)
{
- nsSimulate(this.h, rounds, dt, diff, visc);
+ nsSimulate(h, rounds, dt, diff, visc);
}
public void navierStokes(int rounds, double dt, double diff, double visc, ref double[,] uret, ref double[,] vret)
{
- int N = this.h;
+ int N = h;
- int size = (N * 2) * (N * 2);
+ int size = (N*2)*(N*2);
double[] u = new double[size]; // Force, X axis
double[] v = new double[size]; // Force, Y axis
@@ -286,8 +286,8 @@ namespace libTerrain
double[] dens = new double[size];
double[] dens_prev = new double[size];
- nsDoublesToBuffer(this.map, N, ref dens);
- nsDoublesToBuffer(this.map, N, ref dens_prev);
+ nsDoublesToBuffer(map, N, ref dens);
+ nsDoublesToBuffer(map, N, ref dens_prev);
for (int i = 0; i < rounds; i++)
{
@@ -301,7 +301,7 @@ namespace libTerrain
nsBufferToDoubles(ref u, N, ref uret);
nsBufferToDoubles(ref v, N, ref vret);
- nsBufferToDoubles(ref dens, N, ref this.map);
+ nsBufferToDoubles(ref dens, N, ref map);
}
}
}
\ 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 @@
*
*/
-using System;
-using System.Collections.Generic;
-using System.Text;
-
namespace libTerrain
{
partial class Channel
@@ -47,10 +43,11 @@ namespace libTerrain
double[,] lastFrame;
double[,] thisFrame;
- lastFrame = (double[,])map.Clone();
- thisFrame = (double[,])map.Clone();
+ lastFrame = (double[,]) map.Clone();
+ thisFrame = (double[,]) map.Clone();
- NeighbourSystem type = NeighbourSystem.Moore; // Using moore neighbourhood (twice as computationally expensive)
+ NeighbourSystem type = NeighbourSystem.Moore;
+ // Using moore neighbourhood (twice as computationally expensive)
int NEIGHBOUR_ME = 4; // I am always 4 in both systems.
int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5;
@@ -88,19 +85,18 @@ namespace libTerrain
if (target > heightF + talus)
{
- double calc = c * ((target - heightF) - talus);
+ double calc = c*((target - heightF) - talus);
heightF += calc;
target -= calc;
}
thisFrame[x, y] = heightF;
thisFrame[coords[0], coords[1]] = target;
-
}
}
}
}
- lastFrame = (double[,])thisFrame.Clone();
+ lastFrame = (double[,]) thisFrame.Clone();
}
map = thisFrame;
@@ -109,4 +105,4 @@ namespace libTerrain
return this;
}
}
-}
+}
\ 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 @@
*
*/
-using System;
-using System.Collections.Generic;
-using System.Text;
-
namespace libTerrain
{
partial class Channel
{
- enum NeighbourSystem
+ private enum NeighbourSystem
{
Moore,
VonNeumann
- };
+ } ;
private int[] Neighbours(NeighbourSystem type, int index)
{
@@ -138,4 +134,4 @@ namespace libTerrain
return coord;
}
}
-}
+}
\ 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 @@
*/
using System;
-using System.Collections.Generic;
-using System.Text;
namespace libTerrain
{
@@ -138,7 +136,7 @@ namespace libTerrain
{
for (y = 0; y < A.h; y++)
{
- A.map[x, y] = Math.Pow(A.map[x,y],B.map[x, y]);
+ A.map[x, y] = Math.Pow(A.map[x, y], B.map[x, y]);
}
}
@@ -230,7 +228,7 @@ namespace libTerrain
{
for (y = 0; y < A.h; y++)
{
- A.map[x, y] = Math.Pow(A.map[x,y],B);
+ A.map[x, y] = Math.Pow(A.map[x, y], B);
}
}
@@ -238,6 +236,5 @@ namespace libTerrain
return A;
}
-
}
-}
+}
\ 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 @@
*
*/
-using System;
-using System.Collections.Generic;
-using System.Text;
-
namespace libTerrain
{
public class Point2D
@@ -43,4 +39,4 @@ namespace libTerrain
y = Y;
}
}
-}
+}
\ 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 @@
*/
using System;
-using System.Collections.Generic;
-using System.Text;
namespace libTerrain
{
- class Tools
+ internal class Tools
{
public static double LinearInterpolate(double a, double b, double amount)
{
- return a + ((b - a) * amount);
+ return a + ((b - a)*amount);
}
public static double ExponentialInterpolate(double a, double b, double amount)
{
a = Math.Pow(a, amount);
b = Math.Pow(b - a, 1.0 - amount);
- return a+b;
+ return a + b;
}
- public static int PowerOf2Log2(int n) {
- for (int i = 0; i < 31; i++) {
- if ((n & 1) == 1) {
- return i;
- }
- n >>= 1;
- }
- return 0;
- }
+ public static int PowerOf2Log2(int n)
+ {
+ for (int i = 0; i < 31; i++)
+ {
+ if ((n & 1) == 1)
+ {
+ return i;
+ }
+ n >>= 1;
+ }
+ return 0;
+ }
}
-}
+}
\ No newline at end of file
--
cgit v1.1