Factor out common default animations code into SLUtil. LLClientView now makes use of the SLUtil copy via a method rather than each LLClientView loading a separate copy.

As per opensim-users mailing list discussion.
0.7.4.1
Justin Clark-Casey (justincc) 2012-03-09 23:57:24 +00:00
parent 5c5a493791
commit bdc968f1fc
4 changed files with 55 additions and 62 deletions

View File

@ -28,6 +28,7 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Xml;
using log4net;
using OpenMetaverse;
@ -39,6 +40,13 @@ namespace OpenSim.Framework
#region SL / file extension / content-type conversions
public static Dictionary<string, UUID> DefaultAvatarAnimations = new Dictionary<string, UUID>();
static SLUtil()
{
DefaultAvatarAnimations = LoadDefaultAvatarAnimations("data/avataranimations.xml");
}
public static string SLAssetTypeToContentType(int assetType)
{
switch ((AssetType)assetType)
@ -374,5 +382,47 @@ namespace OpenSim.Framework
return output;
}
/// <summary>
/// Load the default SL avatar animations.
/// </summary>
/// <returns></returns>
public static Dictionary<string, UUID> LoadDefaultAvatarAnimations(string path)
{
Dictionary<string, UUID> animations = new Dictionary<string, UUID>();
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;
}
/// <summary>
/// Get the default SL avatar animation with the given name.
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public static UUID GetDefaultAvatarAnimation(string name)
{
if (DefaultAvatarAnimations.ContainsKey(name))
return DefaultAvatarAnimations[name];
return UUID.Zero;
}
}
}
}

View File

@ -317,7 +317,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
protected readonly UUID m_agentId;
private readonly uint m_circuitCode;
private readonly byte[] m_channelVersion = Utils.EmptyBytes;
private readonly Dictionary<string, UUID> m_defaultAnimations = new Dictionary<string, UUID>();
private readonly IGroupsModule m_GroupsModule;
private int m_cachedTextureSerial;
@ -452,10 +451,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
RegisterInterface<IClientChat>(this);
RegisterInterface<IClientIPEndpoint>(this);
InitDefaultAnimations();
m_scene = scene;
m_entityUpdates = new PriorityQueue(m_scene.Entities.Count);
m_entityProps = new PriorityQueue(m_scene.Entities.Count);
m_fullUpdateDataBlocksBuilder = new List<ObjectUpdatePacket.ObjectDataBlock>();
@ -11210,30 +11206,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
OutPacket(scriptQuestion, ThrottleOutPacketType.Task);
}
private void InitDefaultAnimations()
{
using (XmlTextReader reader = new XmlTextReader("data/avataranimations.xml"))
{
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;
m_defaultAnimations.Add(name, (UUID)id);
}
}
}
}
public UUID GetDefaultAnimation(string name)
{
if (m_defaultAnimations.ContainsKey(name))
return m_defaultAnimations[name];
return UUID.Zero;
return SLUtil.GetDefaultAvatarAnimation(name);
}
/// <summary>

View File

@ -42,9 +42,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
{
public class NPCAvatar : IClientAPI, INPC
{
private static readonly Dictionary<string, UUID> m_defaultAnimations = new Dictionary<string, UUID>();
public bool SenseAsAgent { get; set; }
private readonly string m_firstname;
private readonly string m_lastname;
private readonly Vector3 m_startPos;
@ -61,16 +60,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
m_scene = scene;
m_ownerID = ownerID;
SenseAsAgent = senseAsAgent;
}
static NPCAvatar()
{
InitDefaultAnimations();
}
public IScene Scene
{
get { return m_scene; }
@ -142,32 +133,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC
}
private static void InitDefaultAnimations()
{
using (XmlTextReader reader = new XmlTextReader("data/avataranimations.xml"))
{
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;
m_defaultAnimations.Add(name, (UUID)id);
}
}
}
}
public UUID GetDefaultAnimation(string name)
{
if (m_defaultAnimations.ContainsKey(name))
{
return m_defaultAnimations[name];
}
return UUID.Zero;
return SLUtil.GetDefaultAvatarAnimation(name);
}
public Vector3 Position

View File

@ -712,7 +712,7 @@ namespace OpenSim.Region.RegionCombinerModule
List<Vector3> CoarseLocations = new List<Vector3>();
List<UUID> AvatarUUIDs = new List<UUID>();
connectiondata.RegionScene.ForEachRootScenePresence(delegate(ScenePresence sp)
{
if (sp.UUID != presence.UUID)