diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/KeyframeMotion.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 60 |
1 files changed, 50 insertions, 10 deletions
diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 276b61f..4d153da 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | |||
@@ -1,6 +1,29 @@ | |||
1 | // Proprietary code of Avination Virtual Limited | 1 | /* |
2 | // (c) 2012 Melanie Thielker | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | // | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
4 | 27 | ||
5 | using System; | 28 | using System; |
6 | using System.Timers; | 29 | using System.Timers; |
@@ -32,7 +55,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
32 | private object m_lockObject = new object(); | 55 | private object m_lockObject = new object(); |
33 | private object m_timerLock = new object(); | 56 | private object m_timerLock = new object(); |
34 | private const double m_tickDuration = 50.0; | 57 | private const double m_tickDuration = 50.0; |
35 | private Scene m_scene; | ||
36 | 58 | ||
37 | public double TickDuration | 59 | public double TickDuration |
38 | { | 60 | { |
@@ -46,8 +68,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
46 | m_timer.AutoReset = true; | 68 | m_timer.AutoReset = true; |
47 | m_timer.Elapsed += OnTimer; | 69 | m_timer.Elapsed += OnTimer; |
48 | 70 | ||
49 | m_scene = scene; | ||
50 | |||
51 | m_timer.Start(); | 71 | m_timer.Start(); |
52 | } | 72 | } |
53 | 73 | ||
@@ -71,13 +91,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
71 | { | 91 | { |
72 | m.OnTimer(TickDuration); | 92 | m.OnTimer(TickDuration); |
73 | } | 93 | } |
74 | catch (Exception inner) | 94 | catch (Exception) |
75 | { | 95 | { |
76 | // Don't stop processing | 96 | // Don't stop processing |
77 | } | 97 | } |
78 | } | 98 | } |
79 | } | 99 | } |
80 | catch (Exception e) | 100 | catch (Exception) |
81 | { | 101 | { |
82 | // Keep running no matter what | 102 | // Keep running no matter what |
83 | } | 103 | } |
@@ -134,7 +154,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
134 | [Serializable] | 154 | [Serializable] |
135 | public class KeyframeMotion | 155 | public class KeyframeMotion |
136 | { | 156 | { |
137 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 157 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
138 | 158 | ||
139 | public enum PlayMode : int | 159 | public enum PlayMode : int |
140 | { | 160 | { |
@@ -478,6 +498,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
478 | k.Position = pos; | 498 | k.Position = pos; |
479 | // k.Velocity = Vector3.Zero; | 499 | // k.Velocity = Vector3.Zero; |
480 | } | 500 | } |
501 | k.AngularVelocity = (Vector3)k.Position; | ||
481 | 502 | ||
482 | k.StartRotation = rot; | 503 | k.StartRotation = rot; |
483 | if (k.Rotation.HasValue) | 504 | if (k.Rotation.HasValue) |
@@ -618,7 +639,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
618 | m_group.RootPart.Velocity = Vector3.Zero; | 639 | m_group.RootPart.Velocity = Vector3.Zero; |
619 | m_group.RootPart.AngularVelocity = Vector3.Zero; | 640 | m_group.RootPart.AngularVelocity = Vector3.Zero; |
620 | 641 | ||
621 | m_nextPosition = (Vector3)m_currentFrame.Position; | 642 | m_nextPosition = NormalizeVector(m_currentFrame.AngularVelocity); |
622 | m_group.AbsolutePosition = m_nextPosition; | 643 | m_group.AbsolutePosition = m_nextPosition; |
623 | 644 | ||
624 | // we are sending imediate updates, no doing force a extra terseUpdate | 645 | // we are sending imediate updates, no doing force a extra terseUpdate |
@@ -706,7 +727,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
706 | m_group.SendGroupRootTerseUpdate(); | 727 | m_group.SendGroupRootTerseUpdate(); |
707 | } | 728 | } |
708 | } | 729 | } |
730 | private Vector3 NormalizeVector(Vector3? pPosition) | ||
731 | { | ||
732 | if (pPosition == null) | ||
733 | return Vector3.Zero; | ||
734 | |||
735 | Vector3 tmp = (Vector3) pPosition; | ||
709 | 736 | ||
737 | while (tmp.X > Constants.RegionSize) | ||
738 | tmp.X -= Constants.RegionSize; | ||
739 | while (tmp.X < 0) | ||
740 | tmp.X += Constants.RegionSize; | ||
741 | while (tmp.Y > Constants.RegionSize) | ||
742 | tmp.Y -= Constants.RegionSize; | ||
743 | while (tmp.Y < 0) | ||
744 | tmp.Y += Constants.RegionSize; | ||
745 | |||
746 | return tmp; | ||
747 | |||
748 | |||
749 | } | ||
710 | public Byte[] Serialize() | 750 | public Byte[] Serialize() |
711 | { | 751 | { |
712 | StopTimer(); | 752 | StopTimer(); |