mirror of
https://github.com/opensim/opensim.git
synced 2026-08-11 11:57:03 +08:00
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").
This commit is contained in:
@@ -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<OpenSim.Framework.Animation> m_animations = new List<OpenSim.Framework.Animation>();
|
||||
@@ -132,9 +134,13 @@ namespace OpenSim.Region.Framework.Scenes.Animation
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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<string, UUID> AnimsUUID = new Dictionary<string, UUID>();
|
||||
public Dictionary<UUID, string> AnimsNames = new Dictionary<UUID, string>();
|
||||
public Dictionary<UUID, string> AnimStateNames = new Dictionary<UUID, string>();
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public AvatarAnimations()
|
||||
public static readonly string DefaultAnimationsPath = "data/avataranimations.xml";
|
||||
|
||||
public static Dictionary<string, UUID> AnimsUUID = new Dictionary<string, UUID>();
|
||||
public static Dictionary<UUID, string> AnimsNames = new Dictionary<UUID, string>();
|
||||
public static Dictionary<UUID, string> AnimStateNames = new Dictionary<UUID, string>();
|
||||
|
||||
static AvatarAnimations()
|
||||
{
|
||||
using (XmlTextReader reader = new XmlTextReader("data/avataranimations.xml"))
|
||||
LoadAnimations(DefaultAnimationsPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load the default SL avatar animations.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private static void LoadAnimations(string path)
|
||||
{
|
||||
// Dictionary<string, UUID> animations = new Dictionary<string, UUID>();
|
||||
|
||||
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;
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the default avatar animation with the given name.
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user