minor cleanup on mesh decompress code
parent
2739b2f5cc
commit
ba66d2d3c1
|
@ -563,13 +563,11 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
nsides = 0;
|
nsides = 0;
|
||||||
|
|
||||||
OSD decodedMeshOsd = new OSD();
|
OSD decodedMeshOsd = new OSD();
|
||||||
byte[] meshBytes = new byte[size];
|
|
||||||
System.Buffer.BlockCopy(data, offset, meshBytes, 0, size);
|
|
||||||
try
|
try
|
||||||
{
|
|
||||||
using (MemoryStream inMs = new MemoryStream(meshBytes))
|
|
||||||
{
|
{
|
||||||
using (MemoryStream outMs = new MemoryStream())
|
using (MemoryStream outMs = new MemoryStream())
|
||||||
|
{
|
||||||
|
using (MemoryStream inMs = new MemoryStream(data, offset, size))
|
||||||
{
|
{
|
||||||
using (DeflateStream decompressionStream = new DeflateStream(inMs, CompressionMode.Decompress))
|
using (DeflateStream decompressionStream = new DeflateStream(inMs, CompressionMode.Decompress))
|
||||||
{
|
{
|
||||||
|
@ -579,13 +577,10 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
|
|
||||||
while ((readLen = decompressionStream.Read(readBuffer, 0, readBuffer.Length)) > 0)
|
while ((readLen = decompressionStream.Read(readBuffer, 0, readBuffer.Length)) > 0)
|
||||||
outMs.Write(readBuffer, 0, readLen);
|
outMs.Write(readBuffer, 0, readLen);
|
||||||
|
}
|
||||||
|
}
|
||||||
outMs.Seek(0, SeekOrigin.Begin);
|
outMs.Seek(0, SeekOrigin.Begin);
|
||||||
|
decodedMeshOsd = OSDParser.DeserializeLLSDBinary(outMs);
|
||||||
byte[] decompressedBuf = outMs.GetBuffer();
|
|
||||||
decodedMeshOsd = OSDParser.DeserializeLLSDBinary(decompressedBuf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
@ -630,29 +625,24 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
nhulls = 1;
|
nhulls = 1;
|
||||||
|
|
||||||
OSD decodedMeshOsd = new OSD();
|
OSD decodedMeshOsd = new OSD();
|
||||||
byte[] meshBytes = new byte[size];
|
|
||||||
System.Buffer.BlockCopy(data, offset, meshBytes, 0, size);
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (MemoryStream inMs = new MemoryStream(meshBytes))
|
using (MemoryStream outMs = new MemoryStream(4 * size))
|
||||||
{
|
{
|
||||||
using (MemoryStream outMs = new MemoryStream())
|
using (MemoryStream inMs = new MemoryStream(data, offset, size))
|
||||||
{
|
{
|
||||||
using (DeflateStream decompressionStream = new DeflateStream(inMs, CompressionMode.Decompress))
|
using (DeflateStream decompressionStream = new DeflateStream(inMs, CompressionMode.Decompress))
|
||||||
{
|
{
|
||||||
byte[] readBuffer = new byte[2048];
|
byte[] readBuffer = new byte[8192];
|
||||||
inMs.Read(readBuffer, 0, 2); // skip first 2 bytes in header
|
inMs.Read(readBuffer, 0, 2); // skip first 2 bytes in header
|
||||||
int readLen = 0;
|
int readLen = 0;
|
||||||
|
|
||||||
while ((readLen = decompressionStream.Read(readBuffer, 0, readBuffer.Length)) > 0)
|
while ((readLen = decompressionStream.Read(readBuffer, 0, readBuffer.Length)) > 0)
|
||||||
outMs.Write(readBuffer, 0, readLen);
|
outMs.Write(readBuffer, 0, readLen);
|
||||||
|
}
|
||||||
|
}
|
||||||
outMs.Seek(0, SeekOrigin.Begin);
|
outMs.Seek(0, SeekOrigin.Begin);
|
||||||
|
decodedMeshOsd = OSDParser.DeserializeLLSDBinary(outMs);
|
||||||
byte[] decompressedBuf = outMs.GetBuffer();
|
|
||||||
decodedMeshOsd = OSDParser.DeserializeLLSDBinary(decompressedBuf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
|
|
@ -597,28 +597,22 @@ namespace OpenSim.Region.PhysicsModule.Meshing
|
||||||
{
|
{
|
||||||
OSD decodedOsd = null;
|
OSD decodedOsd = null;
|
||||||
|
|
||||||
using (MemoryStream inMs = new MemoryStream(meshBytes))
|
|
||||||
{
|
|
||||||
using (MemoryStream outMs = new MemoryStream())
|
using (MemoryStream outMs = new MemoryStream())
|
||||||
|
{
|
||||||
|
using (MemoryStream inMs = new MemoryStream(meshBytes))
|
||||||
{
|
{
|
||||||
using (DeflateStream decompressionStream = new DeflateStream(inMs, CompressionMode.Decompress))
|
using (DeflateStream decompressionStream = new DeflateStream(inMs, CompressionMode.Decompress))
|
||||||
{
|
{
|
||||||
byte[] readBuffer = new byte[2048];
|
byte[] readBuffer = new byte[8192];
|
||||||
inMs.Read(readBuffer, 0, 2); // skip first 2 bytes in header
|
inMs.Read(readBuffer, 0, 2); // skip first 2 bytes in header
|
||||||
int readLen = 0;
|
int readLen = 0;
|
||||||
|
|
||||||
while ((readLen = decompressionStream.Read(readBuffer, 0, readBuffer.Length)) > 0)
|
while ((readLen = decompressionStream.Read(readBuffer, 0, readBuffer.Length)) > 0)
|
||||||
outMs.Write(readBuffer, 0, readLen);
|
outMs.Write(readBuffer, 0, readLen);
|
||||||
|
}
|
||||||
outMs.Flush();
|
}
|
||||||
|
|
||||||
outMs.Seek(0, SeekOrigin.Begin);
|
outMs.Seek(0, SeekOrigin.Begin);
|
||||||
|
decodedOsd = OSDParser.DeserializeLLSDBinary(outMs);
|
||||||
byte[] decompressedBuf = outMs.GetBuffer();
|
|
||||||
|
|
||||||
decodedOsd = OSDParser.DeserializeLLSDBinary(decompressedBuf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return decodedOsd;
|
return decodedOsd;
|
||||||
}
|
}
|
||||||
|
|
|
@ -425,31 +425,24 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
|
||||||
return false; // no mesh data in asset
|
return false; // no mesh data in asset
|
||||||
|
|
||||||
OSD decodedMeshOsd = new OSD();
|
OSD decodedMeshOsd = new OSD();
|
||||||
byte[] meshBytes = new byte[physSize];
|
|
||||||
System.Buffer.BlockCopy(primShape.SculptData, physOffset, meshBytes, 0, physSize);
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (MemoryStream inMs = new MemoryStream(meshBytes))
|
using (MemoryStream outMs = new MemoryStream(4 * physSize))
|
||||||
{
|
{
|
||||||
using (MemoryStream outMs = new MemoryStream())
|
using (MemoryStream inMs = new MemoryStream(primShape.SculptData, physOffset, physSize))
|
||||||
{
|
{
|
||||||
using (DeflateStream decompressionStream = new DeflateStream(inMs, CompressionMode.Decompress))
|
using (DeflateStream decompressionStream = new DeflateStream(inMs, CompressionMode.Decompress))
|
||||||
{
|
{
|
||||||
byte[] readBuffer = new byte[2048];
|
byte[] readBuffer = new byte[8192];
|
||||||
inMs.Read(readBuffer, 0, 2); // skip first 2 bytes in header
|
inMs.Read(readBuffer, 0, 2); // skip first 2 bytes in header
|
||||||
int readLen = 0;
|
int readLen = 0;
|
||||||
|
|
||||||
while ((readLen = decompressionStream.Read(readBuffer, 0, readBuffer.Length)) > 0)
|
while ((readLen = decompressionStream.Read(readBuffer, 0, readBuffer.Length)) > 0)
|
||||||
outMs.Write(readBuffer, 0, readLen);
|
outMs.Write(readBuffer, 0, readLen);
|
||||||
|
}
|
||||||
|
}
|
||||||
outMs.Seek(0, SeekOrigin.Begin);
|
outMs.Seek(0, SeekOrigin.Begin);
|
||||||
|
decodedMeshOsd = OSDParser.DeserializeLLSDBinary(outMs);
|
||||||
byte[] decompressedBuf = outMs.GetBuffer();
|
|
||||||
|
|
||||||
decodedMeshOsd = OSDParser.DeserializeLLSDBinary(decompressedBuf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
Loading…
Reference in New Issue