mirror of
https://github.com/opensim/opensim.git
synced 2026-08-07 17:55:48 +08:00
Merge branch 'master' into careminster
Conflicts: OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
This commit is contained in:
@@ -28,8 +28,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
|
||||
using OpenSim.Framework;
|
||||
|
||||
using Animation = OpenSim.Framework.Animation;
|
||||
@@ -60,6 +63,12 @@ namespace OpenSim.Region.Framework.Scenes.Animation
|
||||
ResetDefaultAnimation();
|
||||
}
|
||||
|
||||
public AnimationSet(OSDArray pArray)
|
||||
{
|
||||
ResetDefaultAnimation();
|
||||
FromOSDArray(pArray);
|
||||
}
|
||||
|
||||
public bool HasAnimation(UUID animID)
|
||||
{
|
||||
if (m_defaultAnimation.AnimID == animID)
|
||||
@@ -218,5 +227,106 @@ namespace OpenSim.Region.Framework.Scenes.Animation
|
||||
foreach (OpenSim.Framework.Animation anim in theArray)
|
||||
m_animations.Add(anim);
|
||||
}
|
||||
|
||||
// Create representation of this AnimationSet as an OSDArray.
|
||||
// First two entries in the array are the default and implicitDefault animations
|
||||
// followed by the other animations.
|
||||
public OSDArray ToOSDArray()
|
||||
{
|
||||
OSDArray ret = new OSDArray();
|
||||
ret.Add(DefaultAnimation.PackUpdateMessage());
|
||||
ret.Add(ImplicitDefaultAnimation.PackUpdateMessage());
|
||||
|
||||
foreach (OpenSim.Framework.Animation anim in m_animations)
|
||||
ret.Add(anim.PackUpdateMessage());
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void FromOSDArray(OSDArray pArray)
|
||||
{
|
||||
this.Clear();
|
||||
|
||||
if (pArray.Count >= 1)
|
||||
{
|
||||
m_defaultAnimation = new OpenSim.Framework.Animation((OSDMap)pArray[0]);
|
||||
}
|
||||
if (pArray.Count >= 2)
|
||||
{
|
||||
m_implicitDefaultAnimation = new OpenSim.Framework.Animation((OSDMap)pArray[1]);
|
||||
}
|
||||
for (int ii = 2; ii < pArray.Count; ii++)
|
||||
{
|
||||
m_animations.Add(new OpenSim.Framework.Animation((OSDMap)pArray[ii]));
|
||||
}
|
||||
}
|
||||
|
||||
// Compare two AnimationSets and return 'true' if the default animations are the same
|
||||
// and all of the animations in the list are equal.
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
AnimationSet other = obj as AnimationSet;
|
||||
if (other != null)
|
||||
{
|
||||
if (this.DefaultAnimation.Equals(other.DefaultAnimation)
|
||||
&& this.ImplicitDefaultAnimation.Equals(other.ImplicitDefaultAnimation))
|
||||
{
|
||||
// The defaults are the same. Is the list of animations the same?
|
||||
OpenSim.Framework.Animation[] thisAnims = this.ToArray();
|
||||
OpenSim.Framework.Animation[] otherAnims = other.ToArray();
|
||||
if (thisAnims.Length == 0 && otherAnims.Length == 0)
|
||||
return true; // the common case
|
||||
if (thisAnims.Length == otherAnims.Length)
|
||||
{
|
||||
// Do this the hard way but since the list is usually short this won't take long.
|
||||
foreach (OpenSim.Framework.Animation thisAnim in thisAnims)
|
||||
{
|
||||
bool found = false;
|
||||
foreach (OpenSim.Framework.Animation otherAnim in otherAnims)
|
||||
{
|
||||
if (thisAnim.Equals(otherAnim))
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
// If anything is not in the other list, these are not equal
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Found everything in the other list. Since lists are equal length, they must be equal.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Don't know what was passed, but the base system will figure it out for me.
|
||||
return base.Equals(obj);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder buff = new StringBuilder();
|
||||
buff.Append("dflt=");
|
||||
buff.Append(DefaultAnimation.ToString());
|
||||
buff.Append(",iDflt=");
|
||||
if (DefaultAnimation == ImplicitDefaultAnimation)
|
||||
buff.Append("same");
|
||||
else
|
||||
buff.Append(ImplicitDefaultAnimation.ToString());
|
||||
if (m_animations.Count > 0)
|
||||
{
|
||||
buff.Append(",anims=");
|
||||
foreach (OpenSim.Framework.Animation anim in m_animations)
|
||||
{
|
||||
buff.Append("<");
|
||||
buff.Append(anim.ToString());
|
||||
buff.Append(">,");
|
||||
}
|
||||
}
|
||||
return buff.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,5 +104,31 @@ namespace OpenSim.Region.Framework.Scenes.Animation
|
||||
|
||||
return UUID.Zero;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the name of the animation given a UUID. If there is no matching animation
|
||||
/// return the UUID as a string.
|
||||
/// </summary>
|
||||
public static string GetDefaultAnimationName(UUID uuid)
|
||||
{
|
||||
string ret = "unknown";
|
||||
if (AnimsUUID.ContainsValue(uuid))
|
||||
{
|
||||
foreach (KeyValuePair<string, UUID> kvp in AnimsUUID)
|
||||
{
|
||||
if (kvp.Value == uuid)
|
||||
{
|
||||
ret = kvp.Key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = uuid.ToString();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,7 +93,9 @@ namespace OpenSim.Region.Framework.Scenes.Animation
|
||||
GetAnimName(animID), animID, m_scenePresence.Name);
|
||||
|
||||
if (m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, objectID))
|
||||
{
|
||||
SendAnimPack();
|
||||
}
|
||||
}
|
||||
|
||||
// Called from scripts
|
||||
@@ -132,7 +134,9 @@ namespace OpenSim.Region.Framework.Scenes.Animation
|
||||
GetAnimName(animID), animID, m_scenePresence.Name);
|
||||
|
||||
if (m_animations.Remove(animID, allowNoDefault))
|
||||
{
|
||||
SendAnimPack();
|
||||
}
|
||||
}
|
||||
|
||||
public void avnChangeAnim(UUID animID, bool addRemove, bool sendPack)
|
||||
@@ -180,8 +184,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation
|
||||
/// The movement animation is reserved for "main" animations
|
||||
/// that are mutually exclusive, e.g. flying and sitting.
|
||||
/// </summary>
|
||||
public void TrySetMovementAnimation(string anim)
|
||||
/// <returns>'true' if the animation was updated</returns>
|
||||
public bool TrySetMovementAnimation(string anim)
|
||||
{
|
||||
bool ret = false;
|
||||
if (!m_scenePresence.IsChildAgent)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
@@ -198,6 +204,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
|
||||
// 16384 is CHANGED_ANIMATION
|
||||
m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { (int)Changed.ANIMATION});
|
||||
SendAnimPack();
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -206,6 +213,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
|
||||
"[SCENE PRESENCE ANIMATOR]: Tried to set movement animation {0} on child presence {1}",
|
||||
anim, m_scenePresence.Name);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -439,8 +447,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation
|
||||
/// <summary>
|
||||
/// Update the movement animation of this avatar according to its current state
|
||||
/// </summary>
|
||||
public void UpdateMovementAnimations()
|
||||
/// <returns>'true' if the animation was changed</returns>
|
||||
public bool UpdateMovementAnimations()
|
||||
{
|
||||
bool ret = false;
|
||||
lock (m_animations)
|
||||
{
|
||||
string newMovementAnimation = DetermineMovementAnimation();
|
||||
@@ -454,9 +464,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation
|
||||
|
||||
// Only set it if it's actually changed, give a script
|
||||
// a chance to stop a default animation
|
||||
TrySetMovementAnimation(CurrentMovementAnimation);
|
||||
ret = TrySetMovementAnimation(CurrentMovementAnimation);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public UUID[] GetAnimationArray()
|
||||
|
||||
Reference in New Issue
Block a user