aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs')
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs42
1 files changed, 19 insertions, 23 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs
index 0155791..24df5b9 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs
@@ -27,8 +27,6 @@
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic;
31using System.Text;
32 30
33namespace libTerrain 31namespace libTerrain
34{ 32{
@@ -49,13 +47,13 @@ namespace libTerrain
49 { 47 {
50 for (y = 0; y < h; y++) 48 for (y = 0; y < h; y++)
51 { 49 {
52 map[x, y] = (map[x, y] - min) * (1.0 / (max - min)); 50 map[x, y] = (map[x, y] - min)*(1.0/(max - min));
53 } 51 }
54 } 52 }
55 } 53 }
56 else 54 else
57 { 55 {
58 this.Fill(0.5); 56 Fill(0.5);
59 } 57 }
60 58
61 return this; 59 return this;
@@ -82,7 +80,7 @@ namespace libTerrain
82 { 80 {
83 if (min != max) 81 if (min != max)
84 { 82 {
85 double val = (map[x, y] - min) * (1.0 / max - min); 83 double val = (map[x, y] - min)*(1.0/max - min);
86 val *= maxv - minv; 84 val *= maxv - minv;
87 val += minv; 85 val += minv;
88 86
@@ -179,9 +177,9 @@ namespace libTerrain
179 SetDiff(); 177 SetDiff();
180 178
181 double area = amount; 179 double area = amount;
182 double step = amount / 4.0; 180 double step = amount/4.0;
183 181
184 double[,] manipulate = new double[w, h]; 182 double[,] manipulate = new double[w,h];
185 int x, y; 183 int x, y;
186 double n, l; 184 double n, l;
187 for (x = 0; x < w; x++) 185 for (x = 0; x < w; x++)
@@ -200,7 +198,7 @@ namespace libTerrain
200 } 198 }
201 } 199 }
202 200
203 manipulate[x, y] = average / avgsteps; 201 manipulate[x, y] = average/avgsteps;
204 } 202 }
205 } 203 }
206 map = manipulate; 204 map = manipulate;
@@ -211,7 +209,7 @@ namespace libTerrain
211 SetDiff(); 209 SetDiff();
212 210
213 // Simple pertubation filter 211 // Simple pertubation filter
214 double[,] manipulated = new double[w, h]; 212 double[,] manipulated = new double[w,h];
215 Random generator = new Random(seed); // Seeds FTW! 213 Random generator = new Random(seed); // Seeds FTW!
216 //double amount = 8.0; 214 //double amount = 8.0;
217 215
@@ -220,8 +218,8 @@ namespace libTerrain
220 { 218 {
221 for (y = 0; y < h; y++) 219 for (y = 0; y < h; y++)
222 { 220 {
223 double offset_x = (double)x + (generator.NextDouble() * amount) - (amount / 2.0); 221 double offset_x = (double) x + (generator.NextDouble()*amount) - (amount/2.0);
224 double offset_y = (double)y + (generator.NextDouble() * amount) - (amount / 2.0); 222 double offset_y = (double) y + (generator.NextDouble()*amount) - (amount/2.0);
225 double p = GetBilinearInterpolate(offset_x, offset_y); 223 double p = GetBilinearInterpolate(offset_x, offset_y);
226 manipulated[x, y] = p; 224 manipulated[x, y] = p;
227 } 225 }
@@ -232,7 +230,7 @@ namespace libTerrain
232 public void PertubationMask(Channel mask) 230 public void PertubationMask(Channel mask)
233 { 231 {
234 // Simple pertubation filter 232 // Simple pertubation filter
235 double[,] manipulated = new double[w, h]; 233 double[,] manipulated = new double[w,h];
236 Random generator = new Random(seed); // Seeds FTW! 234 Random generator = new Random(seed); // Seeds FTW!
237 //double amount = 8.0; 235 //double amount = 8.0;
238 236
@@ -244,8 +242,8 @@ namespace libTerrain
244 for (y = 0; y < h; y++) 242 for (y = 0; y < h; y++)
245 { 243 {
246 amount = mask.map[x, y]; 244 amount = mask.map[x, y];
247 double offset_x = (double)x + (generator.NextDouble() * amount) - (amount / 2.0); 245 double offset_x = (double) x + (generator.NextDouble()*amount) - (amount/2.0);
248 double offset_y = (double)y + (generator.NextDouble() * amount) - (amount / 2.0); 246 double offset_y = (double) y + (generator.NextDouble()*amount) - (amount/2.0);
249 247
250 if (offset_x > w) 248 if (offset_x > w)
251 offset_x = w - 1; 249 offset_x = w - 1;
@@ -267,7 +265,7 @@ namespace libTerrain
267 public void Distort(Channel mask, double str) 265 public void Distort(Channel mask, double str)
268 { 266 {
269 // Simple pertubation filter 267 // Simple pertubation filter
270 double[,] manipulated = new double[w, h]; 268 double[,] manipulated = new double[w,h];
271 269
272 double amount; 270 double amount;
273 271
@@ -277,8 +275,8 @@ namespace libTerrain
277 for (y = 0; y < h; y++) 275 for (y = 0; y < h; y++)
278 { 276 {
279 amount = mask.map[x, y]; 277 amount = mask.map[x, y];
280 double offset_x = (double)x + (amount * str) - (0.5 * str); 278 double offset_x = (double) x + (amount*str) - (0.5*str);
281 double offset_y = (double)y + (amount * str) - (0.5 * str); 279 double offset_y = (double) y + (amount*str) - (0.5*str);
282 280
283 if (offset_x > w) 281 if (offset_x > w)
284 offset_x = w - 1; 282 offset_x = w - 1;
@@ -295,13 +293,12 @@ namespace libTerrain
295 } 293 }
296 } 294 }
297 map = manipulated; 295 map = manipulated;
298
299 } 296 }
300 297
301 public void Distort(Channel mask, Channel mask2, double str) 298 public void Distort(Channel mask, Channel mask2, double str)
302 { 299 {
303 // Simple pertubation filter 300 // Simple pertubation filter
304 double[,] manipulated = new double[w, h]; 301 double[,] manipulated = new double[w,h];
305 302
306 double amountX; 303 double amountX;
307 double amountY; 304 double amountY;
@@ -313,8 +310,8 @@ namespace libTerrain
313 { 310 {
314 amountX = mask.map[x, y]; 311 amountX = mask.map[x, y];
315 amountY = mask2.map[x, y]; 312 amountY = mask2.map[x, y];
316 double offset_x = (double)x + (amountX * str) - (0.5 * str); 313 double offset_x = (double) x + (amountX*str) - (0.5*str);
317 double offset_y = (double)y + (amountY * str) - (0.5 * str); 314 double offset_y = (double) y + (amountY*str) - (0.5*str);
318 315
319 if (offset_x > w) 316 if (offset_x > w)
320 offset_x = w - 1; 317 offset_x = w - 1;
@@ -331,7 +328,6 @@ namespace libTerrain
331 } 328 }
332 } 329 }
333 map = manipulated; 330 map = manipulated;
334
335 } 331 }
336 332
337 public Channel Blend(Channel other, double amount) 333 public Channel Blend(Channel other, double amount)
@@ -360,4 +356,4 @@ namespace libTerrain
360 return this; 356 return this;
361 } 357 }
362 } 358 }
363} 359} \ No newline at end of file