aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorUbitUmarov2018-05-26 19:02:09 +0100
committerUbitUmarov2018-05-26 19:02:09 +0100
commit007adce0811dec23d231b2b274c785280befa940 (patch)
tree4a5019f587ab22da47708df08203faa2c6869d05 /OpenSim/Region
parentuse RegionInfo.ServerURI to report region url on datasnapshot (diff)
downloadopensim-SC-007adce0811dec23d231b2b274c785280befa940.zip
opensim-SC-007adce0811dec23d231b2b274c785280befa940.tar.gz
opensim-SC-007adce0811dec23d231b2b274c785280befa940.tar.bz2
opensim-SC-007adce0811dec23d231b2b274c785280befa940.tar.xz
missing updated files
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/World/Warp3DMap/Perlin.cs67
-rw-r--r--OpenSim/Region/CoreModules/World/Warp3DMap/TerrainSplat.cs254
-rw-r--r--OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs2
3 files changed, 116 insertions, 207 deletions
diff --git a/OpenSim/Region/CoreModules/World/Warp3DMap/Perlin.cs b/OpenSim/Region/CoreModules/World/Warp3DMap/Perlin.cs
index 522a7eb..2279b76 100644
--- a/OpenSim/Region/CoreModules/World/Warp3DMap/Perlin.cs
+++ b/OpenSim/Region/CoreModules/World/Warp3DMap/Perlin.cs
@@ -103,41 +103,39 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
103 103
104 public static float noise2(float x, float y) 104 public static float noise2(float x, float y)
105 { 105 {
106 int bx0, bx1, by0, by1, b00, b10, b01, b11; 106 int bx, by, b00, b10, b01, b11;
107 float rx0, rx1, ry0, ry1, sx, sy, a, b, t, u, v; 107 float rx0, rx1, ry0, ry1, sx, sy, a, b, t, u, v;
108 int i, j; 108 int i, j;
109 109
110 t = x + N; 110 t = x + N;
111 bx0 = ((int)t) & BM;
112 bx1 = (bx0 + 1) & BM;
113 rx0 = t - (int)t; 111 rx0 = t - (int)t;
114 rx1 = rx0 - 1f; 112 bx = ((int)t) & BM;
113 i = p[bx];
114 bx = (bx + 1) & BM;
115 j = p[bx];
115 116
116 t = y + N; 117 t = y + N;
117 by0 = ((int)t) & BM;
118 by1 = (by0 + 1) & BM;
119 ry0 = t - (int)t; 118 ry0 = t - (int)t;
120 ry1 = ry0 - 1f; 119 by = ((int)t) & BM;
120 b00 = p[i + by];
121 b10 = p[j + by];
121 122
122 i = p[bx0]; 123 by = (by + 1) & BM;
123 j = p[bx1]; 124 b01 = p[i + by];
124 125 b11 = p[j + by];
125 b00 = p[i + by0];
126 b10 = p[j + by0];
127 b01 = p[i + by1];
128 b11 = p[j + by1];
129 126
130 sx = s_curve(rx0); 127 sx = s_curve(rx0);
131 sy = s_curve(ry0);
132
133 u = rx0 * g2[b00, 0] + ry0 * g2[b00, 1]; 128 u = rx0 * g2[b00, 0] + ry0 * g2[b00, 1];
129 rx1 = rx0 - 1f;
134 v = rx1 * g2[b10, 0] + ry0 * g2[b10, 1]; 130 v = rx1 * g2[b10, 0] + ry0 * g2[b10, 1];
135 a = Utils.Lerp(u, v, sx); 131 a = Utils.Lerp(u, v, sx);
136 132
133 ry1 = ry0 - 1f;
137 u = rx0 * g2[b01, 0] + ry1 * g2[b01, 1]; 134 u = rx0 * g2[b01, 0] + ry1 * g2[b01, 1];
138 v = rx1 * g2[b11, 0] + ry1 * g2[b11, 1]; 135 v = rx1 * g2[b11, 0] + ry1 * g2[b11, 1];
139 b = Utils.Lerp(u, v, sx); 136 b = Utils.Lerp(u, v, sx);
140 137
138 sy = s_curve(ry0);
141 return Utils.Lerp(a, b, sy); 139 return Utils.Lerp(a, b, sy);
142 } 140 }
143 141
@@ -202,12 +200,10 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
202 public static float turbulence1(float x, float freq) 200 public static float turbulence1(float x, float freq)
203 { 201 {
204 float t; 202 float t;
205 float v;
206 203
207 for (t = 0f; freq >= 1f; freq *= 0.5f) 204 for (t = 0f; freq >= 1f; freq *= 0.5f)
208 { 205 {
209 v = freq * x; 206 t += noise1(freq * x) / freq;
210 t += noise1(v) / freq;
211 } 207 }
212 return t; 208 return t;
213 } 209 }
@@ -215,28 +211,20 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
215 public static float turbulence2(float x, float y, float freq) 211 public static float turbulence2(float x, float y, float freq)
216 { 212 {
217 float t; 213 float t;
218 Vector2 vec;
219 214
220 for (t = 0f; freq >= 1f; freq *= 0.5f) 215 for (t = 0f; freq >= 1f; freq *= 0.5f)
221 { 216 t += noise2(freq * x, freq * y) / freq;
222 vec.X = freq * x; 217
223 vec.Y = freq * y;
224 t += noise2(vec.X, vec.Y) / freq;
225 }
226 return t; 218 return t;
227 } 219 }
228 220
229 public static float turbulence3(float x, float y, float z, float freq) 221 public static float turbulence3(float x, float y, float z, float freq)
230 { 222 {
231 float t; 223 float t;
232 Vector3 vec;
233 224
234 for (t = 0f; freq >= 1f; freq *= 0.5f) 225 for (t = 0f; freq >= 1f; freq *= 0.5f)
235 { 226 {
236 vec.X = freq * x; 227 t += noise3(freq * x, freq * y, freq * z) / freq;
237 vec.Y = freq * y;
238 vec.Z = freq * z;
239 t += noise3(vec.X, vec.Y, vec.Z) / freq;
240 } 228 }
241 return t; 229 return t;
242 } 230 }
@@ -244,23 +232,28 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
244 private static void normalize2(float[,] v, int i) 232 private static void normalize2(float[,] v, int i)
245 { 233 {
246 float s; 234 float s;
235 float a = v[i, 0];
236 float b = v[i, 1];
247 237
248 s = (float)Math.Sqrt(v[i, 0] * v[i, 0] + v[i, 1] * v[i, 1]); 238 s = (float)Math.Sqrt(a * a + b * b);
249 s = 1.0f / s; 239 s = 1.0f / s;
250 v[i, 0] = v[i, 0] * s; 240 v[i, 0] = a * s;
251 v[i, 1] = v[i, 1] * s; 241 v[i, 1] = b * s;
252 } 242 }
253 243
254 private static void normalize3(float[,] v, int i) 244 private static void normalize3(float[,] v, int i)
255 { 245 {
256 float s; 246 float s;
247 float a = v[i, 0];
248 float b = v[i, 1];
249 float c = v[i, 2];
257 250
258 s = (float)Math.Sqrt(v[i, 0] * v[i, 0] + v[i, 1] * v[i, 1] + v[i, 2] * v[i, 2]); 251 s = (float)Math.Sqrt(a * a + b * b + c * c);
259 s = 1.0f / s; 252 s = 1.0f / s;
260 253
261 v[i, 0] = v[i, 0] * s; 254 v[i, 0] = a * s;
262 v[i, 1] = v[i, 1] * s; 255 v[i, 1] = b * s;
263 v[i, 2] = v[i, 2] * s; 256 v[i, 2] = c * s;
264 } 257 }
265 258
266 private static float s_curve(float t) 259 private static float s_curve(float t)
diff --git a/OpenSim/Region/CoreModules/World/Warp3DMap/TerrainSplat.cs b/OpenSim/Region/CoreModules/World/Warp3DMap/TerrainSplat.cs
index 51f8f75..4b9f207 100644
--- a/OpenSim/Region/CoreModules/World/Warp3DMap/TerrainSplat.cs
+++ b/OpenSim/Region/CoreModules/World/Warp3DMap/TerrainSplat.cs
@@ -82,9 +82,9 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
82 82
83 public static Bitmap Splat(ITerrainChannel terrain, UUID[] textureIDs, 83 public static Bitmap Splat(ITerrainChannel terrain, UUID[] textureIDs,
84 float[] startHeights, float[] heightRanges, 84 float[] startHeights, float[] heightRanges,
85 uint regionPositionX,uint regionPositionY, 85 uint regionPositionX, uint regionPositionY,
86 IAssetService assetService, IJ2KDecoder decoder, 86 IAssetService assetService, IJ2KDecoder decoder,
87 bool textureTerrain, bool averagetextureTerrain, bool FlipedY, 87 bool textureTerrain, bool averagetextureTerrain,
88 int twidth, int theight) 88 int twidth, int theight)
89 { 89 {
90 Debug.Assert(textureIDs.Length == 4); 90 Debug.Assert(textureIDs.Length == 4);
@@ -303,87 +303,48 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
303 float layerDiff; 303 float layerDiff;
304 int l0; 304 int l0;
305 int l1; 305 int l1;
306 uint yglobalpos;
306 307
307 if(usecolors) 308 if(usecolors)
308 { 309 {
309 float a; 310 float a;
310 float b; 311 float b;
311 if(FlipedY) 312 unsafe
312 { 313 {
313 unsafe 314 byte* ptrO;
315 for(int y = 0; y < theight; ++y)
314 { 316 {
315 for(int y = 0; y < theight; ++y) 317 pcty = y * invtheightMinus1;
316 { 318 ptrO = (byte*)outputData.Scan0 + y * outputData.Stride;
317 ty = (int)(y * yFactor); 319 ty = (int)(y * yFactor);
318 pcty = y * invtheightMinus1; 320 yglobalpos = (uint)ty + regionPositionY;
319 byte* ptrO = (byte*)outputData.Scan0 + y * outputData.Stride;
320 321
321 for(int x = 0; x < twidth; ++x) 322 for(int x = 0; x < twidth; ++x)
322 {
323 tx = (int)(x * xFactor);
324 pctx = x * invtwitdthMinus1;
325 height = (float)terrain[tx, ty];
326 layer = getLayerTex(height, pctx, pcty,
327 (uint)tx + regionPositionX, (uint)ty + regionPositionY,
328 startHeights, heightRanges);
329
330 // Select two textures
331 l0 = (int)layer;
332 l1 = Math.Min(l0 + 1, 3);
333
334 layerDiff = layer - l0;
335
336 a = mapColorsRed[l0];
337 b = mapColorsRed[l1];
338 *(ptrO++) = (byte)(a + layerDiff * (b - a));
339
340 a = mapColorsGreen[l0];
341 b = mapColorsGreen[l1];
342 *(ptrO++) = (byte)(a + layerDiff * (b - a));
343
344 a = mapColorsBlue[l0];
345 b = mapColorsBlue[l1];
346 *(ptrO++) = (byte)(a + layerDiff * (b - a));
347 }
348 }
349 }
350 }
351 else
352 {
353 unsafe
354 {
355 for(int y = 0; y < theight; ++y)
356 { 323 {
357 ty = (int)((theight - y -1) * yFactor); 324 tx = (int)(x * xFactor);
358 pcty = 1.0f - y * invtheightMinus1; 325 pctx = x * invtwitdthMinus1;
359 byte* ptrO = (byte*)outputData.Scan0 + y * outputData.Stride; 326 height = (float)terrain[tx, ty];
360 327 layer = getLayerTex(height, pctx, pcty,
361 for(int x = 0; x < twidth; ++x) 328 (uint)tx + regionPositionX, yglobalpos,
362 { 329 startHeights, heightRanges);
363 tx = (int)(x * xFactor); 330
364 pctx = x * invtwitdthMinus1; 331 // Select two textures
365 height = (float)terrain[tx, ty]; 332 l0 = (int)layer;
366 layer = getLayerTex(height, pctx , pcty, 333 l1 = Math.Min(l0 + 1, 3);
367 (uint)tx + regionPositionX, (uint)ty + regionPositionY, 334
368 startHeights, heightRanges); 335 layerDiff = layer - l0;
369 336
370 // Select two textures 337 a = mapColorsRed[l0];
371 l0 = (int)layer; 338 b = mapColorsRed[l1];
372 l1 = Math.Min(l0 + 1, 3); 339 *(ptrO++) = (byte)(a + layerDiff * (b - a));
373 340
374 layerDiff = layer - l0; 341 a = mapColorsGreen[l0];
375 a = mapColorsRed[l0]; 342 b = mapColorsGreen[l1];
376 b = mapColorsRed[l1]; 343 *(ptrO++) = (byte)(a + layerDiff * (b - a));
377 *(ptrO++) = (byte)(a + layerDiff * (b - a)); 344
378 345 a = mapColorsBlue[l0];
379 a = mapColorsGreen[l0]; 346 b = mapColorsBlue[l1];
380 b = mapColorsGreen[l1]; 347 *(ptrO++) = (byte)(a + layerDiff * (b - a));
381 *(ptrO++) = (byte)(a + layerDiff * (b - a));
382
383 a = mapColorsBlue[l0];
384 b = mapColorsBlue[l1];
385 *(ptrO++) = (byte)(a + layerDiff * (b - a));
386 }
387 } 348 }
388 } 349 }
389 } 350 }
@@ -396,100 +357,59 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
396 float bB; 357 float bB;
397 float bG; 358 float bG;
398 float bR; 359 float bR;
360
399 unsafe 361 unsafe
400 { 362 {
401 // Get handles to all of the texture data arrays 363 // Get handles to all of the texture data arrays
402 BitmapData[] datas = new BitmapData[] 364 BitmapData[] datas = new BitmapData[]
403 { 365 {
404 detailTexture[0].LockBits(new Rectangle(0, 0, 16, 16), ImageLockMode.ReadOnly, detailTexture[0].PixelFormat), 366 detailTexture[0].LockBits(new Rectangle(0, 0, 16, 16), ImageLockMode.ReadOnly, detailTexture[0].PixelFormat),
405 detailTexture[1].LockBits(new Rectangle(0, 0, 16, 16), ImageLockMode.ReadOnly, detailTexture[1].PixelFormat), 367 detailTexture[1].LockBits(new Rectangle(0, 0, 16, 16), ImageLockMode.ReadOnly, detailTexture[1].PixelFormat),
406 detailTexture[2].LockBits(new Rectangle(0, 0, 16, 16), ImageLockMode.ReadOnly, detailTexture[2].PixelFormat), 368 detailTexture[2].LockBits(new Rectangle(0, 0, 16, 16), ImageLockMode.ReadOnly, detailTexture[2].PixelFormat),
407 detailTexture[3].LockBits(new Rectangle(0, 0, 16, 16), ImageLockMode.ReadOnly, detailTexture[3].PixelFormat) 369 detailTexture[3].LockBits(new Rectangle(0, 0, 16, 16), ImageLockMode.ReadOnly, detailTexture[3].PixelFormat)
408 }; 370 };
409 371
410 if(FlipedY) 372 byte* ptr;
411 { 373 byte* ptrO;
412 for(int y = 0; y < theight; y++) 374 for(int y = 0; y < theight; y++)
413 {
414 ty = (int)(y * yFactor);
415 pcty = y * invtheightMinus1;
416 int ypatch = ((int)(y * yFactor) & 0x0f) * datas[0].Stride;
417 for(int x = 0; x < twidth; x++)
418 {
419 tx = (int)(x * xFactor);
420 pctx = x * invtwitdthMinus1;
421 height = (float)terrain[tx, ty];
422 layer = getLayerTex(height, pctx, pcty,
423 (uint)tx + regionPositionX, (uint)ty + regionPositionY,
424 startHeights, heightRanges);
425
426 // Select two textures
427 l0 = (int)layer;
428 l1 = Math.Min(l0 + 1, 3);
429
430 int patchOffset = (tx & 0x0f) * 3 + ypatch;
431 byte* ptrA = (byte*)datas[l0].Scan0 + patchOffset;
432 byte* ptrB = (byte*)datas[l1].Scan0 + patchOffset;
433 byte* ptrO = (byte*)outputData.Scan0 + y * outputData.Stride + x * 3;
434
435 aB = *(ptrA + 0);
436 aG = *(ptrA + 1);
437 aR = *(ptrA + 2);
438
439 bB = *(ptrB + 0);
440 bG = *(ptrB + 1);
441 bR = *(ptrB + 2);
442
443 layerDiff = layer - l0;
444
445 // Interpolate between the two selected textures
446 *(ptrO + 0) = (byte)(aB + layerDiff * (bB - aB));
447 *(ptrO + 1) = (byte)(aG + layerDiff * (bG - aG));
448 *(ptrO + 2) = (byte)(aR + layerDiff * (bR - aR));
449 }
450 }
451 }
452 else
453 { 375 {
454 for(int y = 0; y < theight; y++) 376 pcty = y * invtheightMinus1;
455 { 377 int ypatch = ((int)(y * yFactor) & 0x0f) * datas[0].Stride;
456 ty = (int)((theight - y - 1) * yFactor); 378 ptrO = (byte*)outputData.Scan0 + y * outputData.Stride;
457 pcty = 1.0f - y * invtheightMinus1; 379 ty = (int)(y * yFactor);
458 int ypatch = ((int)(y * yFactor) & 0x0f) * datas[0].Stride; 380 yglobalpos = (uint)ty + regionPositionY;
459 381
460 for(int x = 0; x < twidth; x++) 382 for(int x = 0; x < twidth; x++)
461 { 383 {
462 tx = (int)(x * xFactor); 384 tx = (int)(x * xFactor);
463 pctx = x * invtwitdthMinus1; 385 pctx = x * invtwitdthMinus1;
464 height = (float)terrain[tx, ty]; 386 height = (float)terrain[tx, ty];
465 layer = getLayerTex(height, pctx, pcty, 387 layer = getLayerTex(height, pctx, pcty,
466 (uint)tx + regionPositionX, (uint)ty + regionPositionY, 388 (uint)tx + regionPositionX, yglobalpos,
467 startHeights, heightRanges); 389 startHeights, heightRanges);
468 390
469 // Select two textures 391 // Select two textures
470 l0 = (int)layer; 392 l0 = (int)layer;
471 l1 = Math.Min(l0 + 1, 3); 393 layerDiff = layer - l0;
472 394
473 int patchOffset = (tx & 0x0f) * 3 + ypatch; 395 int patchOffset = (tx & 0x0f) * 3 + ypatch;
474 byte* ptrA = (byte*)datas[l0].Scan0 + patchOffset; 396
475 byte* ptrB = (byte*)datas[l1].Scan0 + patchOffset; 397 ptr = (byte*)datas[l0].Scan0 + patchOffset;
476 byte* ptrO = (byte*)outputData.Scan0 + y * outputData.Stride + x * 3; 398 aB = *(ptr++);
477 399 aG = *(ptr++);
478 aB = *(ptrA + 0); 400 aR = *(ptr);
479 aG = *(ptrA + 1); 401
480 aR = *(ptrA + 2); 402 l1 = Math.Min(l0 + 1, 3);
481 403 ptr = (byte*)datas[l1].Scan0 + patchOffset;
482 bB = *(ptrB + 0); 404 bB = *(ptr++);
483 bG = *(ptrB + 1); 405 bG = *(ptr++);
484 bR = *(ptrB + 2); 406 bR = *(ptr);
485 407
486 layerDiff = layer - l0; 408
487 409 // Interpolate between the two selected textures
488 // Interpolate between the two selected textures 410 *(ptrO++) = (byte)(aB + layerDiff * (bB - aB));
489 *(ptrO + 0) = (byte)(aB + layerDiff * (bB - aB)); 411 *(ptrO++) = (byte)(aG + layerDiff * (bG - aG));
490 *(ptrO + 1) = (byte)(aG + layerDiff * (bG - aG)); 412 *(ptrO++) = (byte)(aR + layerDiff * (bR - aR));
491 *(ptrO + 2) = (byte)(aR + layerDiff * (bR - aR));
492 }
493 } 413 }
494 } 414 }
495 415
@@ -512,7 +432,7 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
512 } 432 }
513 433
514 [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] 434 [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
515 private static float getLayerTex(float height, float pctX, float pctY, uint sourceX, uint sourceY, 435 private static float getLayerTex(float height, float pctX, float pctY, uint X, uint Y,
516 float[] startHeights, float[] heightRanges) 436 float[] startHeights, float[] heightRanges)
517 { 437 {
518 // Use bilinear interpolation between the four corners of start height and 438 // Use bilinear interpolation between the four corners of start height and
@@ -533,15 +453,11 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
533 453
534 // Generate two frequencies of perlin noise based on our global position 454 // Generate two frequencies of perlin noise based on our global position
535 // The magic values were taken from http://opensimulator.org/wiki/Terrain_Splatting 455 // The magic values were taken from http://opensimulator.org/wiki/Terrain_Splatting
536 Vector3 vec = new Vector3 456 float sX = X * 0.20319f;
537 ( 457 float sY = Y * 0.20319f;
538 sourceX * 0.20319f, 458
539 sourceY * 0.20319f, 459 float noise = Perlin.noise2(sX * 0.222222f, sY * 0.222222f) * 13.0f;
540 height * 0.25f 460 noise += Perlin.turbulence2(sX, sY, 2f) * 4.5f;
541 );
542
543 float noise = Perlin.noise2(vec.X * 0.222222f, vec.Y * 0.222222f) * 13.0f;
544 noise += Perlin.turbulence2(vec.X, vec.Y, 2f) * 4.5f;
545 461
546 // Combine the current height, generated noise, start height, and height range parameters, then scale all of it 462 // Combine the current height, generated noise, start height, and height range parameters, then scale all of it
547 float layer = ((height + noise - startHeight) / heightRange) * 4f; 463 float layer = ((height + noise - startHeight) / heightRange) * 4f;
diff --git a/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs
index dae78d2..d7e9114 100644
--- a/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs
+++ b/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs
@@ -172,7 +172,7 @@ namespace OpenSim.Region.DataSnapshot
172 if (m_snapStore == null) 172 if (m_snapStore == null)
173 { 173 {
174 m_hostname = scene.RegionInfo.ExternalHostName; 174 m_hostname = scene.RegionInfo.ExternalHostName;
175 m_snapStore = new SnapshotStore(m_snapsDir, m_gridinfo, m_listener_port, m_hostname); 175 m_snapStore = new SnapshotStore(m_snapsDir, m_gridinfo);
176 } 176 }
177 177
178 m_snapStore.AddScene(scene); 178 m_snapStore.AddScene(scene);