From d8a786870b5ff03241e9f6b0393a2e1f91de2b01 Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Tue, 2 Oct 2012 10:56:39 -0700
Subject: BulletSim: Fix problem where box shapes were not being rebuilt if the
 shape type changed.

---
 OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
index a86bf8a..399a133 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
@@ -108,7 +108,8 @@ public class BSShapeCollection : IDisposable
             // If we had to select a new shape geometry for the object,
             //    rebuild the body around it.
             // Updates prim.BSBody with information/pointers to requested body
-            bool newBody = CreateBody((newGeom || forceRebuild), prim, PhysicsScene.World, prim.BSShape, shapeData, bodyCallback);
+            bool newBody = CreateBody((newGeom || forceRebuild), prim, PhysicsScene.World, 
+                                    prim.BSShape, shapeData, bodyCallback);
             ret = newGeom || newBody;
         }
         DetailLog("{0},BSShapeCollection.GetBodyAndShape,force={1},ret={2},body={3},shape={4}",
@@ -140,7 +141,7 @@ public class BSShapeCollection : IDisposable
             bodyDesc.lastReferenced = System.DateTime.Now;
             Bodies[body.ID] = bodyDesc;
         }
-}
+    }
 
     // Release the usage of a body.
     // Called when releasing use of a BSBody. BSShape is handled separately.
@@ -167,7 +168,7 @@ public class BSShapeCollection : IDisposable
                     {
                         DetailLog("{0},BSShapeCollection.DereferenceBody,DestroyingBody. ptr={1}",
                                                     body.ID, body.ptr.ToString("X"));
-                        // If the caller needs to know, pass the event up.
+                        // If the caller needs to know the old body is going away, pass the event up.
                         if (bodyCallback != null) bodyCallback(body);
 
                         // Zero any reference to the shape so it is not freed when the body is deleted.
@@ -448,7 +449,8 @@ public class BSShapeCollection : IDisposable
         ulong newMeshKey = ComputeShapeKey(shapeData, pbs, out lod);
 
         // if this new shape is the same as last time, don't recreate the mesh
-        if (prim.BSShape.shapeKey == newMeshKey) return false;
+        if (newMeshKey == prim.BSShape.shapeKey && prim.BSShape.type == ShapeData.PhysicsShapeType.SHAPE_MESH)
+            return false;
 
         DetailLog("{0},BSShapeCollection.CreateGeomMesh,create,oldKey={1},newKey={2}",
                                 prim.LocalID, prim.BSShape.shapeKey.ToString("X"), newMeshKey.ToString("X"));
-- 
cgit v1.1