aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs
diff options
context:
space:
mode:
authorAdam Frisby2007-07-25 10:08:16 +0000
committerAdam Frisby2007-07-25 10:08:16 +0000
commitcd88a4914dc31779a13d673aaaa6a1327ebeb351 (patch)
tree5626fed7ae06f4f39fb6f837f47b04dc2b642f28 /OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs
parent* Several functions should now be more efficient with sending packets to the ... (diff)
downloadopensim-SC_OLD-cd88a4914dc31779a13d673aaaa6a1327ebeb351.zip
opensim-SC_OLD-cd88a4914dc31779a13d673aaaa6a1327ebeb351.tar.gz
opensim-SC_OLD-cd88a4914dc31779a13d673aaaa6a1327ebeb351.tar.bz2
opensim-SC_OLD-cd88a4914dc31779a13d673aaaa6a1327ebeb351.tar.xz
* Assorted terrain fixes
Diffstat (limited to 'OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs')
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs83
1 files changed, 80 insertions, 3 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs
index a39db50..e6b18f4 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs
@@ -43,13 +43,20 @@ namespace libTerrain
43 43
44 int x, y; 44 int x, y;
45 45
46 for (x = 0; x < w; x++) 46 if (max != min)
47 { 47 {
48 for (y = 0; y < h; y++) 48 for (x = 0; x < w; x++)
49 { 49 {
50 map[x, y] = (map[x, y] - min) * (1.0 / (max - min)); 50 for (y = 0; y < h; y++)
51 {
52 map[x, y] = (map[x, y] - min) * (1.0 / (max - min));
53 }
51 } 54 }
52 } 55 }
56 else
57 {
58 this.Fill(0.5);
59 }
53 60
54 return this; 61 return this;
55 } 62 }
@@ -244,6 +251,76 @@ namespace libTerrain
244 map = manipulated; 251 map = manipulated;
245 } 252 }
246 253
254 public void Distort(Channel mask, double str)
255 {
256 // Simple pertubation filter
257 double[,] manipulated = new double[w, h];
258
259 double amount;
260
261 int x, y;
262 for (x = 0; x < w; x++)
263 {
264 for (y = 0; y < h; y++)
265 {
266 amount = mask.map[x, y];
267 double offset_x = (double)x + (amount * str) - (0.5 * str);
268 double offset_y = (double)y + (amount * str) - (0.5 * str);
269
270 if (offset_x > w)
271 offset_x = w - 1;
272 if (offset_y > h)
273 offset_y = h - 1;
274 if (offset_y < 0)
275 offset_y = 0;
276 if (offset_x < 0)
277 offset_x = 0;
278
279 double p = GetBilinearInterpolate(offset_x, offset_y);
280 manipulated[x, y] = p;
281 SetDiff(x, y);
282 }
283 }
284 map = manipulated;
285
286 }
287
288 public void Distort(Channel mask, Channel mask2, double str)
289 {
290 // Simple pertubation filter
291 double[,] manipulated = new double[w, h];
292
293 double amountX;
294 double amountY;
295
296 int x, y;
297 for (x = 0; x < w; x++)
298 {
299 for (y = 0; y < h; y++)
300 {
301 amountX = mask.map[x, y];
302 amountY = mask2.map[x, y];
303 double offset_x = (double)x + (amountX * str) - (0.5 * str);
304 double offset_y = (double)y + (amountY * str) - (0.5 * str);
305
306 if (offset_x > w)
307 offset_x = w - 1;
308 if (offset_y > h)
309 offset_y = h - 1;
310 if (offset_y < 0)
311 offset_y = 0;
312 if (offset_x < 0)
313 offset_x = 0;
314
315 double p = GetBilinearInterpolate(offset_x, offset_y);
316 manipulated[x, y] = p;
317 SetDiff(x, y);
318 }
319 }
320 map = manipulated;
321
322 }
323
247 public Channel Blend(Channel other, double amount) 324 public Channel Blend(Channel other, double amount)
248 { 325 {
249 int x, y; 326 int x, y;