diff options
author | UbitUmarov | 2019-04-02 10:13:26 +0100 |
---|---|---|
committer | UbitUmarov | 2019-04-02 10:13:26 +0100 |
commit | ba66d2d3c125136171dc9fec34bb9d424a6a731d (patch) | |
tree | d5cd06c550f27d73af5cff6cd50036ea7e27ed39 /OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps | |
parent | mantis 8509: replace mesh gzip decompress (diff) | |
download | opensim-SC-ba66d2d3c125136171dc9fec34bb9d424a6a731d.zip opensim-SC-ba66d2d3c125136171dc9fec34bb9d424a6a731d.tar.gz opensim-SC-ba66d2d3c125136171dc9fec34bb9d424a6a731d.tar.bz2 opensim-SC-ba66d2d3c125136171dc9fec34bb9d424a6a731d.tar.xz |
minor cleanup on mesh decompress code
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index adc8298..cf5f0ef 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs | |||
@@ -563,13 +563,11 @@ namespace OpenSim.Region.ClientStack.Linden | |||
563 | nsides = 0; | 563 | nsides = 0; |
564 | 564 | ||
565 | OSD decodedMeshOsd = new OSD(); | 565 | OSD decodedMeshOsd = new OSD(); |
566 | byte[] meshBytes = new byte[size]; | ||
567 | System.Buffer.BlockCopy(data, offset, meshBytes, 0, size); | ||
568 | try | 566 | try |
569 | { | 567 | { |
570 | using (MemoryStream inMs = new MemoryStream(meshBytes)) | 568 | using (MemoryStream outMs = new MemoryStream()) |
571 | { | 569 | { |
572 | using (MemoryStream outMs = new MemoryStream()) | 570 | using (MemoryStream inMs = new MemoryStream(data, offset, size)) |
573 | { | 571 | { |
574 | using (DeflateStream decompressionStream = new DeflateStream(inMs, CompressionMode.Decompress)) | 572 | using (DeflateStream decompressionStream = new DeflateStream(inMs, CompressionMode.Decompress)) |
575 | { | 573 | { |
@@ -579,13 +577,10 @@ namespace OpenSim.Region.ClientStack.Linden | |||
579 | 577 | ||
580 | while ((readLen = decompressionStream.Read(readBuffer, 0, readBuffer.Length)) > 0) | 578 | while ((readLen = decompressionStream.Read(readBuffer, 0, readBuffer.Length)) > 0) |
581 | outMs.Write(readBuffer, 0, readLen); | 579 | outMs.Write(readBuffer, 0, readLen); |
582 | |||
583 | outMs.Seek(0, SeekOrigin.Begin); | ||
584 | |||
585 | byte[] decompressedBuf = outMs.GetBuffer(); | ||
586 | decodedMeshOsd = OSDParser.DeserializeLLSDBinary(decompressedBuf); | ||
587 | } | 580 | } |
588 | } | 581 | } |
582 | outMs.Seek(0, SeekOrigin.Begin); | ||
583 | decodedMeshOsd = OSDParser.DeserializeLLSDBinary(outMs); | ||
589 | } | 584 | } |
590 | } | 585 | } |
591 | catch | 586 | catch |
@@ -630,29 +625,24 @@ namespace OpenSim.Region.ClientStack.Linden | |||
630 | nhulls = 1; | 625 | nhulls = 1; |
631 | 626 | ||
632 | OSD decodedMeshOsd = new OSD(); | 627 | OSD decodedMeshOsd = new OSD(); |
633 | byte[] meshBytes = new byte[size]; | ||
634 | System.Buffer.BlockCopy(data, offset, meshBytes, 0, size); | ||
635 | try | 628 | try |
636 | { | 629 | { |
637 | using (MemoryStream inMs = new MemoryStream(meshBytes)) | 630 | using (MemoryStream outMs = new MemoryStream(4 * size)) |
638 | { | 631 | { |
639 | using (MemoryStream outMs = new MemoryStream()) | 632 | using (MemoryStream inMs = new MemoryStream(data, offset, size)) |
640 | { | 633 | { |
641 | using (DeflateStream decompressionStream = new DeflateStream(inMs, CompressionMode.Decompress)) | 634 | using (DeflateStream decompressionStream = new DeflateStream(inMs, CompressionMode.Decompress)) |
642 | { | 635 | { |
643 | byte[] readBuffer = new byte[2048]; | 636 | byte[] readBuffer = new byte[8192]; |
644 | inMs.Read(readBuffer, 0, 2); // skip first 2 bytes in header | 637 | inMs.Read(readBuffer, 0, 2); // skip first 2 bytes in header |
645 | int readLen = 0; | 638 | int readLen = 0; |
646 | 639 | ||
647 | while ((readLen = decompressionStream.Read(readBuffer, 0, readBuffer.Length)) > 0) | 640 | while ((readLen = decompressionStream.Read(readBuffer, 0, readBuffer.Length)) > 0) |
648 | outMs.Write(readBuffer, 0, readLen); | 641 | outMs.Write(readBuffer, 0, readLen); |
649 | |||
650 | outMs.Seek(0, SeekOrigin.Begin); | ||
651 | |||
652 | byte[] decompressedBuf = outMs.GetBuffer(); | ||
653 | decodedMeshOsd = OSDParser.DeserializeLLSDBinary(decompressedBuf); | ||
654 | } | 642 | } |
655 | } | 643 | } |
644 | outMs.Seek(0, SeekOrigin.Begin); | ||
645 | decodedMeshOsd = OSDParser.DeserializeLLSDBinary(outMs); | ||
656 | } | 646 | } |
657 | } | 647 | } |
658 | catch | 648 | catch |