diff options
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Framework/Animation.cs | 20 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs | 110 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Animation/DefaultAvatarAnimations.cs | 26 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | 17 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/EventManager.cs | 23 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 8 |
7 files changed, 202 insertions, 4 deletions
diff --git a/OpenSim/Framework/Animation.cs b/OpenSim/Framework/Animation.cs index 232f5a1..8bdf8f4 100644 --- a/OpenSim/Framework/Animation.cs +++ b/OpenSim/Framework/Animation.cs | |||
@@ -120,5 +120,25 @@ namespace OpenSim.Framework | |||
120 | sequenceNum = args["seq_num"].AsInteger(); | 120 | sequenceNum = args["seq_num"].AsInteger(); |
121 | } | 121 | } |
122 | 122 | ||
123 | public override bool Equals(object obj) | ||
124 | { | ||
125 | Animation other = obj as Animation; | ||
126 | if (other != null) | ||
127 | { | ||
128 | return (other.AnimID == this.AnimID | ||
129 | && other.SequenceNum == this.SequenceNum | ||
130 | && other.ObjectID == this.ObjectID); | ||
131 | } | ||
132 | |||
133 | return base.Equals(obj); | ||
134 | } | ||
135 | |||
136 | public override string ToString() | ||
137 | { | ||
138 | return "AnimID=" + AnimID.ToString() | ||
139 | + "/seq=" + SequenceNum.ToString() | ||
140 | + "/objID=" + ObjectID.ToString(); | ||
141 | } | ||
142 | |||
123 | } | 143 | } |
124 | } | 144 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs index 66edfed..5dee64d 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs | |||
@@ -28,8 +28,11 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Text; | ||
31 | using log4net; | 32 | using log4net; |
32 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using OpenMetaverse.StructuredData; | ||
35 | |||
33 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
34 | 37 | ||
35 | using Animation = OpenSim.Framework.Animation; | 38 | using 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,106 @@ 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 string ToString() | ||
310 | { | ||
311 | StringBuilder buff = new StringBuilder(); | ||
312 | buff.Append("dflt="); | ||
313 | buff.Append(DefaultAnimation.ToString()); | ||
314 | buff.Append(",iDflt="); | ||
315 | if (DefaultAnimation == ImplicitDefaultAnimation) | ||
316 | buff.Append("same"); | ||
317 | else | ||
318 | buff.Append(ImplicitDefaultAnimation.ToString()); | ||
319 | if (m_animations.Count > 0) | ||
320 | { | ||
321 | buff.Append(",anims="); | ||
322 | foreach (OpenSim.Framework.Animation anim in m_animations) | ||
323 | { | ||
324 | buff.Append("<"); | ||
325 | buff.Append(anim.ToString()); | ||
326 | buff.Append(">,"); | ||
327 | } | ||
328 | } | ||
329 | return buff.ToString(); | ||
330 | } | ||
221 | } | 331 | } |
222 | } | 332 | } |
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..a701a79 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | |||
@@ -92,7 +92,9 @@ 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 | } | ||
96 | } | 98 | } |
97 | 99 | ||
98 | // Called from scripts | 100 | // Called from scripts |
@@ -131,7 +133,9 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
131 | GetAnimName(animID), animID, m_scenePresence.Name); | 133 | GetAnimName(animID), animID, m_scenePresence.Name); |
132 | 134 | ||
133 | if (m_animations.Remove(animID, allowNoDefault)) | 135 | if (m_animations.Remove(animID, allowNoDefault)) |
136 | { | ||
134 | SendAnimPack(); | 137 | SendAnimPack(); |
138 | } | ||
135 | } | 139 | } |
136 | 140 | ||
137 | // Called from scripts | 141 | // Called from scripts |
@@ -163,8 +167,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
163 | /// The movement animation is reserved for "main" animations | 167 | /// The movement animation is reserved for "main" animations |
164 | /// that are mutually exclusive, e.g. flying and sitting. | 168 | /// that are mutually exclusive, e.g. flying and sitting. |
165 | /// </summary> | 169 | /// </summary> |
166 | public void TrySetMovementAnimation(string anim) | 170 | /// <returns>'true' if the animation was updated</returns> |
171 | public bool TrySetMovementAnimation(string anim) | ||
167 | { | 172 | { |
173 | bool ret = false; | ||
168 | if (!m_scenePresence.IsChildAgent) | 174 | if (!m_scenePresence.IsChildAgent) |
169 | { | 175 | { |
170 | // m_log.DebugFormat( | 176 | // m_log.DebugFormat( |
@@ -181,6 +187,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
181 | // 16384 is CHANGED_ANIMATION | 187 | // 16384 is CHANGED_ANIMATION |
182 | m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { (int)Changed.ANIMATION}); | 188 | m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { (int)Changed.ANIMATION}); |
183 | SendAnimPack(); | 189 | SendAnimPack(); |
190 | ret = true; | ||
184 | } | 191 | } |
185 | } | 192 | } |
186 | else | 193 | else |
@@ -189,6 +196,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
189 | "[SCENE PRESENCE ANIMATOR]: Tried to set movement animation {0} on child presence {1}", | 196 | "[SCENE PRESENCE ANIMATOR]: Tried to set movement animation {0} on child presence {1}", |
190 | anim, m_scenePresence.Name); | 197 | anim, m_scenePresence.Name); |
191 | } | 198 | } |
199 | return ret; | ||
192 | } | 200 | } |
193 | 201 | ||
194 | /// <summary> | 202 | /// <summary> |
@@ -422,8 +430,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
422 | /// <summary> | 430 | /// <summary> |
423 | /// Update the movement animation of this avatar according to its current state | 431 | /// Update the movement animation of this avatar according to its current state |
424 | /// </summary> | 432 | /// </summary> |
425 | public void UpdateMovementAnimations() | 433 | /// <returns>'true' if the animation was changed</returns> |
434 | public bool UpdateMovementAnimations() | ||
426 | { | 435 | { |
436 | bool ret = false; | ||
427 | lock (m_animations) | 437 | lock (m_animations) |
428 | { | 438 | { |
429 | string newMovementAnimation = DetermineMovementAnimation(); | 439 | string newMovementAnimation = DetermineMovementAnimation(); |
@@ -437,9 +447,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
437 | 447 | ||
438 | // Only set it if it's actually changed, give a script | 448 | // Only set it if it's actually changed, give a script |
439 | // a chance to stop a default animation | 449 | // a chance to stop a default animation |
440 | TrySetMovementAnimation(CurrentMovementAnimation); | 450 | ret = TrySetMovementAnimation(CurrentMovementAnimation); |
441 | } | 451 | } |
442 | } | 452 | } |
453 | return ret; | ||
443 | } | 454 | } |
444 | 455 | ||
445 | public UUID[] GetAnimationArray() | 456 | public UUID[] GetAnimationArray() |
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 59d0148..a246319 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs | |||
@@ -969,6 +969,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
969 | public delegate void RegionStarted(Scene scene); | 969 | public delegate void RegionStarted(Scene scene); |
970 | public event RegionStarted OnRegionStarted; | 970 | public event RegionStarted OnRegionStarted; |
971 | 971 | ||
972 | public delegate void RegionHeartbeatStart(Scene scene); | ||
973 | public event RegionHeartbeatStart OnRegionHeartbeatStart; | ||
972 | public delegate void RegionHeartbeatEnd(Scene scene); | 974 | public delegate void RegionHeartbeatEnd(Scene scene); |
973 | public event RegionHeartbeatEnd OnRegionHeartbeatEnd; | 975 | public event RegionHeartbeatEnd OnRegionHeartbeatEnd; |
974 | 976 | ||
@@ -3068,6 +3070,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
3068 | } | 3070 | } |
3069 | } | 3071 | } |
3070 | 3072 | ||
3073 | public void TriggerRegionHeartbeatStart(Scene scene) | ||
3074 | { | ||
3075 | RegionHeartbeatStart handler = OnRegionHeartbeatStart; | ||
3076 | |||
3077 | if (handler != null) | ||
3078 | { | ||
3079 | foreach (RegionHeartbeatStart d in handler.GetInvocationList()) | ||
3080 | { | ||
3081 | try | ||
3082 | { | ||
3083 | d(scene); | ||
3084 | } | ||
3085 | catch (Exception e) | ||
3086 | { | ||
3087 | m_log.ErrorFormat("[EVENT MANAGER]: Delegate for OnRegionHeartbeatStart failed - continuing {0} - {1}", | ||
3088 | e.Message, e.StackTrace); | ||
3089 | } | ||
3090 | } | ||
3091 | } | ||
3092 | } | ||
3093 | |||
3071 | public void TriggerRegionHeartbeatEnd(Scene scene) | 3094 | public void TriggerRegionHeartbeatEnd(Scene scene) |
3072 | { | 3095 | { |
3073 | RegionHeartbeatEnd handler = OnRegionHeartbeatEnd; | 3096 | RegionHeartbeatEnd handler = OnRegionHeartbeatEnd; |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 5dea634..0743ce7 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -1517,6 +1517,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1517 | 1517 | ||
1518 | try | 1518 | try |
1519 | { | 1519 | { |
1520 | EventManager.TriggerRegionHeartbeatStart(this); | ||
1521 | |||
1520 | // Apply taints in terrain module to terrain in physics scene | 1522 | // Apply taints in terrain module to terrain in physics scene |
1521 | if (Frame % m_update_terrain == 0) | 1523 | if (Frame % m_update_terrain == 0) |
1522 | { | 1524 | { |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index e8aa52e..b8ff7f7 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -2039,6 +2039,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2039 | } | 2039 | } |
2040 | 2040 | ||
2041 | Animator.TrySetMovementAnimation("STAND"); | 2041 | Animator.TrySetMovementAnimation("STAND"); |
2042 | TriggerScenePresenceUpdated(); | ||
2042 | } | 2043 | } |
2043 | 2044 | ||
2044 | private SceneObjectPart FindNextAvailableSitTarget(UUID targetID) | 2045 | private SceneObjectPart FindNextAvailableSitTarget(UUID targetID) |
@@ -2432,6 +2433,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2432 | } | 2433 | } |
2433 | Animator.TrySetMovementAnimation(sitAnimation); | 2434 | Animator.TrySetMovementAnimation(sitAnimation); |
2434 | SendAvatarDataToAllAgents(); | 2435 | SendAvatarDataToAllAgents(); |
2436 | TriggerScenePresenceUpdated(); | ||
2435 | } | 2437 | } |
2436 | } | 2438 | } |
2437 | 2439 | ||
@@ -2440,6 +2442,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2440 | // m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick.. | 2442 | // m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick.. |
2441 | m_AngularVelocity = Vector3.Zero; | 2443 | m_AngularVelocity = Vector3.Zero; |
2442 | Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); | 2444 | Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); |
2445 | TriggerScenePresenceUpdated(); | ||
2443 | SitGround = true; | 2446 | SitGround = true; |
2444 | RemoveFromPhysicalScene(); | 2447 | RemoveFromPhysicalScene(); |
2445 | } | 2448 | } |
@@ -2456,11 +2459,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2456 | public void HandleStartAnim(IClientAPI remoteClient, UUID animID) | 2459 | public void HandleStartAnim(IClientAPI remoteClient, UUID animID) |
2457 | { | 2460 | { |
2458 | Animator.AddAnimation(animID, UUID.Zero); | 2461 | Animator.AddAnimation(animID, UUID.Zero); |
2462 | TriggerScenePresenceUpdated(); | ||
2459 | } | 2463 | } |
2460 | 2464 | ||
2461 | public void HandleStopAnim(IClientAPI remoteClient, UUID animID) | 2465 | public void HandleStopAnim(IClientAPI remoteClient, UUID animID) |
2462 | { | 2466 | { |
2463 | Animator.RemoveAnimation(animID, false); | 2467 | Animator.RemoveAnimation(animID, false); |
2468 | TriggerScenePresenceUpdated(); | ||
2464 | } | 2469 | } |
2465 | 2470 | ||
2466 | /// <summary> | 2471 | /// <summary> |
@@ -3465,7 +3470,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3465 | 3470 | ||
3466 | // if (m_updateCount > 0) | 3471 | // if (m_updateCount > 0) |
3467 | // { | 3472 | // { |
3468 | Animator.UpdateMovementAnimations(); | 3473 | if (Animator.UpdateMovementAnimations()) |
3474 | TriggerScenePresenceUpdated(); | ||
3469 | // m_updateCount--; | 3475 | // m_updateCount--; |
3470 | // } | 3476 | // } |
3471 | 3477 | ||