diff options
author | Justin Clark-Casey (justincc) | 2014-09-26 20:56:22 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2014-11-25 23:18:38 +0000 |
commit | 8d721451129a8f9de84157d83e4bc741c8c7684f (patch) | |
tree | 2c26ed9e1cca03aa9dee3330493065642d90c28b /OpenSim/Region/Physics | |
parent | Improve frame time stability by taking a few unnecessary repeated calculation... (diff) | |
download | opensim-SC_OLD-8d721451129a8f9de84157d83e4bc741c8c7684f.zip opensim-SC_OLD-8d721451129a8f9de84157d83e4bc741c8c7684f.tar.gz opensim-SC_OLD-8d721451129a8f9de84157d83e4bc741c8c7684f.tar.bz2 opensim-SC_OLD-8d721451129a8f9de84157d83e4bc741c8c7684f.tar.xz |
If Bullet is running on its own thread, use a reset event to control timing rather than a sleep.
In theory, there should be no difference between these mechanisms.
However, on at least Mono 3.2.8 waiting via an event appears to be much more accurate.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 7d57751..46a13ab 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 |
@@ -839,6 +844,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
839 | public void BulletSPluginPhysicsThread() | 844 | public void BulletSPluginPhysicsThread() |
840 | { | 845 | { |
841 | Thread.CurrentThread.Priority = ThreadPriority.Highest; | 846 | Thread.CurrentThread.Priority = ThreadPriority.Highest; |
847 | m_updateWaitEvent = new ManualResetEvent(false); | ||
842 | 848 | ||
843 | while (m_initialized) | 849 | while (m_initialized) |
844 | { | 850 | { |
@@ -853,8 +859,9 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
853 | if (simulationTimeVsRealtimeDifferenceMS > 0) | 859 | if (simulationTimeVsRealtimeDifferenceMS > 0) |
854 | { | 860 | { |
855 | // The simulation of the time interval took less than realtime. | 861 | // The simulation of the time interval took less than realtime. |
856 | // Do a sleep for the rest of realtime. | 862 | // Do a wait for the rest of realtime. |
857 | Thread.Sleep(simulationTimeVsRealtimeDifferenceMS); | 863 | m_updateWaitEvent.WaitOne(simulationTimeVsRealtimeDifferenceMS); |
864 | //Thread.Sleep(simulationTimeVsRealtimeDifferenceMS); | ||
858 | } | 865 | } |
859 | else | 866 | else |
860 | { | 867 | { |