From 5efce21abc92fa1005fa8651a5622fe72cf83ff3 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 22 May 2013 21:57:07 -0700 Subject: [PATCH 1/8] BulletSim: correct errors caused by misspelled INI parameter spec. Add debugging messages for hull asset use. --- OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | 2 +- OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs index 5cff66828c..c19eda1242 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs @@ -373,7 +373,7 @@ public static class BSParam true ), new ParameterDefn("ShouldUseGImpactShapeForPrims", "If true, use a GImpact shape for prims with cuts and twists", false ), - new ParameterDefn("UseAssetHulls", "If true, use hull if specified in the mesh asset info", + new ParameterDefn("ShouldUseAssetHulls", "If true, use hull if specified in the mesh asset info", false ), new ParameterDefn("CrossingFailuresBeforeOutOfBounds", "How forgiving we are about getting into adjactent regions", diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs index b7f7e6c9e2..6729d6bf71 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs @@ -619,6 +619,9 @@ public class BSShapeHull : BSShape // create the hull data structure in Bullet newShape = physicsScene.PE.CreateHullShape(physicsScene.World, hullCount, convHulls); + + physicsScene.DetailLog("{0},BSShapeHull.CreatePhysicalHull,assetHulls,hulls={1},totVert={2},shape={3}", + prim.LocalID, hullCount, totalVertices, newShape); } } } @@ -627,7 +630,7 @@ public class BSShapeHull : BSShape { // Build the hull shape from an existing mesh shape. // The mesh should have already been created in Bullet. - physicsScene.DetailLog("{0},BSShapeHull.CreatePhysicalHull,shouldUseBulletHACD,entry", prim.LocalID); + physicsScene.DetailLog("{0},BSShapeHull.CreatePhysicalHull,bulletHACD,entry", prim.LocalID); BSShape meshShape = BSShapeMesh.GetReference(physicsScene, true, prim); if (meshShape.physShapeInfo.HasPhysicalShape) @@ -645,12 +648,12 @@ public class BSShapeHull : BSShape physicsScene.DetailLog("{0},BSShapeHull.CreatePhysicalHull,hullFromMesh,beforeCall", prim.LocalID, newShape.HasPhysicalShape); newShape = physicsScene.PE.BuildHullShapeFromMesh(physicsScene.World, meshShape.physShapeInfo, parms); - physicsScene.DetailLog("{0},BSShapeHull.CreatePhysicalHull,hullFromMesh,hasBody={1}", prim.LocalID, newShape.HasPhysicalShape); + physicsScene.DetailLog("{0},BSShapeHull.CreatePhysicalHull,hullFromMesh,shape={1}", prim.LocalID, newShape); // Now done with the mesh shape. meshShape.Dereference(physicsScene); } - physicsScene.DetailLog("{0},BSShapeHull.CreatePhysicalHull,shouldUseBulletHACD,exit,hasBody={1}", prim.LocalID, newShape.HasPhysicalShape); + physicsScene.DetailLog("{0},BSShapeHull.CreatePhysicalHull,bulletHACD,exit,hasBody={1}", prim.LocalID, newShape.HasPhysicalShape); } // If no hull specified, use our HACD hull approximation. if (!newShape.HasPhysicalShape) From 29b3b44fab46a44f911e582ab284025086cf3692 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 23 May 2013 14:40:16 -0700 Subject: [PATCH 2/8] BulletSim: add locking around Meshmerizer use to eliminate possible race condition when extracting the convex hulls. --- .../Region/Physics/BulletSPlugin/BSShapes.cs | 328 +++++++++--------- 1 file changed, 170 insertions(+), 158 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs index 6729d6bf71..48f1394c5d 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs @@ -441,10 +441,14 @@ public class BSShapeMesh : BSShape { BulletShape newShape = new BulletShape(); - IMesh meshData = physicsScene.mesher.CreateMesh(prim.PhysObjectName, pbs, size, lod, - false, // say it is not physical so a bounding box is not built - false // do not cache the mesh and do not use previously built versions - ); + IMesh meshData = null; + lock (physicsScene.mesher) + { + meshData = physicsScene.mesher.CreateMesh(prim.PhysObjectName, pbs, size, lod, + false, // say it is not physical so a bounding box is not built + false // do not cache the mesh and do not use previously built versions + ); + } if (meshData != null) { @@ -576,55 +580,67 @@ public class BSShapeHull : BSShape BulletShape newShape = new BulletShape(); newShape.shapeKey = newHullKey; - // Pass true for physicalness as this prevents the creation of bounding box which is not needed - IMesh meshData = physicsScene.mesher.CreateMesh(prim.PhysObjectName, pbs, size, lod, true /* isPhysical */, false /* shouldCache */); - - // If there is hull data in the mesh asset, build the hull from that - if (meshData != null && BSParam.ShouldUseAssetHulls) + IMesh meshData = null; + List> allHulls = null; + lock (physicsScene.mesher) { - Meshmerizer realMesher = physicsScene.mesher as Meshmerizer; - if (realMesher != null) + // Pass true for physicalness as this prevents the creation of bounding box which is not needed + meshData = physicsScene.mesher.CreateMesh(prim.PhysObjectName, pbs, size, lod, true /* isPhysical */, false /* shouldCache */); + + // If we should use the asset's hull info, fetch it out of the locked mesher + if (meshData != null && BSParam.ShouldUseAssetHulls) { - List> allHulls = realMesher.GetConvexHulls(size); - if (allHulls != null) + Meshmerizer realMesher = physicsScene.mesher as Meshmerizer; + if (realMesher != null) { - int hullCount = allHulls.Count; - int totalVertices = 1; // include one for the count of the hulls - // Using the structure described for HACD hulls, create the memory sturcture - // to pass the hull data to the creater. - foreach (List hullVerts in allHulls) - { - totalVertices += 4; // add four for the vertex count and centroid - totalVertices += hullVerts.Count * 3; // one vertex is three dimensions - } - float[] convHulls = new float[totalVertices]; - - convHulls[0] = (float)hullCount; - int jj = 1; - foreach (List hullVerts in allHulls) - { - convHulls[jj + 0] = hullVerts.Count; - convHulls[jj + 1] = 0f; // centroid x,y,z - convHulls[jj + 2] = 0f; - convHulls[jj + 3] = 0f; - jj += 4; - foreach (OMV.Vector3 oneVert in hullVerts) - { - convHulls[jj + 0] = oneVert.X; - convHulls[jj + 1] = oneVert.Y; - convHulls[jj + 2] = oneVert.Z; - jj += 3; - } - } - - // create the hull data structure in Bullet - newShape = physicsScene.PE.CreateHullShape(physicsScene.World, hullCount, convHulls); - - physicsScene.DetailLog("{0},BSShapeHull.CreatePhysicalHull,assetHulls,hulls={1},totVert={2},shape={3}", - prim.LocalID, hullCount, totalVertices, newShape); + allHulls = realMesher.GetConvexHulls(size); + } + if (allHulls == null) + { + physicsScene.DetailLog("{0},BSShapeHull.CreatePhysicalHull,assetHulls,noAssetHull", prim.LocalID); } } } + + // If there is hull data in the mesh asset, build the hull from that + if (allHulls != null && BSParam.ShouldUseAssetHulls) + { + int hullCount = allHulls.Count; + int totalVertices = 1; // include one for the count of the hulls + // Using the structure described for HACD hulls, create the memory sturcture + // to pass the hull data to the creater. + foreach (List hullVerts in allHulls) + { + totalVertices += 4; // add four for the vertex count and centroid + totalVertices += hullVerts.Count * 3; // one vertex is three dimensions + } + float[] convHulls = new float[totalVertices]; + + convHulls[0] = (float)hullCount; + int jj = 1; + foreach (List hullVerts in allHulls) + { + convHulls[jj + 0] = hullVerts.Count; + convHulls[jj + 1] = 0f; // centroid x,y,z + convHulls[jj + 2] = 0f; + convHulls[jj + 3] = 0f; + jj += 4; + foreach (OMV.Vector3 oneVert in hullVerts) + { + convHulls[jj + 0] = oneVert.X; + convHulls[jj + 1] = oneVert.Y; + convHulls[jj + 2] = oneVert.Z; + jj += 3; + } + } + + // create the hull data structure in Bullet + newShape = physicsScene.PE.CreateHullShape(physicsScene.World, hullCount, convHulls); + + physicsScene.DetailLog("{0},BSShapeHull.CreatePhysicalHull,assetHulls,hulls={1},totVert={2},shape={3}", + prim.LocalID, hullCount, totalVertices, newShape); + } + // If no hull specified in the asset and we should use Bullet's HACD approximation... if (!newShape.HasPhysicalShape && BSParam.ShouldUseBulletHACD) { @@ -655,120 +671,116 @@ public class BSShapeHull : BSShape } physicsScene.DetailLog("{0},BSShapeHull.CreatePhysicalHull,bulletHACD,exit,hasBody={1}", prim.LocalID, newShape.HasPhysicalShape); } - // If no hull specified, use our HACD hull approximation. - if (!newShape.HasPhysicalShape) + + // If no other hull specifications, use our HACD hull approximation. + if (!newShape.HasPhysicalShape && meshData != null) { - // Build a new hull in the physical world using the C# HACD algorigthm. - if (meshData != null) + if (prim.PrimAssetState == BSPhysObject.PrimAssetCondition.Fetched) { - if (prim.PrimAssetState == BSPhysObject.PrimAssetCondition.Fetched) - { - // Release the fetched asset data once it has been used. - pbs.SculptData = new byte[0]; - prim.PrimAssetState = BSPhysObject.PrimAssetCondition.Unknown; - } - - int[] indices = meshData.getIndexListAsInt(); - List vertices = meshData.getVertexList(); - - //format conversion from IMesh format to DecompDesc format - List convIndices = new List(); - List convVertices = new List(); - for (int ii = 0; ii < indices.GetLength(0); ii++) - { - convIndices.Add(indices[ii]); - } - foreach (OMV.Vector3 vv in vertices) - { - convVertices.Add(new float3(vv.X, vv.Y, vv.Z)); - } - - uint maxDepthSplit = (uint)BSParam.CSHullMaxDepthSplit; - if (BSParam.CSHullMaxDepthSplit != BSParam.CSHullMaxDepthSplitForSimpleShapes) - { - // Simple primitive shapes we know are convex so they are better implemented with - // fewer hulls. - // Check for simple shape (prim without cuts) and reduce split parameter if so. - if (BSShapeCollection.PrimHasNoCuts(pbs)) - { - maxDepthSplit = (uint)BSParam.CSHullMaxDepthSplitForSimpleShapes; - } - } - - // setup and do convex hull conversion - m_hulls = new List(); - DecompDesc dcomp = new DecompDesc(); - dcomp.mIndices = convIndices; - dcomp.mVertices = convVertices; - dcomp.mDepth = maxDepthSplit; - dcomp.mCpercent = BSParam.CSHullConcavityThresholdPercent; - dcomp.mPpercent = BSParam.CSHullVolumeConservationThresholdPercent; - dcomp.mMaxVertices = (uint)BSParam.CSHullMaxVertices; - dcomp.mSkinWidth = BSParam.CSHullMaxSkinWidth; - ConvexBuilder convexBuilder = new ConvexBuilder(HullReturn); - // create the hull into the _hulls variable - convexBuilder.process(dcomp); - - physicsScene.DetailLog("{0},BSShapeCollection.CreatePhysicalHull,key={1},inVert={2},inInd={3},split={4},hulls={5}", - BSScene.DetailLogZero, newHullKey, indices.GetLength(0), vertices.Count, maxDepthSplit, m_hulls.Count); - - // Convert the vertices and indices for passing to unmanaged. - // The hull information is passed as a large floating point array. - // The format is: - // convHulls[0] = number of hulls - // convHulls[1] = number of vertices in first hull - // convHulls[2] = hull centroid X coordinate - // convHulls[3] = hull centroid Y coordinate - // convHulls[4] = hull centroid Z coordinate - // convHulls[5] = first hull vertex X - // convHulls[6] = first hull vertex Y - // convHulls[7] = first hull vertex Z - // convHulls[8] = second hull vertex X - // ... - // convHulls[n] = number of vertices in second hull - // convHulls[n+1] = second hull centroid X coordinate - // ... - // - // TODO: is is very inefficient. Someday change the convex hull generator to return - // data structures that do not need to be converted in order to pass to Bullet. - // And maybe put the values directly into pinned memory rather than marshaling. - int hullCount = m_hulls.Count; - int totalVertices = 1; // include one for the count of the hulls - foreach (ConvexResult cr in m_hulls) - { - totalVertices += 4; // add four for the vertex count and centroid - totalVertices += cr.HullIndices.Count * 3; // we pass just triangles - } - float[] convHulls = new float[totalVertices]; - - convHulls[0] = (float)hullCount; - int jj = 1; - foreach (ConvexResult cr in m_hulls) - { - // copy vertices for index access - float3[] verts = new float3[cr.HullVertices.Count]; - int kk = 0; - foreach (float3 ff in cr.HullVertices) - { - verts[kk++] = ff; - } - - // add to the array one hull's worth of data - convHulls[jj++] = cr.HullIndices.Count; - convHulls[jj++] = 0f; // centroid x,y,z - convHulls[jj++] = 0f; - convHulls[jj++] = 0f; - foreach (int ind in cr.HullIndices) - { - convHulls[jj++] = verts[ind].x; - convHulls[jj++] = verts[ind].y; - convHulls[jj++] = verts[ind].z; - } - } - // create the hull data structure in Bullet - newShape = physicsScene.PE.CreateHullShape(physicsScene.World, hullCount, convHulls); + // Release the fetched asset data once it has been used. + pbs.SculptData = new byte[0]; + prim.PrimAssetState = BSPhysObject.PrimAssetCondition.Unknown; } - newShape.shapeKey = newHullKey; + + int[] indices = meshData.getIndexListAsInt(); + List vertices = meshData.getVertexList(); + + //format conversion from IMesh format to DecompDesc format + List convIndices = new List(); + List convVertices = new List(); + for (int ii = 0; ii < indices.GetLength(0); ii++) + { + convIndices.Add(indices[ii]); + } + foreach (OMV.Vector3 vv in vertices) + { + convVertices.Add(new float3(vv.X, vv.Y, vv.Z)); + } + + uint maxDepthSplit = (uint)BSParam.CSHullMaxDepthSplit; + if (BSParam.CSHullMaxDepthSplit != BSParam.CSHullMaxDepthSplitForSimpleShapes) + { + // Simple primitive shapes we know are convex so they are better implemented with + // fewer hulls. + // Check for simple shape (prim without cuts) and reduce split parameter if so. + if (BSShapeCollection.PrimHasNoCuts(pbs)) + { + maxDepthSplit = (uint)BSParam.CSHullMaxDepthSplitForSimpleShapes; + } + } + + // setup and do convex hull conversion + m_hulls = new List(); + DecompDesc dcomp = new DecompDesc(); + dcomp.mIndices = convIndices; + dcomp.mVertices = convVertices; + dcomp.mDepth = maxDepthSplit; + dcomp.mCpercent = BSParam.CSHullConcavityThresholdPercent; + dcomp.mPpercent = BSParam.CSHullVolumeConservationThresholdPercent; + dcomp.mMaxVertices = (uint)BSParam.CSHullMaxVertices; + dcomp.mSkinWidth = BSParam.CSHullMaxSkinWidth; + ConvexBuilder convexBuilder = new ConvexBuilder(HullReturn); + // create the hull into the _hulls variable + convexBuilder.process(dcomp); + + physicsScene.DetailLog("{0},BSShapeCollection.CreatePhysicalHull,key={1},inVert={2},inInd={3},split={4},hulls={5}", + BSScene.DetailLogZero, newHullKey, indices.GetLength(0), vertices.Count, maxDepthSplit, m_hulls.Count); + + // Convert the vertices and indices for passing to unmanaged. + // The hull information is passed as a large floating point array. + // The format is: + // convHulls[0] = number of hulls + // convHulls[1] = number of vertices in first hull + // convHulls[2] = hull centroid X coordinate + // convHulls[3] = hull centroid Y coordinate + // convHulls[4] = hull centroid Z coordinate + // convHulls[5] = first hull vertex X + // convHulls[6] = first hull vertex Y + // convHulls[7] = first hull vertex Z + // convHulls[8] = second hull vertex X + // ... + // convHulls[n] = number of vertices in second hull + // convHulls[n+1] = second hull centroid X coordinate + // ... + // + // TODO: is is very inefficient. Someday change the convex hull generator to return + // data structures that do not need to be converted in order to pass to Bullet. + // And maybe put the values directly into pinned memory rather than marshaling. + int hullCount = m_hulls.Count; + int totalVertices = 1; // include one for the count of the hulls + foreach (ConvexResult cr in m_hulls) + { + totalVertices += 4; // add four for the vertex count and centroid + totalVertices += cr.HullIndices.Count * 3; // we pass just triangles + } + float[] convHulls = new float[totalVertices]; + + convHulls[0] = (float)hullCount; + int jj = 1; + foreach (ConvexResult cr in m_hulls) + { + // copy vertices for index access + float3[] verts = new float3[cr.HullVertices.Count]; + int kk = 0; + foreach (float3 ff in cr.HullVertices) + { + verts[kk++] = ff; + } + + // add to the array one hull's worth of data + convHulls[jj++] = cr.HullIndices.Count; + convHulls[jj++] = 0f; // centroid x,y,z + convHulls[jj++] = 0f; + convHulls[jj++] = 0f; + foreach (int ind in cr.HullIndices) + { + convHulls[jj++] = verts[ind].x; + convHulls[jj++] = verts[ind].y; + convHulls[jj++] = verts[ind].z; + } + } + // create the hull data structure in Bullet + newShape = physicsScene.PE.CreateHullShape(physicsScene.World, hullCount, convHulls); } return newShape; } From 0e002e369339719204f26c07157713bfc40fecca Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 23 May 2013 14:41:05 -0700 Subject: [PATCH 3/8] Add DEBUG level logging in Meshmerizer for mesh parsing. There is a compile time variable to turn this logging off if it is too spammy. --- OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index 79edc12dde..adc0dc9dd1 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -64,6 +64,7 @@ namespace OpenSim.Region.Physics.Meshing public class Meshmerizer : IMesher { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static string LogHeader = "[MESH]"; // Setting baseDir to a path will enable the dumping of raw files // raw files can be imported by blender so a visual inspection of the results can be done @@ -72,6 +73,8 @@ namespace OpenSim.Region.Physics.Meshing #else private const string baseDir = null; //"rawFiles"; #endif + // If 'true', lots of DEBUG logging of asset parsing details + private bool debugDetail = true; private bool cacheSculptMaps = true; private string decodedSculptMapPath = null; @@ -357,13 +360,25 @@ namespace OpenSim.Region.Physics.Meshing OSDMap physicsParms = null; OSDMap map = (OSDMap)meshOsd; if (map.ContainsKey("physics_shape")) + { physicsParms = (OSDMap)map["physics_shape"]; // old asset format + if (debugDetail) m_log.DebugFormat("{0} prim='{1}': using 'physics_shape' mesh data", LogHeader, primName); + } else if (map.ContainsKey("physics_mesh")) + { physicsParms = (OSDMap)map["physics_mesh"]; // new asset format + if (debugDetail) m_log.DebugFormat("{0} prim='{1}':using 'physics_mesh' mesh data", LogHeader, primName); + } else if (map.ContainsKey("medium_lod")) + { physicsParms = (OSDMap)map["medium_lod"]; // if no physics mesh, try to fall back to medium LOD display mesh + if (debugDetail) m_log.DebugFormat("{0} prim='{1}':using 'medium_lod' mesh data", LogHeader, primName); + } else if (map.ContainsKey("high_lod")) + { physicsParms = (OSDMap)map["high_lod"]; // if all else fails, use highest LOD display mesh and hope it works :) + if (debugDetail) m_log.DebugFormat("{0} prim='{1}':using 'high_lod' mesh data", LogHeader, primName); + } if (map.ContainsKey("physics_convex")) { // pull this out also in case physics engine can use it @@ -408,11 +423,16 @@ namespace OpenSim.Region.Physics.Meshing } mConvexHulls = hulls; + if (debugDetail) m_log.DebugFormat("{0} prim='{1}': parsed hulls. nHulls={2}", LogHeader, primName, mConvexHulls.Count); + } + else + { + if (debugDetail) m_log.DebugFormat("{0} prim='{1}' has physics_convex but no HullList", LogHeader, primName); } } catch (Exception e) { - m_log.WarnFormat("[MESH]: exception decoding convex block: {0}", e.Message); + m_log.WarnFormat("{0} exception decoding convex block: {1}", LogHeader, e); } } @@ -438,7 +458,7 @@ namespace OpenSim.Region.Physics.Meshing } catch (Exception e) { - m_log.Error("[MESH]: exception decoding physical mesh: " + e.ToString()); + m_log.ErrorFormat("{0} prim='{1}': exception decoding physical mesh: {2}", LogHeader, primName, e); return false; } @@ -455,6 +475,9 @@ namespace OpenSim.Region.Physics.Meshing if (subMeshOsd is OSDMap) AddSubMesh(subMeshOsd as OSDMap, size, coords, faces); } + if (debugDetail) + m_log.DebugFormat("{0} {1}: mesh decoded. offset={2}, size={3}, nCoords={4}, nFaces={5}", + LogHeader, primName, physOffset, physSize, coords.Count, faces.Count); } } From 28548ab347487b1ed4e6cf50af30a6eacf963f7d Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 23 May 2013 23:05:56 +0100 Subject: [PATCH 4/8] Fix bug where both ordinary UserManagementModule and HGUserManagementModules were being added to scenes if no UserManagementModule was specified. Without explicit config non-hg UMM is used - this is in common with other HG modules. This was causing a non-HG module to unpredictably use the UMM or HGUMM, though lack of bug reports suggest either UMM was always used or it didn't matter in this case. --- .../Framework/UserManagement/HGUserManagementModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs index fac93e63bb..ad3cf15ff3 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs @@ -54,7 +54,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement public new void Initialise(IConfigSource config) { - string umanmod = config.Configs["Modules"].GetString("UserManagementModule", Name); + string umanmod = config.Configs["Modules"].GetString("UserManagementModule", null); if (umanmod == Name) { m_Enabled = true; From c5549d27306c71cd5ed96e7cba68bd28d5e6d9b0 Mon Sep 17 00:00:00 2001 From: dahlia Date: Thu, 23 May 2013 15:47:47 -0700 Subject: [PATCH 5/8] add decoder for bounding convex hull --- OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 57 +++++++++++++++++-- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index adc0dc9dd1..fd45efe126 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -83,6 +83,7 @@ namespace OpenSim.Region.Physics.Meshing private float minSizeForComplexMesh = 0.2f; // prims with all dimensions smaller than this will have a bounding box mesh private List> mConvexHulls = null; + private List mBoundingHull = null; private Dictionary m_uniqueMeshes = new Dictionary(); @@ -324,6 +325,9 @@ namespace OpenSim.Region.Physics.Meshing faces = new List(); OSD meshOsd = null; + mConvexHulls = null; + mBoundingHull = null; + if (primShape.SculptData.Length <= 0) { // XXX: At the moment we can not log here since ODEPrim, for instance, ends up triggering this @@ -385,13 +389,41 @@ namespace OpenSim.Region.Physics.Meshing try { OSDMap convexBlock = (OSDMap)map["physics_convex"]; + + Vector3 min = new Vector3(-0.5f, -0.5f, -0.5f); + if (convexBlock.ContainsKey("Min")) min = convexBlock["Min"].AsVector3(); + Vector3 max = new Vector3(0.5f, 0.5f, 0.5f); + if (convexBlock.ContainsKey("Max")) max = convexBlock["Max"].AsVector3(); + + List boundingHull = null; + + if (convexBlock.ContainsKey("BoundingVerts")) + { + // decompress and decode bounding hull points + byte[] boundingVertsBytes = DecompressOsd(convexBlock["BoundingVerts"].AsBinary()).AsBinary(); + boundingHull = new List(); + for (int i = 0; i < boundingVertsBytes.Length;) + { + ushort uX = Utils.BytesToUInt16(boundingVertsBytes, i); i += 2; + ushort uY = Utils.BytesToUInt16(boundingVertsBytes, i); i += 2; + ushort uZ = Utils.BytesToUInt16(boundingVertsBytes, i); i += 2; + + Vector3 pos = new Vector3( + Utils.UInt16ToFloat(uX, min.X, max.X), + Utils.UInt16ToFloat(uY, min.Y, max.Y), + Utils.UInt16ToFloat(uZ, min.Z, max.Z) + ); + + boundingHull.Add(pos); + } + + mBoundingHull = boundingHull; + if (debugDetail) m_log.DebugFormat("{0} prim='{1}': parsed bounding hull. nHulls={2}", LogHeader, primName, mBoundingHull.Count); + } + if (convexBlock.ContainsKey("HullList")) { byte[] hullList = convexBlock["HullList"].AsBinary(); - Vector3 min = new Vector3(-0.5f, -0.5f, -0.5f); - if (convexBlock.ContainsKey("Min")) min = convexBlock["Min"].AsVector3(); - Vector3 max = new Vector3(0.5f, 0.5f, 0.5f); - if (convexBlock.ContainsKey("Max")) max = convexBlock["Max"].AsVector3(); // decompress and decode hull points byte[] posBytes = DecompressOsd(convexBlock["Positions"].AsBinary()).AsBinary(); @@ -795,6 +827,23 @@ namespace OpenSim.Region.Physics.Meshing return true; } + /// + /// temporary prototype code - please do not use until the interface has been finalized! + /// + /// value to scale the hull points by + /// a list of vertices in the bounding hull if it exists and has been successfully decoded, otherwise null + public List GetBoundingHull(Vector3 size) + { + if (mBoundingHull == null) + return null; + + List verts = new List(); + foreach (var vert in mBoundingHull) + verts.Add(vert * size); + + return verts; + } + /// /// temporary prototype code - please do not use until the interface has been finalized! /// From 9b56f993261954fe9918bd0c9205a41e058183a1 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Thu, 23 May 2013 23:52:07 +0100 Subject: [PATCH 6/8] Fix bug where a cloned object would report the wrong llGetNumberOfPrims() when avatars had been sitting on the original and a different avatar sat on the copy within the same opensim session. This was because the sitting avatars list was being cloned rather than reset. Addresses http://opensimulator.org/mantis/view.php?id=6649 --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 38fa26abae..2d4218da39 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1500,6 +1500,7 @@ namespace OpenSim.Region.Framework.Scenes dupe.IsAttachment = true; dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); + dupe.m_sittingAvatars = new List(); if (!userExposed) { From 02fe05f346f3c4acad0116e702ed197a52b3fb4d Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 24 May 2013 00:41:47 +0100 Subject: [PATCH 7/8] Fix issue where llSetPayPrice on either one of a clone prim in the same OpenSimulator session would change the prices on both prims. This is because the PayPrice array refernence was being memberwise cloned and not the array itself. Addresses http://opensimulator.org/mantis/view.php?id=6639 --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index b1c1cbb3ea..ea8c3c5c39 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1799,6 +1799,8 @@ namespace OpenSim.Region.Framework.Scenes Array.Copy(Shape.ExtraParams, extraP, extraP.Length); dupe.Shape.ExtraParams = extraP; + dupe.PayPrice = (int[])PayPrice.Clone(); + dupe.DynAttrs.CopyFrom(DynAttrs); if (userExposed) From eb2bd9d203dbc9d202ae62594fcbdb53d38031ac Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 24 May 2013 00:46:58 +0100 Subject: [PATCH 8/8] minor: Remove unnecessary duplication of AbsolutePosition Vector3 in SOG.Copy() As a struct, Vector3 has already been cloned by MemberwiseClone() --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 2d4218da39..df23cc5170 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1499,7 +1499,6 @@ namespace OpenSim.Region.Framework.Scenes if (!userExposed) dupe.IsAttachment = true; - dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); dupe.m_sittingAvatars = new List(); if (!userExposed)