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 --- .../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 +- 19 files changed, 240 insertions(+), 282 deletions(-) (limited to 'OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel') 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 -- cgit v1.1