aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs35
1 files changed, 30 insertions, 5 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
index a4250be..809435d 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
@@ -227,16 +227,41 @@ public sealed class BSShapeCollection : IDisposable
227 if (prim.IsPhysical && BSParam.ShouldUseHullsForPhysicalObjects) 227 if (prim.IsPhysical && BSParam.ShouldUseHullsForPhysicalObjects)
228 { 228 {
229 // Update prim.BSShape to reference a hull of this shape. 229 // Update prim.BSShape to reference a hull of this shape.
230 DereferenceExistingShape(prim, shapeCallback); 230 BSShape potentialHull = BSShapeHull.GetReference(m_physicsScene, false /*forceRebuild*/, prim);
231 prim.PhysShape = BSShapeMesh.GetReference(m_physicsScene, false /*forceRebuild*/, prim); 231 // If the current shape is not what is on the prim at the moment, time to change.
232 if (!prim.PhysShape.HasPhysicalShape
233 || potentialHull.ShapeType != prim.PhysShape.ShapeType
234 || potentialHull.physShapeInfo.shapeKey != prim.PhysShape.physShapeInfo.shapeKey)
235 {
236 DereferenceExistingShape(prim, shapeCallback);
237 prim.PhysShape = potentialHull;
238 ret = true;
239 }
240 else
241 {
242 potentialHull.Dereference(m_physicsScene);
243 }
232 if (DDetail) DetailLog("{0},BSShapeCollection.CreateGeom,hull,shape={1},key={2}", 244 if (DDetail) DetailLog("{0},BSShapeCollection.CreateGeom,hull,shape={1},key={2}",
233 prim.LocalID, prim.PhysShape, prim.PhysShape.physShapeInfo.shapeKey.ToString("X")); 245 prim.LocalID, prim.PhysShape, prim.PhysShape.physShapeInfo.shapeKey.ToString("X"));
234 } 246 }
235 else 247 else
236 { 248 {
237 // Update prim.BSShape to reference a mesh of this shape. 249 // Update prim.BSShape to reference a mesh of this shape.
238 DereferenceExistingShape(prim, shapeCallback); 250 BSShape potentialMesh = BSShapeMesh.GetReference(m_physicsScene, false /*forceRebuild*/, prim);
239 prim.PhysShape = BSShapeHull.GetReference(m_physicsScene, false /*forceRebuild*/, prim); 251 // If the current shape is not what is on the prim at the moment, time to change.
252 if (!prim.PhysShape.HasPhysicalShape
253 || potentialMesh.ShapeType != prim.PhysShape.ShapeType
254 || potentialMesh.physShapeInfo.shapeKey != prim.PhysShape.physShapeInfo.shapeKey)
255 {
256 DereferenceExistingShape(prim, shapeCallback);
257 prim.PhysShape = potentialMesh;
258 ret = true;
259 }
260 else
261 {
262 // We don't need this reference to the mesh that is already being using.
263 potentialMesh.Dereference(m_physicsScene);
264 }
240 if (DDetail) DetailLog("{0},BSShapeCollection.CreateGeom,mesh,shape={1},key={2}", 265 if (DDetail) DetailLog("{0},BSShapeCollection.CreateGeom,mesh,shape={1},key={2}",
241 prim.LocalID, prim.PhysShape, prim.PhysShape.physShapeInfo.shapeKey.ToString("X")); 266 prim.LocalID, prim.PhysShape, prim.PhysShape.physShapeInfo.shapeKey.ToString("X"));
242 } 267 }
@@ -320,7 +345,7 @@ public sealed class BSShapeCollection : IDisposable
320 if (prim.IsSolid) 345 if (prim.IsSolid)
321 { 346 {
322 aBody = m_physicsScene.PE.CreateBodyFromShape(sim, prim.PhysShape.physShapeInfo, prim.LocalID, prim.RawPosition, prim.RawOrientation); 347 aBody = m_physicsScene.PE.CreateBodyFromShape(sim, prim.PhysShape.physShapeInfo, prim.LocalID, prim.RawPosition, prim.RawOrientation);
323 if (DDetail) DetailLog("{0},BSShapeCollection.CreateBody,mesh,body={1}", prim.LocalID, aBody); 348 if (DDetail) DetailLog("{0},BSShapeCollection.CreateBody,rigid,body={1}", prim.LocalID, aBody);
324 } 349 }
325 else 350 else
326 { 351 {