aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Animation
diff options
context:
space:
mode:
authorDavid Walter Seikel2016-11-03 21:44:39 +1000
committerDavid Walter Seikel2016-11-03 21:44:39 +1000
commit134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch)
tree216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Region/Framework/Scenes/Animation
parentMore changing to production grid. Double oops. (diff)
downloadopensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2
opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs119
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/BinBVHAnimation.cs49
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/DefaultAvatarAnimations.cs26
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs38
4 files changed, 201 insertions, 31 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs
index 66edfed..eb1a970 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs
@@ -28,8 +28,11 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using System.Text;
31using log4net; 32using log4net;
32using OpenMetaverse; 33using OpenMetaverse;
34using OpenMetaverse.StructuredData;
35
33using OpenSim.Framework; 36using OpenSim.Framework;
34 37
35using Animation = OpenSim.Framework.Animation; 38using Animation = OpenSim.Framework.Animation;
@@ -60,6 +63,12 @@ namespace OpenSim.Region.Framework.Scenes.Animation
60 ResetDefaultAnimation(); 63 ResetDefaultAnimation();
61 } 64 }
62 65
66 public AnimationSet(OSDArray pArray)
67 {
68 ResetDefaultAnimation();
69 FromOSDArray(pArray);
70 }
71
63 public bool HasAnimation(UUID animID) 72 public bool HasAnimation(UUID animID)
64 { 73 {
65 if (m_defaultAnimation.AnimID == animID) 74 if (m_defaultAnimation.AnimID == animID)
@@ -218,5 +227,115 @@ namespace OpenSim.Region.Framework.Scenes.Animation
218 foreach (OpenSim.Framework.Animation anim in theArray) 227 foreach (OpenSim.Framework.Animation anim in theArray)
219 m_animations.Add(anim); 228 m_animations.Add(anim);
220 } 229 }
230
231 // Create representation of this AnimationSet as an OSDArray.
232 // First two entries in the array are the default and implicitDefault animations
233 // followed by the other animations.
234 public OSDArray ToOSDArray()
235 {
236 OSDArray ret = new OSDArray();
237 ret.Add(DefaultAnimation.PackUpdateMessage());
238 ret.Add(ImplicitDefaultAnimation.PackUpdateMessage());
239
240 foreach (OpenSim.Framework.Animation anim in m_animations)
241 ret.Add(anim.PackUpdateMessage());
242
243 return ret;
244 }
245
246 public void FromOSDArray(OSDArray pArray)
247 {
248 this.Clear();
249
250 if (pArray.Count >= 1)
251 {
252 m_defaultAnimation = new OpenSim.Framework.Animation((OSDMap)pArray[0]);
253 }
254 if (pArray.Count >= 2)
255 {
256 m_implicitDefaultAnimation = new OpenSim.Framework.Animation((OSDMap)pArray[1]);
257 }
258 for (int ii = 2; ii < pArray.Count; ii++)
259 {
260 m_animations.Add(new OpenSim.Framework.Animation((OSDMap)pArray[ii]));
261 }
262 }
263
264 // Compare two AnimationSets and return 'true' if the default animations are the same
265 // and all of the animations in the list are equal.
266 public override bool Equals(object obj)
267 {
268 AnimationSet other = obj as AnimationSet;
269 if (other != null)
270 {
271 if (this.DefaultAnimation.Equals(other.DefaultAnimation)
272 && this.ImplicitDefaultAnimation.Equals(other.ImplicitDefaultAnimation))
273 {
274 // The defaults are the same. Is the list of animations the same?
275 OpenSim.Framework.Animation[] thisAnims = this.ToArray();
276 OpenSim.Framework.Animation[] otherAnims = other.ToArray();
277 if (thisAnims.Length == 0 && otherAnims.Length == 0)
278 return true; // the common case
279 if (thisAnims.Length == otherAnims.Length)
280 {
281 // Do this the hard way but since the list is usually short this won't take long.
282 foreach (OpenSim.Framework.Animation thisAnim in thisAnims)
283 {
284 bool found = false;
285 foreach (OpenSim.Framework.Animation otherAnim in otherAnims)
286 {
287 if (thisAnim.Equals(otherAnim))
288 {
289 found = true;
290 break;
291 }
292 }
293 if (!found)
294 {
295 // If anything is not in the other list, these are not equal
296 return false;
297 }
298 }
299 // Found everything in the other list. Since lists are equal length, they must be equal.
300 return true;
301 }
302 }
303 return false;
304 }
305 // Don't know what was passed, but the base system will figure it out for me.
306 return base.Equals(obj);
307 }
308
309 public override int GetHashCode()
310 {
311 return base.GetHashCode();
312 }
313
314 public override string ToString()
315 {
316 StringBuilder buff = new StringBuilder();
317 buff.Append("dflt=");
318 buff.Append(DefaultAnimation.ToString());
319 buff.Append(",iDflt=");
320 if (DefaultAnimation.Equals(ImplicitDefaultAnimation))
321 buff.Append("same");
322 else
323 buff.Append(ImplicitDefaultAnimation.ToString());
324 if (m_animations.Count > 0)
325 {
326 buff.Append(",anims=");
327 bool firstTime = true;
328 foreach (OpenSim.Framework.Animation anim in m_animations)
329 {
330 if (!firstTime)
331 buff.Append(",");
332 buff.Append("<");
333 buff.Append(anim.ToString());
334 buff.Append(">");
335 firstTime = false;
336 }
337 }
338 return buff.ToString();
339 }
221 } 340 }
222} 341}
diff --git a/OpenSim/Region/Framework/Scenes/Animation/BinBVHAnimation.cs b/OpenSim/Region/Framework/Scenes/Animation/BinBVHAnimation.cs
index 3afc87f..b3b38b2 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/BinBVHAnimation.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/BinBVHAnimation.cs
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
@@ -113,31 +113,34 @@ namespace OpenSim.Region.Framework.Scenes.Animation
113 113
114 public byte[] ToBytes() 114 public byte[] ToBytes()
115 { 115 {
116 byte[] outputbytes = new byte[0]; 116 byte[] outputbytes;
117 117
118 BinaryWriter iostream = new BinaryWriter(new MemoryStream()); 118 using (MemoryStream ms = new MemoryStream())
119 iostream.Write(BinBVHUtil.ES(Utils.UInt16ToBytes(unknown0))); 119 using (BinaryWriter iostream = new BinaryWriter(ms))
120 iostream.Write(BinBVHUtil.ES(Utils.UInt16ToBytes(unknown1)));
121 iostream.Write(BinBVHUtil.ES(Utils.IntToBytes(Priority)));
122 iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(Length)));
123 iostream.Write(BinBVHUtil.WriteNullTerminatedString(ExpressionName));
124 iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(InPoint)));
125 iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(OutPoint)));
126 iostream.Write(BinBVHUtil.ES(Utils.IntToBytes(Loop ? 1 : 0)));
127 iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(EaseInTime)));
128 iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(EaseOutTime)));
129 iostream.Write(BinBVHUtil.ES(Utils.UIntToBytes(HandPose)));
130 iostream.Write(BinBVHUtil.ES(Utils.UIntToBytes((uint)(Joints.Length))));
131
132 for (int i = 0; i < Joints.Length; i++)
133 { 120 {
134 Joints[i].WriteBytesToStream(iostream, InPoint, OutPoint); 121 iostream.Write(BinBVHUtil.ES(Utils.UInt16ToBytes(unknown0)));
122 iostream.Write(BinBVHUtil.ES(Utils.UInt16ToBytes(unknown1)));
123 iostream.Write(BinBVHUtil.ES(Utils.IntToBytes(Priority)));
124 iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(Length)));
125 iostream.Write(BinBVHUtil.WriteNullTerminatedString(ExpressionName));
126 iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(InPoint)));
127 iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(OutPoint)));
128 iostream.Write(BinBVHUtil.ES(Utils.IntToBytes(Loop ? 1 : 0)));
129 iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(EaseInTime)));
130 iostream.Write(BinBVHUtil.ES(Utils.FloatToBytes(EaseOutTime)));
131 iostream.Write(BinBVHUtil.ES(Utils.UIntToBytes(HandPose)));
132 iostream.Write(BinBVHUtil.ES(Utils.UIntToBytes((uint)(Joints.Length))));
133
134 for (int i = 0; i < Joints.Length; i++)
135 {
136 Joints[i].WriteBytesToStream(iostream, InPoint, OutPoint);
137 }
138 iostream.Write(BinBVHUtil.ES(Utils.IntToBytes(0)));
139
140 using (MemoryStream ms2 = (MemoryStream)iostream.BaseStream)
141 outputbytes = ms2.ToArray();
135 } 142 }
136 iostream.Write(BinBVHUtil.ES(Utils.IntToBytes(0))); 143
137 MemoryStream ms = (MemoryStream)iostream.BaseStream;
138 outputbytes = ms.ToArray();
139 ms.Close();
140 iostream.Close();
141 return outputbytes; 144 return outputbytes;
142 } 145 }
143 146
diff --git a/OpenSim/Region/Framework/Scenes/Animation/DefaultAvatarAnimations.cs b/OpenSim/Region/Framework/Scenes/Animation/DefaultAvatarAnimations.cs
index c2b0468..b79dd8f 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/DefaultAvatarAnimations.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/DefaultAvatarAnimations.cs
@@ -104,5 +104,31 @@ namespace OpenSim.Region.Framework.Scenes.Animation
104 104
105 return UUID.Zero; 105 return UUID.Zero;
106 } 106 }
107
108 /// <summary>
109 /// Get the name of the animation given a UUID. If there is no matching animation
110 /// return the UUID as a string.
111 /// </summary>
112 public static string GetDefaultAnimationName(UUID uuid)
113 {
114 string ret = "unknown";
115 if (AnimsUUID.ContainsValue(uuid))
116 {
117 foreach (KeyValuePair<string, UUID> kvp in AnimsUUID)
118 {
119 if (kvp.Value == uuid)
120 {
121 ret = kvp.Key;
122 break;
123 }
124 }
125 }
126 else
127 {
128 ret = uuid.ToString();
129 }
130
131 return ret;
132 }
107 } 133 }
108} \ No newline at end of file 134} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
index e92a087..6d51029 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
@@ -35,7 +35,7 @@ using OpenMetaverse;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
38using OpenSim.Region.Physics.Manager; 38using OpenSim.Region.PhysicsModules.SharedBase;
39 39
40namespace OpenSim.Region.Framework.Scenes.Animation 40namespace OpenSim.Region.Framework.Scenes.Animation
41{ 41{
@@ -92,7 +92,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation
92 GetAnimName(animID), animID, m_scenePresence.Name); 92 GetAnimName(animID), animID, m_scenePresence.Name);
93 93
94 if (m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, objectID)) 94 if (m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, objectID))
95 {
95 SendAnimPack(); 96 SendAnimPack();
97 m_scenePresence.TriggerScenePresenceUpdated();
98 }
96 } 99 }
97 100
98 // Called from scripts 101 // Called from scripts
@@ -131,7 +134,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation
131 GetAnimName(animID), animID, m_scenePresence.Name); 134 GetAnimName(animID), animID, m_scenePresence.Name);
132 135
133 if (m_animations.Remove(animID, allowNoDefault)) 136 if (m_animations.Remove(animID, allowNoDefault))
137 {
134 SendAnimPack(); 138 SendAnimPack();
139 m_scenePresence.TriggerScenePresenceUpdated();
140 }
135 } 141 }
136 142
137 // Called from scripts 143 // Called from scripts
@@ -163,8 +169,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation
163 /// The movement animation is reserved for "main" animations 169 /// The movement animation is reserved for "main" animations
164 /// that are mutually exclusive, e.g. flying and sitting. 170 /// that are mutually exclusive, e.g. flying and sitting.
165 /// </summary> 171 /// </summary>
166 public void TrySetMovementAnimation(string anim) 172 /// <returns>'true' if the animation was updated</returns>
173 public bool TrySetMovementAnimation(string anim)
167 { 174 {
175 bool ret = false;
168 if (!m_scenePresence.IsChildAgent) 176 if (!m_scenePresence.IsChildAgent)
169 { 177 {
170// m_log.DebugFormat( 178// m_log.DebugFormat(
@@ -181,6 +189,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
181 // 16384 is CHANGED_ANIMATION 189 // 16384 is CHANGED_ANIMATION
182 m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { (int)Changed.ANIMATION}); 190 m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { (int)Changed.ANIMATION});
183 SendAnimPack(); 191 SendAnimPack();
192 ret = true;
184 } 193 }
185 } 194 }
186 else 195 else
@@ -189,6 +198,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
189 "[SCENE PRESENCE ANIMATOR]: Tried to set movement animation {0} on child presence {1}", 198 "[SCENE PRESENCE ANIMATOR]: Tried to set movement animation {0} on child presence {1}",
190 anim, m_scenePresence.Name); 199 anim, m_scenePresence.Name);
191 } 200 }
201 return ret;
192 } 202 }
193 203
194 /// <summary> 204 /// <summary>
@@ -393,11 +403,18 @@ namespace OpenSim.Region.Framework.Scenes.Animation
393 Falling = false; 403 Falling = false;
394 // Walking / crouchwalking / running 404 // Walking / crouchwalking / running
395 if (move.Z < 0f) 405 if (move.Z < 0f)
406 {
396 return "CROUCHWALK"; 407 return "CROUCHWALK";
397 else if (m_scenePresence.SetAlwaysRun) 408 }
398 return "RUN"; 409 // We need to prevent these animations if the user tries to make their avatar walk or run whilst
399 else 410 // specifying AGENT_CONTROL_STOP (pressing down space on viewers).
400 return "WALK"; 411 else if (!m_scenePresence.AgentControlStopActive)
412 {
413 if (m_scenePresence.SetAlwaysRun)
414 return "RUN";
415 else
416 return "WALK";
417 }
401 } 418 }
402 else if (!m_jumping) 419 else if (!m_jumping)
403 { 420 {
@@ -422,8 +439,12 @@ namespace OpenSim.Region.Framework.Scenes.Animation
422 /// <summary> 439 /// <summary>
423 /// Update the movement animation of this avatar according to its current state 440 /// Update the movement animation of this avatar according to its current state
424 /// </summary> 441 /// </summary>
425 public void UpdateMovementAnimations() 442 /// <returns>'true' if the animation was changed</returns>
443 public bool UpdateMovementAnimations()
426 { 444 {
445// m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Updating movement animations for {0}", m_scenePresence.Name);
446
447 bool ret = false;
427 lock (m_animations) 448 lock (m_animations)
428 { 449 {
429 string newMovementAnimation = DetermineMovementAnimation(); 450 string newMovementAnimation = DetermineMovementAnimation();
@@ -437,9 +458,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation
437 458
438 // Only set it if it's actually changed, give a script 459 // Only set it if it's actually changed, give a script
439 // a chance to stop a default animation 460 // a chance to stop a default animation
440 TrySetMovementAnimation(CurrentMovementAnimation); 461 ret = TrySetMovementAnimation(CurrentMovementAnimation);
441 } 462 }
442 } 463 }
464 return ret;
443 } 465 }
444 466
445 public UUID[] GetAnimationArray() 467 public UUID[] GetAnimationArray()