Fix interpretation of physics mesh proxies from mesh data

As per http://wiki.secondlife.com/wiki/Mesh/Mesh_Asset_Format, some submesh blocks may just have the flag "NoGeometry" to signal that they provide no mesh data.
If a block contains this, ignore it for meshing purposes rather than suffer a ClassCastException
This fixes physics proxy meshing, so you can now walk through mesh doorways, properly stand on the trailer of mesh trucks, etc.
To get mesh physics proxy, the UseMeshiesPhysicsMesh must be true in a [Mesh] config section in OpenSim.ini (example in OpenSimDefaults.ini).
Convex hull physics not currently supported.
bulletsim
Justin Clark-Casey (justincc) 2011-07-08 19:43:22 +01:00
parent 29034bc0e0
commit b18ef976ff
2 changed files with 28 additions and 3 deletions

View File

@ -324,10 +324,25 @@ namespace OpenSim.Framework
}
/// <summary>
/// Debug utility function to convert unbroken strings of XML into something human readable for occasional debugging purposes.
///
/// Please don't delete me even if I appear currently unused!
/// Debug utility function to convert OSD into formatted XML for debugging purposes.
/// </summary>
/// <param name="osd">
/// A <see cref="OSD"/>
/// </param>
/// <returns>
/// A <see cref="System.String"/>
/// </returns>
public static string GetFormattedXml(OSD osd)
{
return GetFormattedXml(OSDParser.SerializeLLSDXmlString(osd));
}
/// <summary>
/// Debug utility function to convert unbroken strings of XML into something human readable for occasional debugging purposes.
/// </summary>
/// <remarks>
/// Please don't delete me even if I appear currently unused!
/// </remarks>
/// <param name="rawXml"></param>
/// <returns></returns>
public static string GetFormattedXml(string rawXml)

View File

@ -366,6 +366,8 @@ 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));
decodedMeshOsdArray = (OSDArray)decodedMeshOsd;
foreach (OSD subMeshOsd in decodedMeshOsdArray)
{
@ -373,6 +375,14 @@ namespace OpenSim.Region.Physics.Meshing
{
OSDMap subMeshMap = (OSDMap)subMeshOsd;
// Console.WriteLine("subMeshMap for {0} - {1}", primName, Util.GetFormattedXml((OSD)subMeshMap));
// As per http://wiki.secondlife.com/wiki/Mesh/Mesh_Asset_Format, some Mesh Level
// of Detail Blocks (maps) contain just a NoGeometry key to signal there is no
// geometry for this submesh.
if (subMeshMap.ContainsKey("NoGeometry") && ((OSDBoolean)subMeshMap["NoGeometry"]))
continue;
OpenMetaverse.Vector3 posMax = ((OSDMap)subMeshMap["PositionDomain"])["Max"].AsVector3();
OpenMetaverse.Vector3 posMin = ((OSDMap)subMeshMap["PositionDomain"])["Min"].AsVector3();
ushort faceIndexOffset = (ushort)coords.Count;