diff options
Diffstat (limited to '')
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 7ff0a07..bcc3b4a 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 | { |
@@ -1090,6 +1103,15 @@ namespace OpenSim.Region.PhysicsModule.BulletS | |||
1090 | { | 1103 | { |
1091 | if (!m_initialized) return; | 1104 | if (!m_initialized) return; |
1092 | 1105 | ||
1106 | lock (_taintLock) { | ||
1107 | if (inTaintTime || !InSimulationTime) { | ||
1108 | pCallback(); | ||
1109 | } | ||
1110 | else { | ||
1111 | _taintOperations.Add(new TaintCallbackEntry(pOriginator, pIdent, pCallback)); | ||
1112 | } | ||
1113 | } | ||
1114 | /* | ||
1093 | if (inTaintTime) | 1115 | if (inTaintTime) |
1094 | pCallback(); | 1116 | pCallback(); |
1095 | else | 1117 | else |
@@ -1099,6 +1121,7 @@ namespace OpenSim.Region.PhysicsModule.BulletS | |||
1099 | _taintOperations.Add(new TaintCallbackEntry(pOriginator, pIdent, pCallback)); | 1121 | _taintOperations.Add(new TaintCallbackEntry(pOriginator, pIdent, pCallback)); |
1100 | } | 1122 | } |
1101 | } | 1123 | } |
1124 | */ | ||
1102 | } | 1125 | } |
1103 | 1126 | ||
1104 | private void TriggerPreStepEvent(float timeStep) | 1127 | private void TriggerPreStepEvent(float timeStep) |
@@ -1120,14 +1143,19 @@ namespace OpenSim.Region.PhysicsModule.BulletS | |||
1120 | // When someone tries to change a property on a BSPrim or BSCharacter, the object queues | 1143 | // When someone tries to change a property on a BSPrim or BSCharacter, the object queues |
1121 | // a callback into itself to do the actual property change. That callback is called | 1144 | // a callback into itself to do the actual property change. That callback is called |
1122 | // here just before the physics engine is called to step the simulation. | 1145 | // here just before the physics engine is called to step the simulation. |
1123 | public void ProcessTaints() | 1146 | // Returns the number of taints processed |
1147 | public int ProcessTaints() | ||
1124 | { | 1148 | { |
1125 | ProcessRegularTaints(); | 1149 | int ret = 0; |
1126 | ProcessPostTaintTaints(); | 1150 | ret += ProcessRegularTaints(); |
1151 | ret += ProcessPostTaintTaints(); | ||
1152 | return ret; | ||
1127 | } | 1153 | } |
1128 | 1154 | ||
1129 | private void ProcessRegularTaints() | 1155 | // Returns the number of taints processed |
1156 | private int ProcessRegularTaints() | ||
1130 | { | 1157 | { |
1158 | int ret = 0; | ||
1131 | if (m_initialized && _taintOperations.Count > 0) // save allocating new list if there is nothing to process | 1159 | if (m_initialized && _taintOperations.Count > 0) // save allocating new list if there is nothing to process |
1132 | { | 1160 | { |
1133 | // swizzle a new list into the list location so we can process what's there | 1161 | // swizzle a new list into the list location so we can process what's there |
@@ -1144,6 +1172,7 @@ namespace OpenSim.Region.PhysicsModule.BulletS | |||
1144 | { | 1172 | { |
1145 | DetailLog("{0},BSScene.ProcessTaints,doTaint,id={1}", tcbe.originator, tcbe.ident); // DEBUG DEBUG DEBUG | 1173 | DetailLog("{0},BSScene.ProcessTaints,doTaint,id={1}", tcbe.originator, tcbe.ident); // DEBUG DEBUG DEBUG |
1146 | tcbe.callback(); | 1174 | tcbe.callback(); |
1175 | ret++; | ||
1147 | } | 1176 | } |
1148 | catch (Exception e) | 1177 | catch (Exception e) |
1149 | { | 1178 | { |
@@ -1152,6 +1181,7 @@ namespace OpenSim.Region.PhysicsModule.BulletS | |||
1152 | } | 1181 | } |
1153 | oldList.Clear(); | 1182 | oldList.Clear(); |
1154 | } | 1183 | } |
1184 | return ret; | ||
1155 | } | 1185 | } |
1156 | 1186 | ||
1157 | // Schedule an update to happen after all the regular taints are processed. | 1187 | // Schedule an update to happen after all the regular taints are processed. |
@@ -1170,8 +1200,10 @@ namespace OpenSim.Region.PhysicsModule.BulletS | |||
1170 | } | 1200 | } |
1171 | 1201 | ||
1172 | // Taints that happen after the normal taint processing but before the simulation step. | 1202 | // Taints that happen after the normal taint processing but before the simulation step. |
1173 | private void ProcessPostTaintTaints() | 1203 | // Returns the number of taints processed |
1204 | private int ProcessPostTaintTaints() | ||
1174 | { | 1205 | { |
1206 | int ret = 0; | ||
1175 | if (m_initialized && _postTaintOperations.Count > 0) | 1207 | if (m_initialized && _postTaintOperations.Count > 0) |
1176 | { | 1208 | { |
1177 | Dictionary<string, TaintCallbackEntry> oldList; | 1209 | Dictionary<string, TaintCallbackEntry> oldList; |
@@ -1187,6 +1219,7 @@ namespace OpenSim.Region.PhysicsModule.BulletS | |||
1187 | { | 1219 | { |
1188 | DetailLog("{0},BSScene.ProcessPostTaintTaints,doTaint,id={1}", DetailLogZero, kvp.Key); // DEBUG DEBUG DEBUG | 1220 | DetailLog("{0},BSScene.ProcessPostTaintTaints,doTaint,id={1}", DetailLogZero, kvp.Key); // DEBUG DEBUG DEBUG |
1189 | kvp.Value.callback(); | 1221 | kvp.Value.callback(); |
1222 | ret++; | ||
1190 | } | 1223 | } |
1191 | catch (Exception e) | 1224 | catch (Exception e) |
1192 | { | 1225 | { |
@@ -1195,18 +1228,19 @@ namespace OpenSim.Region.PhysicsModule.BulletS | |||
1195 | } | 1228 | } |
1196 | oldList.Clear(); | 1229 | oldList.Clear(); |
1197 | } | 1230 | } |
1231 | return ret; | ||
1198 | } | 1232 | } |
1199 | 1233 | ||
1200 | // Only used for debugging. Does not change state of anything so locking is not necessary. | 1234 | // Verify that things are being diddled when the physics engine is not running. |
1201 | public bool AssertInTaintTime(string whereFrom) | 1235 | public bool AssertNotInSimulationTime(string whereFrom) |
1202 | { | 1236 | { |
1203 | if (!InTaintTime) | 1237 | if (InSimulationTime) |
1204 | { | 1238 | { |
1205 | DetailLog("{0},BSScene.AssertInTaintTime,NOT IN TAINT TIME,Region={1},Where={2}", DetailLogZero, RegionName, whereFrom); | 1239 | DetailLog("{0},BSScene.AssertInTaintTime,IN SIMULATION TIME,Region={1},Where={2}", DetailLogZero, RegionName, whereFrom); |
1206 | m_log.ErrorFormat("{0} NOT IN TAINT TIME!! Region={1}, Where={2}", LogHeader, RegionName, whereFrom); | 1240 | m_log.ErrorFormat("{0} IN SIMULATION TIME!! Region={1}, Where={2}", LogHeader, RegionName, whereFrom); |
1207 | // Util.PrintCallStack(DetailLog); | 1241 | // Util.PrintCallStack(DetailLog); |
1208 | } | 1242 | } |
1209 | return InTaintTime; | 1243 | return InSimulationTime; |
1210 | } | 1244 | } |
1211 | 1245 | ||
1212 | #endregion // Taints | 1246 | #endregion // Taints |
diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSShapeCollection.cs b/OpenSim/Region/PhysicsModules/BulletS/BSShapeCollection.cs index 4ec6f51..8d8fc95 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 | ||
@@ -344,7 +344,7 @@ public sealed class BSShapeCollection : IDisposable | |||
344 | if (!body.HasPhysicalBody) | 344 | if (!body.HasPhysicalBody) |
345 | return; | 345 | return; |
346 | 346 | ||
347 | m_physicsScene.AssertInTaintTime("BSShapeCollection.DereferenceBody"); | 347 | m_physicsScene.AssertNotInSimulationTime("BSShapeCollection.DereferenceBody"); |
348 | 348 | ||
349 | lock (m_collectionActivityLock) | 349 | lock (m_collectionActivityLock) |
350 | { | 350 | { |
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 | ||
103 | public class BulletShape | 104 | public class BulletShape |
104 | { | 105 | { |
105 | public BulletShape() | 106 | public BulletShape() |