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 | |
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')
3 files changed, 19 insertions, 42 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 |
diff --git a/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/Meshmerizer.cs b/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/Meshmerizer.cs index 0d4b6b9..de39d0e 100644 --- a/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/Meshmerizer.cs +++ b/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/Meshmerizer.cs | |||
@@ -597,28 +597,22 @@ namespace OpenSim.Region.PhysicsModule.Meshing | |||
597 | { | 597 | { |
598 | OSD decodedOsd = null; | 598 | OSD decodedOsd = null; |
599 | 599 | ||
600 | using (MemoryStream inMs = new MemoryStream(meshBytes)) | 600 | using (MemoryStream outMs = new MemoryStream()) |
601 | { | 601 | { |
602 | using (MemoryStream outMs = new MemoryStream()) | 602 | using (MemoryStream inMs = new MemoryStream(meshBytes)) |
603 | { | 603 | { |
604 | using (DeflateStream decompressionStream = new DeflateStream(inMs, CompressionMode.Decompress)) | 604 | using (DeflateStream decompressionStream = new DeflateStream(inMs, CompressionMode.Decompress)) |
605 | { | 605 | { |
606 | byte[] readBuffer = new byte[2048]; | 606 | byte[] readBuffer = new byte[8192]; |
607 | inMs.Read(readBuffer, 0, 2); // skip first 2 bytes in header | 607 | inMs.Read(readBuffer, 0, 2); // skip first 2 bytes in header |
608 | int readLen = 0; | 608 | int readLen = 0; |
609 | 609 | ||
610 | while ((readLen = decompressionStream.Read(readBuffer, 0, readBuffer.Length)) > 0) | 610 | while ((readLen = decompressionStream.Read(readBuffer, 0, readBuffer.Length)) > 0) |
611 | outMs.Write(readBuffer, 0, readLen); | 611 | outMs.Write(readBuffer, 0, readLen); |
612 | |||
613 | outMs.Flush(); | ||
614 | |||
615 | outMs.Seek(0, SeekOrigin.Begin); | ||
616 | |||
617 | byte[] decompressedBuf = outMs.GetBuffer(); | ||
618 | |||
619 | decodedOsd = OSDParser.DeserializeLLSDBinary(decompressedBuf); | ||
620 | } | 612 | } |
621 | } | 613 | } |
614 | outMs.Seek(0, SeekOrigin.Begin); | ||
615 | decodedOsd = OSDParser.DeserializeLLSDBinary(outMs); | ||
622 | } | 616 | } |
623 | return decodedOsd; | 617 | return decodedOsd; |
624 | } | 618 | } |
diff --git a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs index 6950f2d..8449596 100644 --- a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs +++ b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs | |||
@@ -425,31 +425,24 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing | |||
425 | return false; // no mesh data in asset | 425 | return false; // no mesh data in asset |
426 | 426 | ||
427 | OSD decodedMeshOsd = new OSD(); | 427 | OSD decodedMeshOsd = new OSD(); |
428 | byte[] meshBytes = new byte[physSize]; | ||
429 | System.Buffer.BlockCopy(primShape.SculptData, physOffset, meshBytes, 0, physSize); | ||
430 | |||
431 | try | 428 | try |
432 | { | 429 | { |
433 | using (MemoryStream inMs = new MemoryStream(meshBytes)) | 430 | using (MemoryStream outMs = new MemoryStream(4 * physSize)) |
434 | { | 431 | { |
435 | using (MemoryStream outMs = new MemoryStream()) | 432 | using (MemoryStream inMs = new MemoryStream(primShape.SculptData, physOffset, physSize)) |
436 | { | 433 | { |
437 | using (DeflateStream decompressionStream = new DeflateStream(inMs, CompressionMode.Decompress)) | 434 | using (DeflateStream decompressionStream = new DeflateStream(inMs, CompressionMode.Decompress)) |
438 | { | 435 | { |
439 | byte[] readBuffer = new byte[2048]; | 436 | byte[] readBuffer = new byte[8192]; |
440 | inMs.Read(readBuffer, 0, 2); // skip first 2 bytes in header | 437 | inMs.Read(readBuffer, 0, 2); // skip first 2 bytes in header |
441 | int readLen = 0; | 438 | int readLen = 0; |
442 | 439 | ||
443 | while ((readLen = decompressionStream.Read(readBuffer, 0, readBuffer.Length)) > 0) | 440 | while ((readLen = decompressionStream.Read(readBuffer, 0, readBuffer.Length)) > 0) |
444 | outMs.Write(readBuffer, 0, readLen); | 441 | outMs.Write(readBuffer, 0, readLen); |
445 | |||
446 | outMs.Seek(0, SeekOrigin.Begin); | ||
447 | |||
448 | byte[] decompressedBuf = outMs.GetBuffer(); | ||
449 | |||
450 | decodedMeshOsd = OSDParser.DeserializeLLSDBinary(decompressedBuf); | ||
451 | } | 442 | } |
452 | } | 443 | } |
444 | outMs.Seek(0, SeekOrigin.Begin); | ||
445 | decodedMeshOsd = OSDParser.DeserializeLLSDBinary(outMs); | ||
453 | } | 446 | } |
454 | } | 447 | } |
455 | catch (Exception e) | 448 | catch (Exception e) |