aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/KeyframeMotion.cs23
1 files changed, 8 insertions, 15 deletions
diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs
index 6dc6504..75b16dc 100644
--- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs
+++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs
@@ -27,12 +27,11 @@ namespace OpenSim.Region.Framework.Scenes
27 private static Dictionary<Scene, KeyframeTimer>m_timers = 27 private static Dictionary<Scene, KeyframeTimer>m_timers =
28 new Dictionary<Scene, KeyframeTimer>(); 28 new Dictionary<Scene, KeyframeTimer>();
29 29
30 private Timer m_timer;
31 private Dictionary<KeyframeMotion, object> m_motions = new Dictionary<KeyframeMotion, object>(); 30 private Dictionary<KeyframeMotion, object> m_motions = new Dictionary<KeyframeMotion, object>();
32 private object m_lockObject = new object(); 31 private object m_lockObject = new object();
33 private object m_timerLock = new object();
34 private const double m_tickDuration = 50.0; 32 private const double m_tickDuration = 50.0;
35 private Scene m_scene; 33 private Scene m_scene;
34 private int m_prevTick;
36 35
37 public double TickDuration 36 public double TickDuration
38 { 37 {
@@ -41,20 +40,18 @@ namespace OpenSim.Region.Framework.Scenes
41 40
42 public KeyframeTimer(Scene scene) 41 public KeyframeTimer(Scene scene)
43 { 42 {
44 m_timer = new Timer(); 43 m_prevTick = Util.EnvironmentTickCount();
45 m_timer.Interval = TickDuration;
46 m_timer.AutoReset = true;
47 m_timer.Elapsed += OnTimer;
48 44
49 m_scene = scene; 45 m_scene = scene;
50 46
51 m_timer.Start(); 47 m_scene.EventManager.OnFrame += OnTimer;
52 } 48 }
53 49
54 private void OnTimer(object sender, ElapsedEventArgs ea) 50 private void OnTimer()
55 { 51 {
56 if (!Monitor.TryEnter(m_timerLock)) 52 int thisTick = Util.EnvironmentTickCount();
57 return; 53 int tickdiff = Util.EnvironmentTickCountSubtract(thisTick, m_prevTick);
54 m_prevTick = thisTick;
58 55
59 try 56 try
60 { 57 {
@@ -69,7 +66,7 @@ namespace OpenSim.Region.Framework.Scenes
69 { 66 {
70 try 67 try
71 { 68 {
72 m.OnTimer(TickDuration); 69 m.OnTimer(tickdiff);
73 } 70 }
74 catch (Exception inner) 71 catch (Exception inner)
75 { 72 {
@@ -81,10 +78,6 @@ namespace OpenSim.Region.Framework.Scenes
81 { 78 {
82 // Keep running no matter what 79 // Keep running no matter what
83 } 80 }
84 finally
85 {
86 Monitor.Exit(m_timerLock);
87 }
88 } 81 }
89 82
90 public static void Add(KeyframeMotion motion) 83 public static void Add(KeyframeMotion motion)