diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSScene.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index a46c241..0f79a10 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | |||
@@ -130,6 +130,11 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
130 | internal int m_maxUpdatesPerFrame; | 130 | internal int m_maxUpdatesPerFrame; |
131 | internal EntityProperties[] m_updateArray; | 131 | internal EntityProperties[] m_updateArray; |
132 | 132 | ||
133 | /// <summary> | ||
134 | /// Used to control physics simulation timing if Bullet is running on its own thread. | ||
135 | /// </summary> | ||
136 | private ManualResetEvent m_updateWaitEvent; | ||
137 | |||
133 | public const uint TERRAIN_ID = 0; // OpenSim senses terrain with a localID of zero | 138 | public const uint TERRAIN_ID = 0; // OpenSim senses terrain with a localID of zero |
134 | public const uint GROUNDPLANE_ID = 1; | 139 | public const uint GROUNDPLANE_ID = 1; |
135 | public const uint CHILDTERRAIN_ID = 2; // Terrain allocated based on our mega-prim childre start here | 140 | public const uint CHILDTERRAIN_ID = 2; // Terrain allocated based on our mega-prim childre start here |
@@ -288,7 +293,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
288 | { | 293 | { |
289 | // The physics simulation should happen independently of the heartbeat loop | 294 | // The physics simulation should happen independently of the heartbeat loop |
290 | m_physicsThread | 295 | m_physicsThread |
291 | = Watchdog.StartThread( | 296 | = WorkManager.StartThread( |
292 | BulletSPluginPhysicsThread, | 297 | BulletSPluginPhysicsThread, |
293 | string.Format("{0} ({1})", BulletEngineName, RegionName), | 298 | string.Format("{0} ({1})", BulletEngineName, RegionName), |
294 | ThreadPriority.Normal, | 299 | ThreadPriority.Normal, |
@@ -838,6 +843,9 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
838 | 843 | ||
839 | public void BulletSPluginPhysicsThread() | 844 | public void BulletSPluginPhysicsThread() |
840 | { | 845 | { |
846 | Thread.CurrentThread.Priority = ThreadPriority.Highest; | ||
847 | m_updateWaitEvent = new ManualResetEvent(false); | ||
848 | |||
841 | while (m_initialized) | 849 | while (m_initialized) |
842 | { | 850 | { |
843 | int beginSimulationRealtimeMS = Util.EnvironmentTickCount(); | 851 | int beginSimulationRealtimeMS = Util.EnvironmentTickCount(); |
@@ -851,8 +859,9 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
851 | if (simulationTimeVsRealtimeDifferenceMS > 0) | 859 | if (simulationTimeVsRealtimeDifferenceMS > 0) |
852 | { | 860 | { |
853 | // The simulation of the time interval took less than realtime. | 861 | // The simulation of the time interval took less than realtime. |
854 | // Do a sleep for the rest of realtime. | 862 | // Do a wait for the rest of realtime. |
855 | Thread.Sleep(simulationTimeVsRealtimeDifferenceMS); | 863 | m_updateWaitEvent.WaitOne(simulationTimeVsRealtimeDifferenceMS); |
864 | //Thread.Sleep(simulationTimeVsRealtimeDifferenceMS); | ||
856 | } | 865 | } |
857 | else | 866 | else |
858 | { | 867 | { |