From e85a6237bfc0f00de4a183e29e515fa5baf1aa7f Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 11 Feb 2013 23:49:05 +0100 Subject: Make keyframes use the sim's frame timer --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/Framework') 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 private static Dictionarym_timers = new Dictionary(); - private Timer m_timer; private Dictionary m_motions = new Dictionary(); private object m_lockObject = new object(); - private object m_timerLock = new object(); private const double m_tickDuration = 50.0; private Scene m_scene; + private int m_prevTick; public double TickDuration { @@ -41,20 +40,18 @@ namespace OpenSim.Region.Framework.Scenes public KeyframeTimer(Scene scene) { - m_timer = new Timer(); - m_timer.Interval = TickDuration; - m_timer.AutoReset = true; - m_timer.Elapsed += OnTimer; + m_prevTick = Util.EnvironmentTickCount(); m_scene = scene; - m_timer.Start(); + m_scene.EventManager.OnFrame += OnTimer; } - private void OnTimer(object sender, ElapsedEventArgs ea) + private void OnTimer() { - if (!Monitor.TryEnter(m_timerLock)) - return; + int thisTick = Util.EnvironmentTickCount(); + int tickdiff = Util.EnvironmentTickCountSubtract(thisTick, m_prevTick); + m_prevTick = thisTick; try { @@ -69,7 +66,7 @@ namespace OpenSim.Region.Framework.Scenes { try { - m.OnTimer(TickDuration); + m.OnTimer(tickdiff); } catch (Exception inner) { @@ -81,10 +78,6 @@ namespace OpenSim.Region.Framework.Scenes { // Keep running no matter what } - finally - { - Monitor.Exit(m_timerLock); - } } public static void Add(KeyframeMotion motion) -- cgit v1.1