aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators
diff options
context:
space:
mode:
authorlbsa712007-10-30 09:05:31 +0000
committerlbsa712007-10-30 09:05:31 +0000
commit67e12b95ea7b68f4904a7484d77ecfd787d16d0c (patch)
tree20b00d24c8a7617017960432ec044852e3ad5fa9 /OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators
parent* Deleted .user file (diff)
downloadopensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.zip
opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.gz
opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.bz2
opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.xz
* Optimized usings
* Shortened type references * Removed redundant 'this' qualifier
Diffstat (limited to 'OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators')
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs23
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/HydraulicErosion.cs19
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs100
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/ThermalWeathering.cs18
4 files changed, 77 insertions, 83 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs
index ca93c25..c8584e8 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs
@@ -27,8 +27,6 @@
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic;
31using System.Text;
32 30
33namespace libTerrain 31namespace libTerrain
34{ 32{
@@ -74,17 +72,18 @@ namespace libTerrain
74 /// <param name="carry">The percentage of rock which can be picked up to pickup 0..1</param> 72 /// <param name="carry">The percentage of rock which can be picked up to pickup 0..1</param>
75 /// <param name="rounds">The number of erosion rounds (recommended: 25+)</param> 73 /// <param name="rounds">The number of erosion rounds (recommended: 25+)</param>
76 /// <param name="lowest">Drop sediment at the lowest point?</param> 74 /// <param name="lowest">Drop sediment at the lowest point?</param>
77 public void AerobicErosion(double windspeed, double pickupTalusMinimum, double dropTalusMinimum, double carry, int rounds, bool lowest, bool usingFluidDynamics) 75 public void AerobicErosion(double windspeed, double pickupTalusMinimum, double dropTalusMinimum, double carry,
76 int rounds, bool lowest, bool usingFluidDynamics)
78 { 77 {
79 bool debugImages = false; 78 bool debugImages = false;
80 79
81 Channel wind = new Channel(w, h) ; 80 Channel wind = new Channel(w, h);
82 Channel sediment = new Channel(w, h); 81 Channel sediment = new Channel(w, h);
83 int x, y, i, j; 82 int x, y, i, j;
84 83
85 this.Normalise(); 84 Normalise();
86 85
87 wind = this.Copy(); 86 wind = Copy();
88 wind.Noise(); 87 wind.Noise();
89 88
90 if (debugImages) 89 if (debugImages)
@@ -120,7 +119,7 @@ namespace libTerrain
120 surfacearea += Math.Abs(target - me); 119 surfacearea += Math.Abs(target - me);
121 } 120 }
122 121
123 double amount = surfacearea * wind.map[x, y] * carry; 122 double amount = surfacearea*wind.map[x, y]*carry;
124 123
125 if (amount < 0) 124 if (amount < 0)
126 amount = 0; 125 amount = 0;
@@ -147,7 +146,7 @@ namespace libTerrain
147 } 146 }
148 else 147 else
149 { 148 {
150 wind.Pertubation(15); // Can do better later 149 wind.Pertubation(15); // Can do better later
151 wind.seed++; 150 wind.seed++;
152 sediment.Pertubation(10); // Sediment is blown around a bit 151 sediment.Pertubation(10); // Sediment is blown around a bit
153 sediment.seed++; 152 sediment.seed++;
@@ -175,12 +174,12 @@ namespace libTerrain
175 174
176 if (target < min && lowest) 175 if (target < min && lowest)
177 { 176 {
178 minside = (int[])coords.Clone(); 177 minside = (int[]) coords.Clone();
179 min = target; 178 min = target;
180 } 179 }
181 } 180 }
182 181
183 double amount = surfacearea * (1.0 - wind.map[x, y]) * carry; 182 double amount = surfacearea*(1.0 - wind.map[x, y])*carry;
184 183
185 if (amount < 0) 184 if (amount < 0)
186 amount = 0; 185 amount = 0;
@@ -199,7 +198,7 @@ namespace libTerrain
199 wind.Normalise(); 198 wind.Normalise();
200 wind *= windspeed; 199 wind *= windspeed;
201 200
202 this.Normalise(); 201 Normalise();
203 } 202 }
204 203
205 Channel myself = this; 204 Channel myself = this;
@@ -207,7 +206,7 @@ namespace libTerrain
207 myself.Normalise(); 206 myself.Normalise();
208 207
209 if (debugImages) 208 if (debugImages)
210 this.SaveImage("testimg/output.png"); 209 SaveImage("testimg/output.png");
211 } 210 }
212 } 211 }
213} \ No newline at end of file 212} \ No newline at end of file
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/HydraulicErosion.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/HydraulicErosion.cs
index 4f58f71..0e47e1b 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/HydraulicErosion.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/HydraulicErosion.cs
@@ -27,8 +27,6 @@
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic;
31using System.Text;
32 30
33namespace libTerrain 31namespace libTerrain
34{ 32{
@@ -44,7 +42,7 @@ namespace libTerrain
44 Channel waterFlow = new Channel(w, h); 42 Channel waterFlow = new Channel(w, h);
45 43
46 NeighbourSystem type = NeighbourSystem.Moore; 44 NeighbourSystem type = NeighbourSystem.Moore;
47 int NEIGHBOUR_ME = 4; 45 int NEIGHBOUR_ME = 4;
48 46
49 int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5; 47 int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5;
50 48
@@ -52,7 +50,7 @@ namespace libTerrain
52 { 50 {
53 water += rain; 51 water += rain;
54 52
55 sediment = terrain * water; 53 sediment = terrain*water;
56 terrain -= sediment; 54 terrain -= sediment;
57 55
58 for (int x = 1; x < w - 1; x++) 56 for (int x = 1; x < w - 1; x++)
@@ -72,7 +70,8 @@ namespace libTerrain
72 coords[0] += x; 70 coords[0] += x;
73 coords[1] += y; 71 coords[1] += y;
74 72
75 heights[j] = map[coords[0], coords[1]] + water.map[coords[0], coords[1]] + sediment.map[coords[0], coords[1]]; 73 heights[j] = map[coords[0], coords[1]] + water.map[coords[0], coords[1]] +
74 sediment.map[coords[0], coords[1]];
76 diffs[j] = heightCenter - heights[j]; 75 diffs[j] = heightCenter - heights[j];
77 } 76 }
78 } 77 }
@@ -97,13 +96,13 @@ namespace libTerrain
97 if (totalCellsCounted == 1) 96 if (totalCellsCounted == 1)
98 continue; 97 continue;
99 98
100 double averageHeight = totalHeight / totalCellsCounted; 99 double averageHeight = totalHeight/totalCellsCounted;
101 double waterAmount = Math.Min(water.map[x, y], heightCenter - averageHeight); 100 double waterAmount = Math.Min(water.map[x, y], heightCenter - averageHeight);
102 101
103 // TODO: Check this. 102 // TODO: Check this.
104 waterFlow.map[x, y] += waterFlow.map[x, y] - waterAmount; 103 waterFlow.map[x, y] += waterFlow.map[x, y] - waterAmount;
105 104
106 double totalInverseDiff = waterAmount / totalHeightDiff; 105 double totalInverseDiff = waterAmount/totalHeightDiff;
107 106
108 for (int j = 0; j < NEIGHBOUR_MAX; j++) 107 for (int j = 0; j < NEIGHBOUR_MAX; j++)
109 { 108 {
@@ -115,7 +114,8 @@ namespace libTerrain
115 114
116 if (diffs[j] > 0) 115 if (diffs[j] > 0)
117 { 116 {
118 waterFlow.SetWrap(coords[0], coords[1], waterFlow.map[coords[0], coords[1]] + diffs[j] * totalInverseDiff); 117 waterFlow.SetWrap(coords[0], coords[1],
118 waterFlow.map[coords[0], coords[1]] + diffs[j]*totalInverseDiff);
119 } 119 }
120 } 120 }
121 } 121 }
@@ -131,7 +131,7 @@ namespace libTerrain
131 { 131 {
132 for (int y = 0; y < h; y++) 132 for (int y = 0; y < h; y++)
133 { 133 {
134 double deposition = sediment.map[x, y] - water.map[x, y] * solubility; 134 double deposition = sediment.map[x, y] - water.map[x, y]*solubility;
135 if (deposition > 0) 135 if (deposition > 0)
136 { 136 {
137 sediment.map[x, y] -= deposition; 137 sediment.map[x, y] -= deposition;
@@ -139,7 +139,6 @@ namespace libTerrain
139 } 139 }
140 } 140 }
141 } 141 }
142
143 } 142 }
144 } 143 }
145 } 144 }
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs
index 401cf95..8c16d7c 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs
@@ -26,10 +26,6 @@
26* 26*
27*/ 27*/
28 28
29using System;
30using System.Collections.Generic;
31using System.Text;
32
33namespace libTerrain 29namespace libTerrain
34{ 30{
35 partial class Channel 31 partial class Channel
@@ -42,7 +38,7 @@ namespace libTerrain
42 38
43 private static int nsIX(int i, int j, int N) 39 private static int nsIX(int i, int j, int N)
44 { 40 {
45 return ((i) + (N + 2) * (j)); 41 return ((i) + (N + 2)*(j));
46 } 42 }
47 43
48 private static void nsSwap(ref double x0, ref double x) 44 private static void nsSwap(ref double x0, ref double x)
@@ -62,10 +58,10 @@ namespace libTerrain
62 private void nsAddSource(int N, ref double[] x, ref double[] s, double dt) 58 private void nsAddSource(int N, ref double[] x, ref double[] s, double dt)
63 { 59 {
64 int i; 60 int i;
65 int size = (N + 2) * (N + 2); 61 int size = (N + 2)*(N + 2);
66 for (i = 0; i < size; i++) 62 for (i = 0; i < size; i++)
67 { 63 {
68 x[i] += dt * s[i]; 64 x[i] += dt*s[i];
69 } 65 }
70 } 66 }
71 67
@@ -74,15 +70,15 @@ namespace libTerrain
74 int i; 70 int i;
75 for (i = 0; i <= N; i++) 71 for (i = 0; i <= N; i++)
76 { 72 {
77 x[nsIX(0, i, N)] = b == 1 ? -x[nsIX(1, i, N)] : x[nsIX(1, i, N)]; 73 x[nsIX(0, i, N)] = b == 1 ? -x[nsIX(1, i, N)] : x[nsIX(1, i, N)];
78 x[nsIX(0, N + 1, N)] = b == 1 ? -x[nsIX(N, i, N)] : x[nsIX(N, i, N)]; 74 x[nsIX(0, N + 1, N)] = b == 1 ? -x[nsIX(N, i, N)] : x[nsIX(N, i, N)];
79 x[nsIX(i, 0, N)] = b == 2 ? -x[nsIX(i, 1, N)] : x[nsIX(i, 1, N)]; 75 x[nsIX(i, 0, N)] = b == 2 ? -x[nsIX(i, 1, N)] : x[nsIX(i, 1, N)];
80 x[nsIX(i, N + 1, N)] = b == 2 ? -x[nsIX(i, N, N)] : x[nsIX(i, N, N)]; 76 x[nsIX(i, N + 1, N)] = b == 2 ? -x[nsIX(i, N, N)] : x[nsIX(i, N, N)];
81 } 77 }
82 x[nsIX(0, 0, N)] = 0.5f * (x[nsIX(1, 0, N)] + x[nsIX(0, 1, N)]); 78 x[nsIX(0, 0, N)] = 0.5f*(x[nsIX(1, 0, N)] + x[nsIX(0, 1, N)]);
83 x[nsIX(0, N + 1, N)] = 0.5f * (x[nsIX(1, N + 1, N)] + x[nsIX(0, N, N)]); 79 x[nsIX(0, N + 1, N)] = 0.5f*(x[nsIX(1, N + 1, N)] + x[nsIX(0, N, N)]);
84 x[nsIX(N + 1, 0, N)] = 0.5f * (x[nsIX(N, 0, N)] + x[nsIX(N + 1, 1, N)]); 80 x[nsIX(N + 1, 0, N)] = 0.5f*(x[nsIX(N, 0, N)] + x[nsIX(N + 1, 1, N)]);
85 x[nsIX(N + 1, N + 1, N)] = 0.5f * (x[nsIX(N, N + 1, N)] + x[nsIX(N + 1, N, N)]); 81 x[nsIX(N + 1, N + 1, N)] = 0.5f*(x[nsIX(N, N + 1, N)] + x[nsIX(N + 1, N, N)]);
86 } 82 }
87 83
88 private void nsLinSolve(int N, int b, ref double[] x, ref double[] x0, double a, double c) 84 private void nsLinSolve(int N, int b, ref double[] x, ref double[] x0, double a, double c)
@@ -92,11 +88,11 @@ namespace libTerrain
92 { 88 {
93 for (j = 1; j <= N; j++) 89 for (j = 1; j <= N; j++)
94 { 90 {
95 x[nsIX(i, j, N)] = (x0[nsIX(i, j, N)] + a * 91 x[nsIX(i, j, N)] = (x0[nsIX(i, j, N)] + a*
96 (x[nsIX(i - 1, j, N)] + 92 (x[nsIX(i - 1, j, N)] +
97 x[nsIX(i + 1, j, N)] + 93 x[nsIX(i + 1, j, N)] +
98 x[nsIX(i, j - 1, N)] + x[nsIX(i, j + 1, N)]) 94 x[nsIX(i, j - 1, N)] + x[nsIX(i, j + 1, N)])
99 ) / c; 95 )/c;
100 } 96 }
101 } 97 }
102 98
@@ -105,8 +101,8 @@ namespace libTerrain
105 101
106 private void nsDiffuse(int N, int b, ref double[] x, ref double[] x0, double diff, double dt) 102 private void nsDiffuse(int N, int b, ref double[] x, ref double[] x0, double diff, double dt)
107 { 103 {
108 double a = dt * diff * N * N; 104 double a = dt*diff*N*N;
109 nsLinSolve(N, b, ref x, ref x0, a, 1 + 4 * a); 105 nsLinSolve(N, b, ref x, ref x0, a, 1 + 4*a);
110 } 106 }
111 107
112 private void nsAdvect(int N, int b, ref double[] d, ref double[] d0, ref double[] u, ref double[] v, double dt) 108 private void nsAdvect(int N, int b, ref double[] d, ref double[] d0, ref double[] u, ref double[] v, double dt)
@@ -114,27 +110,27 @@ namespace libTerrain
114 int i, j, i0, j0, i1, j1; 110 int i, j, i0, j0, i1, j1;
115 double x, y, s0, t0, s1, t1, dt0; 111 double x, y, s0, t0, s1, t1, dt0;
116 112
117 dt0 = dt * N; 113 dt0 = dt*N;
118 114
119 for (i = 1; i <= N; i++) 115 for (i = 1; i <= N; i++)
120 { 116 {
121 for (j = 1; j <= N; j++) 117 for (j = 1; j <= N; j++)
122 { 118 {
123 x = i - dt0 * u[nsIX(i, j, N)]; 119 x = i - dt0*u[nsIX(i, j, N)];
124 y = j - dt0 * v[nsIX(i, j, N)]; 120 y = j - dt0*v[nsIX(i, j, N)];
125 121
126 if (x < 0.5) 122 if (x < 0.5)
127 x = 0.5; 123 x = 0.5;
128 if (x > N + 0.5) 124 if (x > N + 0.5)
129 x = N + 0.5; 125 x = N + 0.5;
130 i0 = (int)x; 126 i0 = (int) x;
131 i1 = i0 + 1; 127 i1 = i0 + 1;
132 128
133 if (y < 0.5) 129 if (y < 0.5)
134 y = 0.5; 130 y = 0.5;
135 if (y > N + 0.5) 131 if (y > N + 0.5)
136 y = N + 0.5; 132 y = N + 0.5;
137 j0 = (int)y; 133 j0 = (int) y;
138 j1 = j0 + 1; 134 j1 = j0 + 1;
139 135
140 s1 = x - i0; 136 s1 = x - i0;
@@ -142,8 +138,8 @@ namespace libTerrain
142 t1 = y - j0; 138 t1 = y - j0;
143 t0 = 1 - t1; 139 t0 = 1 - t1;
144 140
145 d[nsIX(i, j, N)] = s0 * (t0 * d0[nsIX(i0, j0, N)] + t1 * d0[nsIX(i0, j1, N)]) + 141 d[nsIX(i, j, N)] = s0*(t0*d0[nsIX(i0, j0, N)] + t1*d0[nsIX(i0, j1, N)]) +
146 s1 * (t0 * d0[nsIX(i1, j0, N)] + t1 * d0[nsIX(i1, j1, N)]); 142 s1*(t0*d0[nsIX(i1, j0, N)] + t1*d0[nsIX(i1, j1, N)]);
147 } 143 }
148 } 144 }
149 145
@@ -158,7 +154,9 @@ namespace libTerrain
158 { 154 {
159 for (j = 1; j <= N; j++) 155 for (j = 1; j <= N; j++)
160 { 156 {
161 div[nsIX(i, j, N)] = -0.5 * (u[nsIX(i + 1, j, N)] - u[nsIX(i - 1, j, N)] + v[nsIX(i, j + 1, N)] - v[nsIX(i, j - 1, N)]) / N; 157 div[nsIX(i, j, N)] = -0.5*
158 (u[nsIX(i + 1, j, N)] - u[nsIX(i - 1, j, N)] + v[nsIX(i, j + 1, N)] -
159 v[nsIX(i, j - 1, N)])/N;
162 p[nsIX(i, j, N)] = 0; 160 p[nsIX(i, j, N)] = 0;
163 } 161 }
164 } 162 }
@@ -172,8 +170,8 @@ namespace libTerrain
172 { 170 {
173 for (j = 1; j <= N; j++) 171 for (j = 1; j <= N; j++)
174 { 172 {
175 u[nsIX(i, j, N)] -= 0.5 * N * (p[nsIX(i + 1, j, N)] - p[nsIX(i - 1, j, N)]); 173 u[nsIX(i, j, N)] -= 0.5*N*(p[nsIX(i + 1, j, N)] - p[nsIX(i - 1, j, N)]);
176 v[nsIX(i, j, N)] -= 0.5 * N * (p[nsIX(i, j + 1, N)] - p[nsIX(i, j - 1, N)]); 174 v[nsIX(i, j, N)] -= 0.5*N*(p[nsIX(i, j + 1, N)] - p[nsIX(i, j - 1, N)]);
177 } 175 }
178 } 176 }
179 177
@@ -181,7 +179,8 @@ namespace libTerrain
181 nsSetBnd(N, 2, ref v); 179 nsSetBnd(N, 2, ref v);
182 } 180 }
183 181
184 private void nsDensStep(int N, ref double[] x, ref double[] x0, ref double[] u, ref double[] v, double diff, double dt) 182 private void nsDensStep(int N, ref double[] x, ref double[] x0, ref double[] u, ref double[] v, double diff,
183 double dt)
185 { 184 {
186 nsAddSource(N, ref x, ref x0, dt); 185 nsAddSource(N, ref x, ref x0, dt);
187 nsSwap(ref x0, ref x); 186 nsSwap(ref x0, ref x);
@@ -190,7 +189,8 @@ namespace libTerrain
190 nsAdvect(N, 0, ref x, ref x0, ref u, ref v, dt); 189 nsAdvect(N, 0, ref x, ref x0, ref u, ref v, dt);
191 } 190 }
192 191
193 private void nsVelStep(int N, ref double[] u, ref double[] v, ref double[] u0, ref double[] v0, double visc, double dt) 192 private void nsVelStep(int N, ref double[] u, ref double[] v, ref double[] u0, ref double[] v0, double visc,
193 double dt)
194 { 194 {
195 nsAddSource(N, ref u, ref u0, dt); 195 nsAddSource(N, ref u, ref u0, dt);
196 nsAddSource(N, ref v, ref v0, dt); 196 nsAddSource(N, ref v, ref v0, dt);
@@ -236,17 +236,17 @@ namespace libTerrain
236 236
237 private void nsSimulate(int N, int rounds, double dt, double diff, double visc) 237 private void nsSimulate(int N, int rounds, double dt, double diff, double visc)
238 { 238 {
239 int size = (N * 2) * (N * 2); 239 int size = (N*2)*(N*2);
240 240
241 double[] u = new double[size]; // Force, X axis 241 double[] u = new double[size]; // Force, X axis
242 double[] v = new double[size]; // Force, Y axis 242 double[] v = new double[size]; // Force, Y axis
243 double[] u_prev = new double[size]; 243 double[] u_prev = new double[size];
244 double[] v_prev = new double[size]; 244 double[] v_prev = new double[size];
245 double[] dens = new double[size]; 245 double[] dens = new double[size];
246 double[] dens_prev = new double[size]; 246 double[] dens_prev = new double[size];
247 247
248 nsDoublesToBuffer(this.map, N, ref dens); 248 nsDoublesToBuffer(map, N, ref dens);
249 nsDoublesToBuffer(this.map, N, ref dens_prev); 249 nsDoublesToBuffer(map, N, ref dens_prev);
250 250
251 for (int i = 0; i < rounds; i++) 251 for (int i = 0; i < rounds; i++)
252 { 252 {
@@ -258,7 +258,7 @@ namespace libTerrain
258 nsDensStep(N, ref dens, ref dens_prev, ref u, ref v, diff, dt); 258 nsDensStep(N, ref dens, ref dens_prev, ref u, ref v, diff, dt);
259 } 259 }
260 260
261 nsBufferToDoubles(ref dens, N, ref this.map); 261 nsBufferToDoubles(ref dens, N, ref map);
262 } 262 }
263 263
264 /// <summary> 264 /// <summary>
@@ -270,14 +270,14 @@ namespace libTerrain
270 /// <param name="visc">Fluid viscosity (Recommended: 0.0)</param> 270 /// <param name="visc">Fluid viscosity (Recommended: 0.0)</param>
271 public void navierStokes(int rounds, double dt, double diff, double visc) 271 public void navierStokes(int rounds, double dt, double diff, double visc)
272 { 272 {
273 nsSimulate(this.h, rounds, dt, diff, visc); 273 nsSimulate(h, rounds, dt, diff, visc);
274 } 274 }
275 275
276 public void navierStokes(int rounds, double dt, double diff, double visc, ref double[,] uret, ref double[,] vret) 276 public void navierStokes(int rounds, double dt, double diff, double visc, ref double[,] uret, ref double[,] vret)
277 { 277 {
278 int N = this.h; 278 int N = h;
279 279
280 int size = (N * 2) * (N * 2); 280 int size = (N*2)*(N*2);
281 281
282 double[] u = new double[size]; // Force, X axis 282 double[] u = new double[size]; // Force, X axis
283 double[] v = new double[size]; // Force, Y axis 283 double[] v = new double[size]; // Force, Y axis
@@ -286,8 +286,8 @@ namespace libTerrain
286 double[] dens = new double[size]; 286 double[] dens = new double[size];
287 double[] dens_prev = new double[size]; 287 double[] dens_prev = new double[size];
288 288
289 nsDoublesToBuffer(this.map, N, ref dens); 289 nsDoublesToBuffer(map, N, ref dens);
290 nsDoublesToBuffer(this.map, N, ref dens_prev); 290 nsDoublesToBuffer(map, N, ref dens_prev);
291 291
292 for (int i = 0; i < rounds; i++) 292 for (int i = 0; i < rounds; i++)
293 { 293 {
@@ -301,7 +301,7 @@ namespace libTerrain
301 301
302 nsBufferToDoubles(ref u, N, ref uret); 302 nsBufferToDoubles(ref u, N, ref uret);
303 nsBufferToDoubles(ref v, N, ref vret); 303 nsBufferToDoubles(ref v, N, ref vret);
304 nsBufferToDoubles(ref dens, N, ref this.map); 304 nsBufferToDoubles(ref dens, N, ref map);
305 } 305 }
306 } 306 }
307} \ No newline at end of file 307} \ No newline at end of file
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/ThermalWeathering.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/ThermalWeathering.cs
index 9148c3c..0ca3d48 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/ThermalWeathering.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/ThermalWeathering.cs
@@ -26,10 +26,6 @@
26* 26*
27*/ 27*/
28 28
29using System;
30using System.Collections.Generic;
31using System.Text;
32
33namespace libTerrain 29namespace libTerrain
34{ 30{
35 partial class Channel 31 partial class Channel
@@ -47,10 +43,11 @@ namespace libTerrain
47 double[,] lastFrame; 43 double[,] lastFrame;
48 double[,] thisFrame; 44 double[,] thisFrame;
49 45
50 lastFrame = (double[,])map.Clone(); 46 lastFrame = (double[,]) map.Clone();
51 thisFrame = (double[,])map.Clone(); 47 thisFrame = (double[,]) map.Clone();
52 48
53 NeighbourSystem type = NeighbourSystem.Moore; // Using moore neighbourhood (twice as computationally expensive) 49 NeighbourSystem type = NeighbourSystem.Moore;
50 // Using moore neighbourhood (twice as computationally expensive)
54 int NEIGHBOUR_ME = 4; // I am always 4 in both systems. 51 int NEIGHBOUR_ME = 4; // I am always 4 in both systems.
55 52
56 int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5; 53 int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5;
@@ -88,19 +85,18 @@ namespace libTerrain
88 85
89 if (target > heightF + talus) 86 if (target > heightF + talus)
90 { 87 {
91 double calc = c * ((target - heightF) - talus); 88 double calc = c*((target - heightF) - talus);
92 heightF += calc; 89 heightF += calc;
93 target -= calc; 90 target -= calc;
94 } 91 }
95 92
96 thisFrame[x, y] = heightF; 93 thisFrame[x, y] = heightF;
97 thisFrame[coords[0], coords[1]] = target; 94 thisFrame[coords[0], coords[1]] = target;
98
99 } 95 }
100 } 96 }
101 } 97 }
102 } 98 }
103 lastFrame = (double[,])thisFrame.Clone(); 99 lastFrame = (double[,]) thisFrame.Clone();
104 } 100 }
105 101
106 map = thisFrame; 102 map = thisFrame;
@@ -109,4 +105,4 @@ namespace libTerrain
109 return this; 105 return this;
110 } 106 }
111 } 107 }
112} 108} \ No newline at end of file