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