aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorRobert Adams2012-08-14 16:41:36 -0700
committerRobert Adams2012-08-15 12:08:09 -0700
commitb05a2fc4edb632f80b16034feb4c680dbda9c006 (patch)
treeaf5e13273560492045255bdc52934bdacc9fd5a6
parentBulletSim: fix problem of a null reference exception on shutdown if there wer... (diff)
downloadopensim-SC_OLD-b05a2fc4edb632f80b16034feb4c680dbda9c006.zip
opensim-SC_OLD-b05a2fc4edb632f80b16034feb4c680dbda9c006.tar.gz
opensim-SC_OLD-b05a2fc4edb632f80b16034feb4c680dbda9c006.tar.bz2
opensim-SC_OLD-b05a2fc4edb632f80b16034feb4c680dbda9c006.tar.xz
BulletSim: don't recreate mesh unless it needs it when rebuilding the hull. Make sure the collisionCollection is reallocated each tick to fix race condition of it being cleared while still in use.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs30
1 files changed, 15 insertions, 15 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 05cc822..38a9e46 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -497,6 +497,9 @@ public sealed class BSPrim : PhysicsActor
497 497
498 BulletSimAPI.SetObjectProperties(_scene.WorldID, LocalID, IsStatic, IsSolid, SubscribedEvents(), mass); 498 BulletSimAPI.SetObjectProperties(_scene.WorldID, LocalID, IsStatic, IsSolid, SubscribedEvents(), mass);
499 499
500 // recompute any linkset parameters
501 _linkset.Refresh(this);
502
500 CollisionFlags cf = BulletSimAPI.GetCollisionFlags2(Body.Ptr); 503 CollisionFlags cf = BulletSimAPI.GetCollisionFlags2(Body.Ptr);
501 DetailLog("{0},BSPrim.SetObjectDynamic,taint,static={1},solid={2},mass={3}, cf={4}", LocalID, IsStatic, IsSolid, mass, cf); 504 DetailLog("{0},BSPrim.SetObjectDynamic,taint,static={1},solid={2},mass={3}, cf={4}", LocalID, IsStatic, IsSolid, mass, cf);
502 } 505 }
@@ -1095,28 +1098,21 @@ public sealed class BSPrim : PhysicsActor
1095 // if the hull hasn't changed, don't rebuild it 1098 // if the hull hasn't changed, don't rebuild it
1096 if (newHullKey == _hullKey) return; 1099 if (newHullKey == _hullKey) return;
1097 1100
1098 DetailLog("{0},BSPrim.CreateGeomHull,create,key={1}", LocalID, _meshKey); 1101 DetailLog("{0},BSPrim.CreateGeomHull,create,oldKey={1},newKey={2}", LocalID, _hullKey, newHullKey);
1099 1102
1100 // Since we're recreating new, get rid of any previously generated shape 1103 // Since we're recreating new, get rid of any previously generated shape
1101 if (_hullKey != 0) 1104 if (_hullKey != 0)
1102 { 1105 {
1103 // m_log.DebugFormat("{0}: CreateGeom: deleting old hull. Key={1}", LogHeader, _hullKey); 1106 // m_log.DebugFormat("{0}: CreateGeom: deleting old hull. Key={1}", LogHeader, _hullKey);
1104 DetailLog("{0},BSPrim.CreateGeomHull,deleteOldHull,key={1}", LocalID, _meshKey); 1107 DetailLog("{0},BSPrim.CreateGeomHull,deleteOldHull,key={1}", LocalID, _hullKey);
1105 BulletSimAPI.DestroyHull(_scene.WorldID, _hullKey); 1108 BulletSimAPI.DestroyHull(_scene.WorldID, _hullKey);
1106 _hullKey = 0; 1109 _hullKey = 0;
1107 _hulls.Clear();
1108 DetailLog("{0},BSPrim.CreateGeomHull,deleteOldMesh,key={1}", LocalID, _meshKey);
1109 BulletSimAPI.DestroyMesh(_scene.WorldID, _meshKey);
1110 _mesh = null; // the mesh cannot match either
1111 _meshKey = 0;
1112 } 1110 }
1113 1111
1114 _hullKey = newHullKey; 1112 _hullKey = newHullKey;
1115 if (_meshKey != _hullKey) 1113
1116 { 1114 // Make sure the underlying mesh exists and is correct
1117 // if the underlying mesh has changed, rebuild it 1115 CreateGeomMesh();
1118 CreateGeomMesh();
1119 }
1120 1116
1121 int[] indices = _mesh.getIndexListAsInt(); 1117 int[] indices = _mesh.getIndexListAsInt();
1122 List<OMV.Vector3> vertices = _mesh.getVertexList(); 1118 List<OMV.Vector3> vertices = _mesh.getVertexList();
@@ -1142,7 +1138,7 @@ public sealed class BSPrim : PhysicsActor
1142 // create the hull into the _hulls variable 1138 // create the hull into the _hulls variable
1143 convexBuilder.process(dcomp); 1139 convexBuilder.process(dcomp);
1144 1140
1145 // Convert the vertices and indices for passing to unmanaged 1141 // Convert the vertices and indices for passing to unmanaged.
1146 // The hull information is passed as a large floating point array. 1142 // The hull information is passed as a large floating point array.
1147 // The format is: 1143 // The format is:
1148 // convHulls[0] = number of hulls 1144 // convHulls[0] = number of hulls
@@ -1355,7 +1351,7 @@ public sealed class BSPrim : PhysicsActor
1355 } 1351 }
1356 1352
1357 // I've collided with something 1353 // I've collided with something
1358 CollisionEventUpdate collisionCollection = null; 1354 CollisionEventUpdate collisionCollection;
1359 public void Collide(uint collidingWith, ActorTypes type, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) 1355 public void Collide(uint collidingWith, ActorTypes type, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth)
1360 { 1356 {
1361 // m_log.DebugFormat("{0}: Collide: ms={1}, id={2}, with={3}", LogHeader, _subscribedEventsMs, LocalID, collidingWith); 1357 // m_log.DebugFormat("{0}: Collide: ms={1}, id={2}, with={3}", LogHeader, _subscribedEventsMs, LocalID, collidingWith);
@@ -1367,6 +1363,8 @@ public sealed class BSPrim : PhysicsActor
1367 _collidingGroundStep = _scene.SimulationStep; 1363 _collidingGroundStep = _scene.SimulationStep;
1368 } 1364 }
1369 1365
1366 // DetailLog("{0},BSPrim.Collison,call,with={1}", LocalID, collidingWith);
1367
1370 // if someone is subscribed to collision events.... 1368 // if someone is subscribed to collision events....
1371 if (_subscribedEventsMs != 0) { 1369 if (_subscribedEventsMs != 0) {
1372 // throttle the collisions to the number of milliseconds specified in the subscription 1370 // throttle the collisions to the number of milliseconds specified in the subscription
@@ -1387,7 +1385,9 @@ public sealed class BSPrim : PhysicsActor
1387 if (collisionCollection != null && collisionCollection.Count > 0) 1385 if (collisionCollection != null && collisionCollection.Count > 0)
1388 { 1386 {
1389 base.SendCollisionUpdate(collisionCollection); 1387 base.SendCollisionUpdate(collisionCollection);
1390 collisionCollection.Clear(); 1388 // The collisionCollection structure is passed around in the simulator.
1389 // Make sure we don't have a handle to that one and that a new one is used next time.
1390 collisionCollection = null;
1391 } 1391 }
1392 } 1392 }
1393 1393