// Loop through all the known meshes and return the description based on the physical address.
 public static bool TryGetMeshByPtr(BulletShape pShape, out BSShapeMesh outMesh)
 {
     bool ret = false;
     BSShapeMesh foundDesc = null;
     lock (Meshes)
     {
         foreach (BSShapeMesh sm in Meshes.Values)
         {
             if (sm.physShapeInfo.ReferenceSame(pShape))
             {
                 foundDesc = sm;
                 ret = true;
                 break;
             }
         }
     }
     outMesh = foundDesc;
     return ret;
 }
        public static BSShape GetReference(BSScene physicsScene, bool forceRebuild, BSPhysObject prim)
        {
            float lod;
            UInt64 newMeshKey = BSShape.ComputeShapeKey(prim.Size, prim.BaseShape, out lod);

            BSShapeMesh retMesh;
            lock (Meshes)
            {
                if (Meshes.TryGetValue(newMeshKey, out retMesh))
                {
                    // The mesh has already been created. Return a new reference to same.
                    retMesh.IncrementReference();
                }
                else
                {
                    retMesh = new BSShapeMesh(new BulletShape());
                    // An instance of this mesh has not been created. Build and remember same.
                    BulletShape newShape = retMesh.CreatePhysicalMesh(physicsScene, prim, newMeshKey, prim.BaseShape,
                        prim.Size, lod);

                    // Check to see if mesh was created (might require an asset).
                    newShape = VerifyMeshCreated(physicsScene, newShape, prim);
                    if (!newShape.isNativeShape || prim.AssetFailed())
                    {
                        // If a mesh was what was created, remember the built shape for later sharing.
                        // Also note that if meshing failed we put it in the mesh list as there is nothing else to do about the mesh.
                        Meshes.Add(newMeshKey, retMesh);
                    }
                    retMesh.physShapeInfo = newShape;
                }
            }
            physicsScene.DetailLog("{0},BSShapeMesh,getReference,mesh={1},size={2},lod={3}", prim.LocalID, retMesh,
                prim.Size, lod);
            return retMesh;
        }