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
parent
5c5a493791
commit
bdc968f1fc
|
@ -28,6 +28,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Xml;
|
||||||
using log4net;
|
using log4net;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
|
|
||||||
|
@ -39,6 +40,13 @@ namespace OpenSim.Framework
|
||||||
|
|
||||||
#region SL / file extension / content-type conversions
|
#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)
|
public static string SLAssetTypeToContentType(int assetType)
|
||||||
{
|
{
|
||||||
switch ((AssetType)assetType)
|
switch ((AssetType)assetType)
|
||||||
|
@ -374,5 +382,47 @@ namespace OpenSim.Framework
|
||||||
|
|
||||||
return output;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -317,7 +317,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
protected readonly UUID m_agentId;
|
protected readonly UUID m_agentId;
|
||||||
private readonly uint m_circuitCode;
|
private readonly uint m_circuitCode;
|
||||||
private readonly byte[] m_channelVersion = Utils.EmptyBytes;
|
private readonly byte[] m_channelVersion = Utils.EmptyBytes;
|
||||||
private readonly Dictionary<string, UUID> m_defaultAnimations = new Dictionary<string, UUID>();
|
|
||||||
private readonly IGroupsModule m_GroupsModule;
|
private readonly IGroupsModule m_GroupsModule;
|
||||||
|
|
||||||
private int m_cachedTextureSerial;
|
private int m_cachedTextureSerial;
|
||||||
|
@ -452,10 +451,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
RegisterInterface<IClientChat>(this);
|
RegisterInterface<IClientChat>(this);
|
||||||
RegisterInterface<IClientIPEndpoint>(this);
|
RegisterInterface<IClientIPEndpoint>(this);
|
||||||
|
|
||||||
InitDefaultAnimations();
|
|
||||||
|
|
||||||
m_scene = scene;
|
m_scene = scene;
|
||||||
|
|
||||||
m_entityUpdates = new PriorityQueue(m_scene.Entities.Count);
|
m_entityUpdates = new PriorityQueue(m_scene.Entities.Count);
|
||||||
m_entityProps = new PriorityQueue(m_scene.Entities.Count);
|
m_entityProps = new PriorityQueue(m_scene.Entities.Count);
|
||||||
m_fullUpdateDataBlocksBuilder = new List<ObjectUpdatePacket.ObjectDataBlock>();
|
m_fullUpdateDataBlocksBuilder = new List<ObjectUpdatePacket.ObjectDataBlock>();
|
||||||
|
@ -11210,30 +11206,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
OutPacket(scriptQuestion, ThrottleOutPacketType.Task);
|
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)
|
public UUID GetDefaultAnimation(string name)
|
||||||
{
|
{
|
||||||
if (m_defaultAnimations.ContainsKey(name))
|
return SLUtil.GetDefaultAvatarAnimation(name);
|
||||||
return m_defaultAnimations[name];
|
|
||||||
return UUID.Zero;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -42,9 +42,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||||
{
|
{
|
||||||
public class NPCAvatar : IClientAPI, INPC
|
public class NPCAvatar : IClientAPI, INPC
|
||||||
{
|
{
|
||||||
private static readonly Dictionary<string, UUID> m_defaultAnimations = new Dictionary<string, UUID>();
|
|
||||||
|
|
||||||
public bool SenseAsAgent { get; set; }
|
public bool SenseAsAgent { get; set; }
|
||||||
|
|
||||||
private readonly string m_firstname;
|
private readonly string m_firstname;
|
||||||
private readonly string m_lastname;
|
private readonly string m_lastname;
|
||||||
private readonly Vector3 m_startPos;
|
private readonly Vector3 m_startPos;
|
||||||
|
@ -61,16 +60,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||||
m_scene = scene;
|
m_scene = scene;
|
||||||
m_ownerID = ownerID;
|
m_ownerID = ownerID;
|
||||||
SenseAsAgent = senseAsAgent;
|
SenseAsAgent = senseAsAgent;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static NPCAvatar()
|
|
||||||
{
|
|
||||||
InitDefaultAnimations();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public IScene Scene
|
public IScene Scene
|
||||||
{
|
{
|
||||||
get { return m_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)
|
public UUID GetDefaultAnimation(string name)
|
||||||
{
|
{
|
||||||
if (m_defaultAnimations.ContainsKey(name))
|
return SLUtil.GetDefaultAvatarAnimation(name);
|
||||||
{
|
|
||||||
return m_defaultAnimations[name];
|
|
||||||
}
|
|
||||||
return UUID.Zero;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3 Position
|
public Vector3 Position
|
||||||
|
|
Loading…
Reference in New Issue