aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorUbitUmarov2015-08-25 17:54:49 +0100
committerUbitUmarov2015-08-25 17:54:49 +0100
commitef3deffeeb0664443f7bef6cc7f2f6844355364b (patch)
treeba45a67eff4101a0ab7c24b45727e3a774dd8f30 /OpenSim/Framework
parent change terrain internal representation to float. ushort work with legal (diff)
downloadopensim-SC-ef3deffeeb0664443f7bef6cc7f2f6844355364b.zip
opensim-SC-ef3deffeeb0664443f7bef6cc7f2f6844355364b.tar.gz
opensim-SC-ef3deffeeb0664443f7bef6cc7f2f6844355364b.tar.bz2
opensim-SC-ef3deffeeb0664443f7bef6cc7f2f6844355364b.tar.xz
remove rest of ushort test code
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/TerrainData.cs125
1 files changed, 31 insertions, 94 deletions
diff --git a/OpenSim/Framework/TerrainData.cs b/OpenSim/Framework/TerrainData.cs
index 976c1f0..c66c1ad 100644
--- a/OpenSim/Framework/TerrainData.cs
+++ b/OpenSim/Framework/TerrainData.cs
@@ -108,12 +108,6 @@ namespace OpenSim.Framework
108 // The dimensions are presumed to be multiples of 16 and, more likely, multiples of 256. 108 // The dimensions are presumed to be multiples of 16 and, more likely, multiples of 256.
109 Compressed2D = 27, 109 Compressed2D = 27,
110 110
111 // as Compressed2D but using ushort[] in place of int16[]
112 Compressed2Du = 28,
113
114 // as Compressed2D but using ushort[] in place of int16[] with Gzip compression
115 Compressed2DuGzip = 29,
116
117 // A revision that is not listed above or any revision greater than this value is 'Legacy256'. 111 // A revision that is not listed above or any revision greater than this value is 'Legacy256'.
118 RevisionHigh = 1234 112 RevisionHigh = 1234
119 } 113 }
@@ -373,21 +367,12 @@ namespace OpenSim.Framework
373 { 367 {
374 case DBTerrainRevision.Variable2DGzip: 368 case DBTerrainRevision.Variable2DGzip:
375 FromCompressedTerrainSerializationV2DGZip(pBlob); 369 FromCompressedTerrainSerializationV2DGZip(pBlob);
376 m_log.DebugFormat("{0} HeightmapTerrainData create from Gzip Compressed2D (unsigned shorts) serialization. Size=<{1},{2}>", LogHeader, SizeX, SizeY); 370 m_log.DebugFormat("{0} HeightmapTerrainData create from Variable2DGzip serialization. Size=<{1},{2}>", LogHeader, SizeX, SizeY);
377 break; 371 break;
378 372
379 case DBTerrainRevision.Variable2D: 373 case DBTerrainRevision.Variable2D:
380 FromCompressedTerrainSerializationV2D(pBlob); 374 FromCompressedTerrainSerializationV2D(pBlob);
381 m_log.DebugFormat("{0} HeightmapTerrainData create from Gzip Compressed2D (unsigned shorts) serialization. Size=<{1},{2}>", LogHeader, SizeX, SizeY); 375 m_log.DebugFormat("{0} HeightmapTerrainData create from Variable2D serialization. Size=<{1},{2}>", LogHeader, SizeX, SizeY);
382 break;
383
384 case DBTerrainRevision.Compressed2DuGzip:
385 FromCompressedTerrainSerialization2DuGZip(pBlob);
386 m_log.DebugFormat("{0} HeightmapTerrainData create from Gzip Compressed2D (unsigned shorts) serialization. Size=<{1},{2}>", LogHeader, SizeX, SizeY);
387 break;
388 case DBTerrainRevision.Compressed2Du:
389 FromCompressedTerrainSerialization2D(pBlob);
390 m_log.DebugFormat("{0} HeightmapTerrainData create from Compressed2D (unsigned shorts) serialization. Size=<{1},{2}>", LogHeader, SizeX, SizeY);
391 break; 376 break;
392 case DBTerrainRevision.Compressed2D: 377 case DBTerrainRevision.Compressed2D:
393 FromCompressedTerrainSerialization2D(pBlob); 378 FromCompressedTerrainSerialization2D(pBlob);
@@ -425,7 +410,7 @@ namespace OpenSim.Framework
425 return ret; 410 return ret;
426 } 411 }
427 412
428 // Just create an array of doubles. Presumes the caller implicitly knows the size. 413 // Presumes the caller implicitly knows the size.
429 public void FromLegacyTerrainSerialization(byte[] pBlob) 414 public void FromLegacyTerrainSerialization(byte[] pBlob)
430 { 415 {
431 // In case database info doesn't match real terrain size, initialize the whole terrain. 416 // In case database info doesn't match real terrain size, initialize the whole terrain.
@@ -464,8 +449,6 @@ namespace OpenSim.Framework
464 // int32 sizeY 449 // int32 sizeY
465 // float[,] array 450 // float[,] array
466 451
467 // may have endian issues like older
468
469 public Array ToCompressedTerrainSerializationV2D() 452 public Array ToCompressedTerrainSerializationV2D()
470 { 453 {
471 Array ret = null; 454 Array ret = null;
@@ -493,6 +476,10 @@ namespace OpenSim.Framework
493 { 476 {
494 477
495 } 478 }
479
480 m_log.DebugFormat("{0} V2D {1} bytes",
481 LogHeader, ret.Length);
482
496 return ret; 483 return ret;
497 } 484 }
498 485
@@ -534,7 +521,7 @@ namespace OpenSim.Framework
534 { 521 {
535 522
536 } 523 }
537 m_log.InfoFormat("{0} terrain GZiped to {1} bytes (V2DGzip)", 524 m_log.DebugFormat("{0} V2DGzip {1} bytes",
538 LogHeader, ret.Length); 525 LogHeader, ret.Length);
539 return ret; 526 return ret;
540 } 527 }
@@ -575,20 +562,19 @@ namespace OpenSim.Framework
575 } 562 }
576 ClearTaint(); 563 ClearTaint();
577 564
578 m_log.InfoFormat("{0} Read (compressed2D) heightmap. Heightmap size=<{1},{2}>. Region size=<{3},{4}>. CompFact={5}", 565 m_log.DebugFormat("{0} Read (compressed2D) heightmap. Heightmap size=<{1},{2}>. Region size=<{3},{4}>. CompFact={5}",
579 LogHeader, hmSizeX, hmSizeY, SizeX, SizeY, hmCompressionFactor); 566 LogHeader, hmSizeX, hmSizeY, SizeX, SizeY, hmCompressionFactor);
580 } 567 }
581 } 568 }
582 569
583 // Initialize heightmap from blob consisting of: 570 // Initialize heightmap from blob consisting of:
584 // int32, int32, int32, int32, ushort[] 571 // int32, int32, int32, float[]
585 // where the first int32 is format code, next two int32s are the X and y of heightmap data and 572 // where the first int32 is format code, next two int32s are the X and y of heightmap data
586 // the forth int is the compression factor for the following int16s
587 // This is just sets heightmap info. The actual size of the region was set on this instance's 573 // This is just sets heightmap info. The actual size of the region was set on this instance's
588 // creation and any heights not initialized by theis blob are set to the default height. 574 // creation and any heights not initialized by theis blob are set to the default height.
589 public void FromCompressedTerrainSerialization2Du(byte[] pBlob) 575 public void FromCompressedTerrainSerializationV2D(byte[] pBlob)
590 { 576 {
591 Int32 hmFormatCode, hmSizeX, hmSizeY, hmCompressionFactor; 577 Int32 hmFormatCode, hmSizeX, hmSizeY;
592 try 578 try
593 { 579 {
594 using (MemoryStream mstr = new MemoryStream(pBlob)) 580 using (MemoryStream mstr = new MemoryStream(pBlob))
@@ -598,9 +584,6 @@ namespace OpenSim.Framework
598 hmFormatCode = br.ReadInt32(); 584 hmFormatCode = br.ReadInt32();
599 hmSizeX = br.ReadInt32(); 585 hmSizeX = br.ReadInt32();
600 hmSizeY = br.ReadInt32(); 586 hmSizeY = br.ReadInt32();
601 hmCompressionFactor = br.ReadInt32();
602
603 m_compressionFactor = hmCompressionFactor;
604 587
605 // In case database info doesn't match real terrain size, initialize the whole terrain. 588 // In case database info doesn't match real terrain size, initialize the whole terrain.
606 ClearLand(); 589 ClearLand();
@@ -609,7 +592,7 @@ namespace OpenSim.Framework
609 { 592 {
610 for (int xx = 0; xx < hmSizeX; xx++) 593 for (int xx = 0; xx < hmSizeX; xx++)
611 { 594 {
612 float val = FromCompressedHeight(br.ReadUInt16()); 595 float val = br.ReadSingle();
613 if (xx < SizeX && yy < SizeY) 596 if (xx < SizeX && yy < SizeY)
614 m_heightmap[xx, yy] = val; 597 m_heightmap[xx, yy] = val;
615 } 598 }
@@ -620,59 +603,41 @@ namespace OpenSim.Framework
620 catch (Exception e) 603 catch (Exception e)
621 { 604 {
622 ClearTaint(); 605 ClearTaint();
623 m_log.ErrorFormat("{0} Read (compressed2Dus) terrain error: {1} - terrain may be damaged", 606 m_log.ErrorFormat("{0} 2D error: {1} - terrain may be damaged",
624 LogHeader, e.Message); 607 LogHeader, e.Message);
625 return; 608 return;
626 } 609 }
627 ClearTaint(); 610 ClearTaint();
628 611
629 m_log.InfoFormat("{0} Read compressed2D terrain. Heightmap size=<{1},{2}>. Region size=<{3},{4}>. CompFact={5}", 612 m_log.DebugFormat("{0} V2D Heightmap size=<{1},{2}>. Region size=<{3},{4}>",
630 LogHeader, hmSizeX, hmSizeY, SizeX, SizeY, hmCompressionFactor); 613 LogHeader, hmSizeX, hmSizeY, SizeX, SizeY);
631 614
632 } 615 }
633 616
634 // as above but Gzip compressed 617 // as above but Gzip compressed
635 public void FromCompressedTerrainSerialization2DuGZip(byte[] pBlob) 618 public void FromCompressedTerrainSerializationV2DGZip(byte[] pBlob)
636 { 619 {
637 m_log.InfoFormat("{0} GZip {1} bytes for terrain", 620 m_log.InfoFormat("{0} VD2Gzip {1} bytes input",
638 LogHeader, pBlob.Length); 621 LogHeader, pBlob.Length);
639 byte[] gzipout = null; 622
623 Int32 hmFormatCode, hmSizeX, hmSizeY;
624
640 try 625 try
641 { 626 {
642 using (MemoryStream inputStream = new MemoryStream(pBlob)) 627 using (MemoryStream outputStream = new MemoryStream())
643 { 628 {
644 using (GZipStream decompressionStream = new GZipStream(inputStream, CompressionMode.Decompress)) 629 using (MemoryStream inputStream = new MemoryStream(pBlob))
645 { 630 {
646 using (MemoryStream outputStream = new MemoryStream()) 631 using (GZipStream decompressionStream = new GZipStream(inputStream, CompressionMode.Decompress))
647 { 632 {
648 decompressionStream.Flush(); 633 decompressionStream.Flush();
649 decompressionStream.CopyTo(outputStream); 634 decompressionStream.CopyTo(outputStream);
650 gzipout = outputStream.ToArray();
651 } 635 }
652 } 636 }
653 }
654 }
655 catch
656 {
657 }
658 637
659 FromCompressedTerrainSerialization2Du(gzipout); 638 outputStream.Seek(0, SeekOrigin.Begin);
660 }
661 639
662 // Initialize heightmap from blob consisting of: 640 using (BinaryReader br = new BinaryReader(outputStream))
663 // int32, int32, int32, int32, ushort[]
664 // where the first int32 is format code, next two int32s are the X and y of heightmap data and
665 // the forth int is the compression factor for the following int16s
666 // This is just sets heightmap info. The actual size of the region was set on this instance's
667 // creation and any heights not initialized by theis blob are set to the default height.
668 public void FromCompressedTerrainSerializationV2D(byte[] pBlob)
669 {
670 Int32 hmFormatCode, hmSizeX, hmSizeY, hmCompressionFactor;
671 try
672 {
673 using (MemoryStream mstr = new MemoryStream(pBlob))
674 {
675 using (BinaryReader br = new BinaryReader(mstr))
676 { 641 {
677 hmFormatCode = br.ReadInt32(); 642 hmFormatCode = br.ReadInt32();
678 hmSizeX = br.ReadInt32(); 643 hmSizeX = br.ReadInt32();
@@ -693,46 +658,18 @@ namespace OpenSim.Framework
693 } 658 }
694 } 659 }
695 } 660 }
696 catch (Exception e) 661 catch( Exception e)
697 { 662 {
698 ClearTaint(); 663 ClearTaint();
699 m_log.ErrorFormat("{0} Read (Variable size format) terrain error: {1} - terrain may be damaged", 664 m_log.ErrorFormat("{0} V2DGzip error: {1} - terrain may be damaged",
700 LogHeader, e.Message); 665 LogHeader, e.Message);
701 return; 666 return;
702 } 667 }
703 ClearTaint();
704 668
705 m_log.InfoFormat("{0} Read Variable size format terrain. Heightmap size=<{1},{2}>. Region size=<{3},{4}>", 669 ClearTaint();
670 m_log.DebugFormat("{0} V2DGzip. Heightmap size=<{1},{2}>. Region size=<{3},{4}>",
706 LogHeader, hmSizeX, hmSizeY, SizeX, SizeY); 671 LogHeader, hmSizeX, hmSizeY, SizeX, SizeY);
707 672
708 } 673 }
709 // as above but Gzip compressed
710 public void FromCompressedTerrainSerializationV2DGZip(byte[] pBlob)
711 {
712 m_log.InfoFormat("{0} GZip {1} bytes for terrain",
713 LogHeader, pBlob.Length);
714
715 byte[] gzipout = null;
716 try
717 {
718 using (MemoryStream inputStream = new MemoryStream(pBlob))
719 {
720 using (GZipStream decompressionStream = new GZipStream(inputStream, CompressionMode.Decompress))
721 {
722 using (MemoryStream outputStream = new MemoryStream())
723 {
724 decompressionStream.Flush();
725 decompressionStream.CopyTo(outputStream);
726 gzipout = outputStream.ToArray();
727 }
728 }
729 }
730 }
731 catch
732 {
733 }
734
735 FromCompressedTerrainSerializationV2D(gzipout);
736 }
737 } 674 }
738} 675}