aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/PhysicsModules
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs6
-rw-r--r--OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs2
-rw-r--r--OpenSim/Region/PhysicsModules/BulletS/BSScene.cs76
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSShapeCollection.cs4
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BulletSimData.cs1
5 files changed, 62 insertions, 27 deletions
diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs b/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs
index 57f03fb..04ac659 100644
--- a/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs
@@ -496,8 +496,8 @@ public sealed class BSCharacter : BSPhysObject
496 public override OMV.Vector3 ForceVelocity { 496 public override OMV.Vector3 ForceVelocity {
497 get { return RawVelocity; } 497 get { return RawVelocity; }
498 set { 498 set {
499 PhysScene.AssertInTaintTime("BSCharacter.ForceVelocity"); 499 PhysScene.AssertNotInSimulationTime("BSCharacter.ForceVelocity");
500 DetailLog("{0}: BSCharacter.ForceVelocity.set = {1}", LocalID, value); 500 DetailLog("{0},BSCharacter.ForceVelocity.set={1}", LocalID, value);
501 501
502 RawVelocity = Util.ClampV(value, BSParam.MaxLinearVelocity); 502 RawVelocity = Util.ClampV(value, BSParam.MaxLinearVelocity);
503 PhysScene.PE.SetLinearVelocity(PhysBody, RawVelocity); 503 PhysScene.PE.SetLinearVelocity(PhysBody, RawVelocity);
@@ -638,7 +638,7 @@ public sealed class BSCharacter : BSPhysObject
638 public override float ForceBuoyancy { 638 public override float ForceBuoyancy {
639 get { return _buoyancy; } 639 get { return _buoyancy; }
640 set { 640 set {
641 PhysScene.AssertInTaintTime("BSCharacter.ForceBuoyancy"); 641 PhysScene.AssertNotInSimulationTime("BSCharacter.ForceBuoyancy");
642 642
643 _buoyancy = value; 643 _buoyancy = value;
644 DetailLog("{0},BSCharacter.setForceBuoyancy,taint,buoy={1}", LocalID, _buoyancy); 644 DetailLog("{0},BSCharacter.setForceBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs b/OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs
index b153761..e1990ee 100644
--- a/OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs
@@ -790,7 +790,7 @@ public class BSPrim : BSPhysObject
790 public override OMV.Vector3 ForceVelocity { 790 public override OMV.Vector3 ForceVelocity {
791 get { return RawVelocity; } 791 get { return RawVelocity; }
792 set { 792 set {
793 PhysScene.AssertInTaintTime("BSPrim.ForceVelocity"); 793 PhysScene.AssertNotInSimulationTime("BSPrim.ForceVelocity");
794 794
795 RawVelocity = Util.ClampV(value, BSParam.MaxLinearVelocity); 795 RawVelocity = Util.ClampV(value, BSParam.MaxLinearVelocity);
796 if (PhysBody.HasPhysicalBody) 796 if (PhysBody.HasPhysicalBody)
diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSScene.cs b/OpenSim/Region/PhysicsModules/BulletS/BSScene.cs
index f1ff3a9..52aea87 100644
--- a/OpenSim/Region/PhysicsModules/BulletS/BSScene.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSScene.cs
@@ -128,6 +128,9 @@ namespace OpenSim.Region.PhysicsModule.BulletS
128 // Not guaranteed to be correct all the time (don't depend on this) but good for debugging. 128 // Not guaranteed to be correct all the time (don't depend on this) but good for debugging.
129 public bool InTaintTime { get; private set; } 129 public bool InTaintTime { get; private set; }
130 130
131 // Flag that is true when the simulator is active and shouldn't be touched
132 public bool InSimulationTime { get; private set; }
133
131 // Pinned memory used to pass step information between managed and unmanaged 134 // Pinned memory used to pass step information between managed and unmanaged
132 internal int m_maxCollisionsPerFrame; 135 internal int m_maxCollisionsPerFrame;
133 internal CollisionDesc[] m_collisionArray; 136 internal CollisionDesc[] m_collisionArray;
@@ -344,6 +347,7 @@ namespace OpenSim.Region.PhysicsModule.BulletS
344 // Put some informational messages into the log file. 347 // Put some informational messages into the log file.
345 m_log.InfoFormat("{0} Linksets implemented with {1}", LogHeader, (BSLinkset.LinksetImplementation)BSParam.LinksetImplementation); 348 m_log.InfoFormat("{0} Linksets implemented with {1}", LogHeader, (BSLinkset.LinksetImplementation)BSParam.LinksetImplementation);
346 349
350 InSimulationTime = false;
347 InTaintTime = false; 351 InTaintTime = false;
348 m_initialized = true; 352 m_initialized = true;
349 353
@@ -658,21 +662,21 @@ namespace OpenSim.Region.PhysicsModule.BulletS
658 int beforeTime = Util.EnvironmentTickCount(); 662 int beforeTime = Util.EnvironmentTickCount();
659 int simTime = 0; 663 int simTime = 0;
660 664
661 int numTaints = _taintOperations.Count; 665 InTaintTime = true;
662 InTaintTime = true; // Only used for debugging so locking is not necessary.
663
664 // update the prim states while we know the physics engine is not busy 666 // update the prim states while we know the physics engine is not busy
665 ProcessTaints(); 667 int numTaints = ProcessTaints();
666 668
667 // Some of the physical objects requre individual, pre-step calls 669 // Some of the physical objects requre individual, pre-step calls
668 // (vehicles and avatar movement, in particular) 670 // (vehicles and avatar movement, in particular)
669 TriggerPreStepEvent(timeStep); 671 TriggerPreStepEvent(timeStep);
670 672
671 // the prestep actions might have added taints 673 // the prestep actions might have added taints
672 numTaints += _taintOperations.Count; 674 numTaints += ProcessTaints();
673 ProcessTaints();
674 675
675 InTaintTime = false; // Only used for debugging so locking is not necessary. 676 lock (_taintLock)
677 {
678 InSimulationTime = true;
679 }
676 680
677 // The following causes the unmanaged code to output ALL the values found in ALL the objects in the world. 681 // The following causes the unmanaged code to output ALL the values found in ALL the objects in the world.
678 // Only enable this in a limited test world with few objects. 682 // Only enable this in a limited test world with few objects.
@@ -700,6 +704,18 @@ namespace OpenSim.Region.PhysicsModule.BulletS
700 if (PhysicsMetricDumpFrames != 0 && ((m_simulationStep % PhysicsMetricDumpFrames) == 0)) 704 if (PhysicsMetricDumpFrames != 0 && ((m_simulationStep % PhysicsMetricDumpFrames) == 0))
701 PE.DumpPhysicsStatistics(World); 705 PE.DumpPhysicsStatistics(World);
702 706
707 lock (_taintLock)
708 {
709 InTaintTime = false;
710 InSimulationTime = false;
711 }
712
713 // Some actors want to know when the simulation step is complete.
714 TriggerPostStepEvent(timeStep);
715
716 // In case there were any parameter updates that happened during the simulation step
717 numTaints += ProcessTaints();
718
703 // Get a value for 'now' so all the collision and update routines don't have to get their own. 719 // Get a value for 'now' so all the collision and update routines don't have to get their own.
704 SimulationNowTime = Util.EnvironmentTickCount(); 720 SimulationNowTime = Util.EnvironmentTickCount();
705 721
@@ -748,9 +764,6 @@ namespace OpenSim.Region.PhysicsModule.BulletS
748 } 764 }
749 } 765 }
750 766
751 // Some actors want to know when the simulation step is complete.
752 TriggerPostStepEvent(timeStep);
753
754 simTime = Util.EnvironmentTickCountSubtract(beforeTime); 767 simTime = Util.EnvironmentTickCountSubtract(beforeTime);
755 if (PhysicsLogging.Enabled) 768 if (PhysicsLogging.Enabled)
756 { 769 {
@@ -1182,6 +1195,15 @@ namespace OpenSim.Region.PhysicsModule.BulletS
1182 { 1195 {
1183 if (!m_initialized) return; 1196 if (!m_initialized) return;
1184 1197
1198 lock (_taintLock) {
1199 if (inTaintTime || !InSimulationTime) {
1200 pCallback();
1201 }
1202 else {
1203 _taintOperations.Add(new TaintCallbackEntry(pOriginator, pIdent, pCallback));
1204 }
1205 }
1206 /*
1185 if (inTaintTime) 1207 if (inTaintTime)
1186 pCallback(); 1208 pCallback();
1187 else 1209 else
@@ -1191,6 +1213,7 @@ namespace OpenSim.Region.PhysicsModule.BulletS
1191 _taintOperations.Add(new TaintCallbackEntry(pOriginator, pIdent, pCallback)); 1213 _taintOperations.Add(new TaintCallbackEntry(pOriginator, pIdent, pCallback));
1192 } 1214 }
1193 } 1215 }
1216 */
1194 } 1217 }
1195 1218
1196 private void TriggerPreStepEvent(float timeStep) 1219 private void TriggerPreStepEvent(float timeStep)
@@ -1212,14 +1235,19 @@ namespace OpenSim.Region.PhysicsModule.BulletS
1212 // When someone tries to change a property on a BSPrim or BSCharacter, the object queues 1235 // When someone tries to change a property on a BSPrim or BSCharacter, the object queues
1213 // a callback into itself to do the actual property change. That callback is called 1236 // a callback into itself to do the actual property change. That callback is called
1214 // here just before the physics engine is called to step the simulation. 1237 // here just before the physics engine is called to step the simulation.
1215 public void ProcessTaints() 1238 // Returns the number of taints processed
1239 public int ProcessTaints()
1216 { 1240 {
1217 ProcessRegularTaints(); 1241 int ret = 0;
1218 ProcessPostTaintTaints(); 1242 ret += ProcessRegularTaints();
1243 ret += ProcessPostTaintTaints();
1244 return ret;
1219 } 1245 }
1220 1246
1221 private void ProcessRegularTaints() 1247 // Returns the number of taints processed
1248 private int ProcessRegularTaints()
1222 { 1249 {
1250 int ret = 0;
1223 if (m_initialized && _taintOperations.Count > 0) // save allocating new list if there is nothing to process 1251 if (m_initialized && _taintOperations.Count > 0) // save allocating new list if there is nothing to process
1224 { 1252 {
1225 // swizzle a new list into the list location so we can process what's there 1253 // swizzle a new list into the list location so we can process what's there
@@ -1236,6 +1264,7 @@ namespace OpenSim.Region.PhysicsModule.BulletS
1236 { 1264 {
1237 DetailLog("{0},BSScene.ProcessTaints,doTaint,id={1}", tcbe.originator, tcbe.ident); // DEBUG DEBUG DEBUG 1265 DetailLog("{0},BSScene.ProcessTaints,doTaint,id={1}", tcbe.originator, tcbe.ident); // DEBUG DEBUG DEBUG
1238 tcbe.callback(); 1266 tcbe.callback();
1267 ret++;
1239 } 1268 }
1240 catch (Exception e) 1269 catch (Exception e)
1241 { 1270 {
@@ -1244,6 +1273,7 @@ namespace OpenSim.Region.PhysicsModule.BulletS
1244 } 1273 }
1245 oldList.Clear(); 1274 oldList.Clear();
1246 } 1275 }
1276 return ret;
1247 } 1277 }
1248 1278
1249 // Schedule an update to happen after all the regular taints are processed. 1279 // Schedule an update to happen after all the regular taints are processed.
@@ -1262,8 +1292,10 @@ namespace OpenSim.Region.PhysicsModule.BulletS
1262 } 1292 }
1263 1293
1264 // Taints that happen after the normal taint processing but before the simulation step. 1294 // Taints that happen after the normal taint processing but before the simulation step.
1265 private void ProcessPostTaintTaints() 1295 // Returns the number of taints processed
1296 private int ProcessPostTaintTaints()
1266 { 1297 {
1298 int ret = 0;
1267 if (m_initialized && _postTaintOperations.Count > 0) 1299 if (m_initialized && _postTaintOperations.Count > 0)
1268 { 1300 {
1269 Dictionary<string, TaintCallbackEntry> oldList; 1301 Dictionary<string, TaintCallbackEntry> oldList;
@@ -1279,6 +1311,7 @@ namespace OpenSim.Region.PhysicsModule.BulletS
1279 { 1311 {
1280 DetailLog("{0},BSScene.ProcessPostTaintTaints,doTaint,id={1}", DetailLogZero, kvp.Key); // DEBUG DEBUG DEBUG 1312 DetailLog("{0},BSScene.ProcessPostTaintTaints,doTaint,id={1}", DetailLogZero, kvp.Key); // DEBUG DEBUG DEBUG
1281 kvp.Value.callback(); 1313 kvp.Value.callback();
1314 ret++;
1282 } 1315 }
1283 catch (Exception e) 1316 catch (Exception e)
1284 { 1317 {
@@ -1287,18 +1320,19 @@ namespace OpenSim.Region.PhysicsModule.BulletS
1287 } 1320 }
1288 oldList.Clear(); 1321 oldList.Clear();
1289 } 1322 }
1323 return ret;
1290 } 1324 }
1291 1325
1292 // Only used for debugging. Does not change state of anything so locking is not necessary. 1326 // Verify that things are being diddled when the physics engine is not running.
1293 public bool AssertInTaintTime(string whereFrom) 1327 public bool AssertNotInSimulationTime(string whereFrom)
1294 { 1328 {
1295 if (!InTaintTime) 1329 if (InSimulationTime)
1296 { 1330 {
1297 DetailLog("{0},BSScene.AssertInTaintTime,NOT IN TAINT TIME,Region={1},Where={2}", DetailLogZero, RegionName, whereFrom); 1331 DetailLog("{0},BSScene.AssertInTaintTime,IN SIMULATION TIME,Region={1},Where={2}", DetailLogZero, RegionName, whereFrom);
1298 m_log.ErrorFormat("{0} NOT IN TAINT TIME!! Region={1}, Where={2}", LogHeader, RegionName, whereFrom); 1332 m_log.ErrorFormat("{0} IN SIMULATION TIME!! Region={1}, Where={2}", LogHeader, RegionName, whereFrom);
1299 // Util.PrintCallStack(DetailLog); 1333 // Util.PrintCallStack(DetailLog);
1300 } 1334 }
1301 return InTaintTime; 1335 return InSimulationTime;
1302 } 1336 }
1303 1337
1304 #endregion // Taints 1338 #endregion // Taints
diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSShapeCollection.cs b/OpenSim/Region/PhysicsModules/BulletS/BSShapeCollection.cs
index cd72c98..cda33e4 100755
--- a/OpenSim/Region/PhysicsModules/BulletS/BSShapeCollection.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSShapeCollection.cs
@@ -75,7 +75,7 @@ public sealed class BSShapeCollection : IDisposable
75 // Called at taint-time. 75 // Called at taint-time.
76 public bool GetBodyAndShape(bool forceRebuild, BulletWorld sim, BSPhysObject prim, PhysicalDestructionCallback bodyCallback) 76 public bool GetBodyAndShape(bool forceRebuild, BulletWorld sim, BSPhysObject prim, PhysicalDestructionCallback bodyCallback)
77 { 77 {
78 m_physicsScene.AssertInTaintTime("BSShapeCollection.GetBodyAndShape"); 78 m_physicsScene.AssertNotInSimulationTime("BSShapeCollection.GetBodyAndShape");
79 79
80 bool ret = false; 80 bool ret = false;
81 81
@@ -346,7 +346,7 @@ public sealed class BSShapeCollection : IDisposable
346 if (!body.HasPhysicalBody) 346 if (!body.HasPhysicalBody)
347 return; 347 return;
348 348
349 m_physicsScene.AssertInTaintTime("BSShapeCollection.DereferenceBody"); 349 m_physicsScene.AssertNotInSimulationTime("BSShapeCollection.DereferenceBody");
350 350
351 lock (m_collectionActivityLock) 351 lock (m_collectionActivityLock)
352 { 352 {
diff --git a/OpenSim/Region/PhysicsModules/BulletS/BulletSimData.cs b/OpenSim/Region/PhysicsModules/BulletS/BulletSimData.cs
index 3329395..308769b 100755
--- a/OpenSim/Region/PhysicsModules/BulletS/BulletSimData.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BulletSimData.cs
@@ -100,6 +100,7 @@ public class BulletBody
100 } 100 }
101} 101}
102 102
103// Handle to btCollisionObject - a shape that can be added to a btRidgidBody
103public class BulletShape 104public class BulletShape
104{ 105{
105 public BulletShape() 106 public BulletShape()