correct some errors in decoding of mesh asset convex decomposition data
parent
e597a7d94e
commit
0cdea5c2f3
|
@ -386,9 +386,40 @@ namespace OpenSim.Region.Physics.Meshing
|
|||
|
||||
if (map.ContainsKey("physics_convex"))
|
||||
{ // pull this out also in case physics engine can use it
|
||||
OSD convexBlockOsd = null;
|
||||
try
|
||||
{
|
||||
OSDMap convexBlock = (OSDMap)map["physics_convex"];
|
||||
{
|
||||
int convexOffset = convexBlock["offset"].AsInteger() + (int)start;
|
||||
int convexSize = convexBlock["size"].AsInteger();
|
||||
|
||||
byte[] convexBytes = new byte[convexSize];
|
||||
|
||||
System.Buffer.BlockCopy(primShape.SculptData, convexOffset, convexBytes, 0, convexSize);
|
||||
|
||||
try
|
||||
{
|
||||
convexBlockOsd = DecompressOsd(convexBytes);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("{0} prim='{1}': exception decoding convex block: {2}", LogHeader, primName, e);
|
||||
//return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (convexBlockOsd != null && convexBlockOsd is OSDMap)
|
||||
{
|
||||
convexBlock = convexBlockOsd as OSDMap;
|
||||
|
||||
if (debugDetail)
|
||||
{
|
||||
string keys = "[MESH]: keys found in convexBlock: ";
|
||||
foreach (KeyValuePair<string, OSD> kvp in convexBlock)
|
||||
keys += "'" + kvp.Key + "' ";
|
||||
m_log.Info(keys);
|
||||
}
|
||||
|
||||
Vector3 min = new Vector3(-0.5f, -0.5f, -0.5f);
|
||||
if (convexBlock.ContainsKey("Min")) min = convexBlock["Min"].AsVector3();
|
||||
|
@ -399,10 +430,9 @@ namespace OpenSim.Region.Physics.Meshing
|
|||
|
||||
if (convexBlock.ContainsKey("BoundingVerts"))
|
||||
{
|
||||
// decompress and decode bounding hull points
|
||||
byte[] boundingVertsBytes = DecompressOsd(convexBlock["BoundingVerts"].AsBinary()).AsBinary();
|
||||
byte[] boundingVertsBytes = convexBlock["BoundingVerts"].AsBinary();
|
||||
boundingHull = new List<Vector3>();
|
||||
for (int i = 0; i < boundingVertsBytes.Length;)
|
||||
for (int i = 0; i < boundingVertsBytes.Length; )
|
||||
{
|
||||
ushort uX = Utils.BytesToUInt16(boundingVertsBytes, i); i += 2;
|
||||
ushort uY = Utils.BytesToUInt16(boundingVertsBytes, i); i += 2;
|
||||
|
@ -418,15 +448,14 @@ namespace OpenSim.Region.Physics.Meshing
|
|||
}
|
||||
|
||||
mBoundingHull = boundingHull;
|
||||
if (debugDetail) m_log.DebugFormat("{0} prim='{1}': parsed bounding hull. nHulls={2}", LogHeader, primName, mBoundingHull.Count);
|
||||
if (debugDetail) m_log.DebugFormat("{0} prim='{1}': parsed bounding hull. nVerts={2}", LogHeader, primName, mBoundingHull.Count);
|
||||
}
|
||||
|
||||
if (convexBlock.ContainsKey("HullList"))
|
||||
{
|
||||
byte[] hullList = convexBlock["HullList"].AsBinary();
|
||||
|
||||
// decompress and decode hull points
|
||||
byte[] posBytes = DecompressOsd(convexBlock["Positions"].AsBinary()).AsBinary();
|
||||
byte[] posBytes = convexBlock["Positions"].AsBinary();
|
||||
|
||||
List<List<Vector3>> hulls = new List<List<Vector3>>();
|
||||
int posNdx = 0;
|
||||
|
@ -462,6 +491,7 @@ namespace OpenSim.Region.Physics.Meshing
|
|||
if (debugDetail) m_log.DebugFormat("{0} prim='{1}' has physics_convex but no HullList", LogHeader, primName);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.WarnFormat("{0} exception decoding convex block: {1}", LogHeader, e);
|
||||
|
@ -483,7 +513,7 @@ namespace OpenSim.Region.Physics.Meshing
|
|||
OSD decodedMeshOsd = new OSD();
|
||||
byte[] meshBytes = new byte[physSize];
|
||||
System.Buffer.BlockCopy(primShape.SculptData, physOffset, meshBytes, 0, physSize);
|
||||
// byte[] decompressed = new byte[physSize * 5];
|
||||
// byte[] decompressed = new byte[physSize * 5];
|
||||
try
|
||||
{
|
||||
decodedMeshOsd = DecompressOsd(meshBytes);
|
||||
|
@ -499,7 +529,7 @@ namespace OpenSim.Region.Physics.Meshing
|
|||
// physics_shape is an array of OSDMaps, one for each submesh
|
||||
if (decodedMeshOsd is OSDArray)
|
||||
{
|
||||
// Console.WriteLine("decodedMeshOsd for {0} - {1}", primName, Util.GetFormattedXml(decodedMeshOsd));
|
||||
// Console.WriteLine("decodedMeshOsd for {0} - {1}", primName, Util.GetFormattedXml(decodedMeshOsd));
|
||||
|
||||
decodedMeshOsdArray = (OSDArray)decodedMeshOsd;
|
||||
foreach (OSD subMeshOsd in decodedMeshOsdArray)
|
||||
|
|
Loading…
Reference in New Issue