From 1a8769e6eff0eab750a528f27d127637edbd292b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 21 Mar 2012 23:57:39 +0000 Subject: Instead of loading default avatar animations in both SLUtil and AvatarAnimations, load just in AvatarAnimations instead. This lets us remove the dependency of OpenSim.Framework.dll on data/avataranimations.xml, which is not necessary for ROBUST. This commit also takes care of the odd situation where animations are stored and used internally with uppercase names (e.g. "STAND") but scripts refer to them with lowercase names (e.g. "sit"). --- OpenSim/Framework/IClientAPI.cs | 3 +- OpenSim/Framework/SLUtil.cs | 50 +------------ .../Region/ClientStack/Linden/UDP/LLClientView.cs | 7 +- .../Framework/Scenes/Animation/AnimationSet.cs | 14 ++-- .../Framework/Scenes/Animation/AvatarAnimations.cs | 81 +++++++++++++++++----- .../Scenes/Animation/ScenePresenceAnimator.cs | 8 ++- .../Server/IRCClientView.cs | 5 -- .../Region/OptionalModules/World/NPC/NPCAvatar.cs | 5 -- .../Shared/Api/Implementation/LSL_Api.cs | 6 +- OpenSim/Tests/Common/Mock/TestClient.cs | 5 -- 10 files changed, 85 insertions(+), 99 deletions(-) diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index c85e599..3f560d0 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -1215,10 +1215,9 @@ namespace OpenSim.Framework /// The orbital position is given in radians, and must be "adjusted" for the linden client, see LLClientView void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong CurrentTime, uint SecondsPerSunCycle, uint SecondsPerYear, float OrbitalPosition); - + void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks); void SendViewerTime(int phase); - UUID GetDefaultAnimation(string name); void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] charterMember, string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL, UUID partnerID); diff --git a/OpenSim/Framework/SLUtil.cs b/OpenSim/Framework/SLUtil.cs index f9cb851..db4541e 100644 --- a/OpenSim/Framework/SLUtil.cs +++ b/OpenSim/Framework/SLUtil.cs @@ -27,6 +27,7 @@ using System; using System.Collections.Generic; +using System.IO; using System.Reflection; using System.Xml; using log4net; @@ -40,13 +41,6 @@ namespace OpenSim.Framework #region SL / file extension / content-type conversions - public static Dictionary DefaultAvatarAnimations = new Dictionary(); - - static SLUtil() - { - DefaultAvatarAnimations = LoadDefaultAvatarAnimations("data/avataranimations.xml"); - } - public static string SLAssetTypeToContentType(int assetType) { switch ((AssetType)assetType) @@ -382,47 +376,5 @@ namespace OpenSim.Framework return output; } - - /// - /// Load the default SL avatar animations. - /// - /// - public static Dictionary LoadDefaultAvatarAnimations(string path) - { - Dictionary animations = new Dictionary(); - - using (XmlTextReader reader = new XmlTextReader(path)) - { - XmlDocument doc = new XmlDocument(); - doc.Load(reader); - if (doc.DocumentElement != null) - { - foreach (XmlNode nod in doc.DocumentElement.ChildNodes) - { - if (nod.Attributes["name"] != null) - { - string name = nod.Attributes["name"].Value.ToLower(); - string id = nod.InnerText; - animations.Add(name, (UUID)id); - } - } - } - } - - return animations; - } - - /// - /// Get the default SL avatar animation with the given name. - /// - /// - /// - public static UUID GetDefaultAvatarAnimation(string name) - { - if (DefaultAvatarAnimations.ContainsKey(name)) - return DefaultAvatarAnimations[name]; - - return UUID.Zero; - } } } \ No newline at end of file diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index b388b10..68aae14 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -11202,15 +11202,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP scriptQuestion.Data.Questions = question; scriptQuestion.Data.ObjectName = Util.StringToBytes256(taskName); scriptQuestion.Data.ObjectOwner = Util.StringToBytes256(ownerName); - + OutPacket(scriptQuestion, ThrottleOutPacketType.Task); } - public UUID GetDefaultAnimation(string name) - { - return SLUtil.GetDefaultAvatarAnimation(name); - } - /// /// Handler called when we receive a logout packet. /// diff --git a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs index 9176d3d..240a424 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs @@ -27,8 +27,10 @@ using System; using System.Collections.Generic; -using OpenSim.Framework; +using System.Reflection; +using log4net; using OpenMetaverse; +using OpenSim.Framework; using Animation = OpenSim.Framework.Animation; @@ -37,7 +39,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation [Serializable] public class AnimationSet { - public static AvatarAnimations Animations = new AvatarAnimations(); +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private OpenSim.Framework.Animation m_defaultAnimation = new OpenSim.Framework.Animation(); private List m_animations = new List(); @@ -132,9 +134,13 @@ namespace OpenSim.Region.Framework.Scenes.Animation /// public bool TrySetDefaultAnimation(string anim, int sequenceNum, UUID objectID) { - if (Animations.AnimsUUID.ContainsKey(anim)) +// m_log.DebugFormat( +// "[ANIMATION SET]: Setting default animation {0}, sequence number {1}, object id {2}", +// anim, sequenceNum, objectID); + + if (AvatarAnimations.AnimsUUID.ContainsKey(anim)) { - return SetDefaultAnimation(Animations.AnimsUUID[anim], sequenceNum, objectID); + return SetDefaultAnimation(AvatarAnimations.AnimsUUID[anim], sequenceNum, objectID); } return false; } diff --git a/OpenSim/Region/Framework/Scenes/Animation/AvatarAnimations.cs b/OpenSim/Region/Framework/Scenes/Animation/AvatarAnimations.cs index 659c3a5..ec928f4 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/AvatarAnimations.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/AvatarAnimations.cs @@ -26,38 +26,83 @@ */ using System.Collections.Generic; +using System.Reflection; using System.Xml; +using log4net; using OpenMetaverse; namespace OpenSim.Region.Framework.Scenes.Animation { public class AvatarAnimations { - public Dictionary AnimsUUID = new Dictionary(); - public Dictionary AnimsNames = new Dictionary(); - public Dictionary AnimStateNames = new Dictionary(); +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public AvatarAnimations() + public static readonly string DefaultAnimationsPath = "data/avataranimations.xml"; + + public static Dictionary AnimsUUID = new Dictionary(); + public static Dictionary AnimsNames = new Dictionary(); + public static Dictionary AnimStateNames = new Dictionary(); + + static AvatarAnimations() + { + LoadAnimations(DefaultAnimationsPath); + } + + /// + /// Load the default SL avatar animations. + /// + /// + private static void LoadAnimations(string path) { - using (XmlTextReader reader = new XmlTextReader("data/avataranimations.xml")) +// Dictionary animations = new Dictionary(); + + using (XmlTextReader reader = new XmlTextReader(path)) { XmlDocument doc = new XmlDocument(); doc.Load(reader); - foreach (XmlNode nod in doc.DocumentElement.ChildNodes) - { - if (nod.Attributes["name"] != null) +// if (doc.DocumentElement != null) +// { + foreach (XmlNode nod in doc.DocumentElement.ChildNodes) { - string name = (string)nod.Attributes["name"].Value; - UUID id = (UUID)nod.InnerText; - string animState = (string)nod.Attributes["state"].Value; - - AnimsUUID.Add(name, id); - AnimsNames.Add(id, name); - if (animState != "") - AnimStateNames.Add(id, animState); + if (nod.Attributes["name"] != null) + { + string name = nod.Attributes["name"].Value; + UUID id = (UUID)nod.InnerText; + string animState = (string)nod.Attributes["state"].Value; + + AnimsUUID.Add(name, id); + AnimsNames.Add(id, name); + if (animState != "") + AnimStateNames.Add(id, animState); + +// m_log.DebugFormat("[AVATAR ANIMATIONS]: Loaded {0} {1} {2}", id, name, animState); + } } - } +// } + } + +// return animations; + } + + /// + /// Get the default avatar animation with the given name. + /// + /// + /// + public static UUID GetDefaultAnimation(string name) + { +// m_log.DebugFormat( +// "[AVATAR ANIMATIONS]: Looking for default avatar animation with name {0}", name); + + if (AnimsUUID.ContainsKey(name)) + { +// m_log.DebugFormat( +// "[AVATAR ANIMATIONS]: Found {0} {1} in GetDefaultAvatarAnimation()", AnimsUUID[name], name); + + return AnimsUUID[name]; } + + return UUID.Zero; } } -} +} \ 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 3584cda..9038ebc 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -97,7 +97,9 @@ namespace OpenSim.Region.Framework.Scenes.Animation if (m_scenePresence.IsChildAgent) return; - UUID animID = m_scenePresence.ControllingClient.GetDefaultAnimation(name); + // XXX: For some reason, we store all animations and use them with upper case names, but in LSL animations + // are referenced with lower case names! + UUID animID = AvatarAnimations.GetDefaultAnimation(name.ToUpper()); if (animID == UUID.Zero) return; @@ -121,7 +123,9 @@ namespace OpenSim.Region.Framework.Scenes.Animation if (m_scenePresence.IsChildAgent) return; - UUID animID = m_scenePresence.ControllingClient.GetDefaultAnimation(name); + // XXX: For some reason, we store all animations and use them with upper case names, but in LSL animations + // are referenced with lower case names! + UUID animID = AvatarAnimations.GetDefaultAnimation(name); if (animID == UUID.Zero) return; diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index d3c96e2..5cf478a 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -1203,11 +1203,6 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server } - public UUID GetDefaultAnimation(string name) - { - return UUID.Zero; - } - public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, byte[] charterMember, string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL, UUID partnerID) { diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 24b9e6b..16ec34f 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -133,11 +133,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC } - public UUID GetDefaultAnimation(string name) - { - return SLUtil.GetDefaultAvatarAnimation(name); - } - public Vector3 Position { get { return m_scene.Entities[m_uuid].AbsolutePosition; } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index bb374ed..27f7c03 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4314,7 +4314,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (m_host.RegionHandle == presence.RegionHandle) { - Dictionary animationstateNames = AnimationSet.Animations.AnimStateNames; + Dictionary animationstateNames = AvatarAnimations.AnimStateNames; if (presence != null) { @@ -5600,7 +5600,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } if (agent.Animator.Animations.DefaultAnimation.AnimID - == AnimationSet.Animations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) + == AvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) { flags |= ScriptBaseClass.AGENT_SITTING; } @@ -7714,7 +7714,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSL_Vector lower; LSL_Vector upper; if (presence.Animator.Animations.DefaultAnimation.AnimID - == AnimationSet.Animations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) + == AvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) { // This is for ground sitting avatars float height = presence.Appearance.AvatarHeight / 2.66666667f; diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index 14c1287..455b51e 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -700,11 +700,6 @@ namespace OpenSim.Tests.Common.Mock { } - public UUID GetDefaultAnimation(string name) - { - return UUID.Zero; - } - public void SendTakeControls(int controls, bool passToAgent, bool TakeControls) { } -- cgit v1.1