From 5c18ebf42470038720dffcf676bf3f9dd174d443 Mon Sep 17 00:00:00 2001 From: dahlia Date: Wed, 29 Jun 2011 17:36:41 -0700 Subject: [PATCH] Allow physics proxy generation for meshes using new asset format. Fix an invalid cast exception while decoding new mesh asset format. --- OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 21 +++++++++++++++---- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 5 ++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index 99b2d8477a..a5fe45b216 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -291,7 +291,14 @@ namespace OpenSim.Region.Physics.Meshing { try { - meshOsd = (OSDMap)OSDParser.DeserializeLLSDBinary(data); + OSD osd = OSDParser.DeserializeLLSDBinary(data); + if (osd is OSDMap) + meshOsd = (OSDMap)osd; + else + { + m_log.Warn("[Mesh}: unable to cast mesh asset to OSDMap"); + return null; + } } catch (Exception e) { @@ -302,11 +309,17 @@ namespace OpenSim.Region.Physics.Meshing if (meshOsd is OSDMap) { + OSDMap physicsParms = null; OSDMap map = (OSDMap)meshOsd; - OSDMap physicsParms = (OSDMap)map["physics_shape"]; // old asset format - - if (physicsParms.Count == 0) + if (map.ContainsKey("physics_shape")) + physicsParms = (OSDMap)map["physics_shape"]; // old asset format + else if (map.ContainsKey("physics_mesh")) physicsParms = (OSDMap)map["physics_mesh"]; // new asset format + if (physicsParms == null) + { + m_log.Warn("[Mesh]: no recognized physics mesh found in mesh asset"); + return null; + } int physOffset = physicsParms["offset"].AsInteger() + (int)start; int physSize = physicsParms["size"].AsInteger(); diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index a0101af2bb..8d9f5f14d6 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -2502,7 +2502,7 @@ namespace OpenSim.Region.Physics.OdePlugin } // if it's a standard box or sphere with no cuts, hollows, twist or top shear, return false since ODE can use an internal representation for the prim - if (!forceSimplePrimMeshing) + if (!forceSimplePrimMeshing && !pbs.SculptEntry) { if ((pbs.ProfileShape == ProfileShape.Square && pbs.PathCurve == (byte)Extrusion.Straight) || (pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte)Extrusion.Curve1 @@ -2592,6 +2592,9 @@ namespace OpenSim.Region.Physics.OdePlugin } } + if (pbs.SculptEntry && meshSculptedPrim) + iPropertiesNotSupportedDefault++; + if (iPropertiesNotSupportedDefault == 0) {