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
---
.../Channel/Manipulators/AerobicErosion.cs | 23 +++--
.../Channel/Manipulators/HydraulicErosion.cs | 19 ++--
.../Channel/Manipulators/NavierStokes.cs | 100 ++++++++++-----------
.../Channel/Manipulators/ThermalWeathering.cs | 18 ++--
4 files changed, 77 insertions(+), 83 deletions(-)
(limited to 'OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators')
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
--
cgit v1.1