From e23290eff67ec2b19cffa3a555deef0a63511358 Mon Sep 17 00:00:00 2001 From: MW Date: Fri, 7 Dec 2007 17:23:11 +0000 Subject: Avatar Appearance refactoring /changes. Added a AvatarAppearance class, each ScenePresence "has" a AvatarAppearance object. All the ScenePresences in a opensim related to one user (so a user's various ScenePresence's in all the regions in that instance) share the same AvatarAppearance object. This means that a user's avatar should appear correctly (to both that user and other users) no matter what border crossing or teleporting they have done. Note: this mainly improves Standalone mode, as in grid mode the appearance data isn't passed between region servers. Although people should notice a improvement when moving between regions in the same instance. --- .../Environment/Modules/AvatarFactoryModule.cs | 63 ++++++---------------- 1 file changed, 15 insertions(+), 48 deletions(-) (limited to 'OpenSim/Region/Environment/Modules') diff --git a/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs b/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs index edaad82..4f9aa2a 100644 --- a/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs +++ b/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs @@ -12,26 +12,27 @@ namespace OpenSim.Region.Environment.Modules public class AvatarFactoryModule : IAvatarFactory { private Scene m_scene = null; - private Dictionary m_avatarsClothes = new Dictionary(); + private Dictionary m_avatarsAppearance = new Dictionary(); - public bool TryGetInitialAvatarAppearance(LLUUID avatarId, out AvatarWearable[] wearables, - out byte[] visualParams) + public bool TryGetAvatarAppearance(LLUUID avatarId, out AvatarAppearance appearance) { - if (m_avatarsClothes.ContainsKey(avatarId)) + if (m_avatarsAppearance.ContainsKey(avatarId)) { - visualParams = GetDefaultVisualParams(); - wearables = m_avatarsClothes[avatarId].IsWearing; + appearance = m_avatarsAppearance[avatarId]; return true; } else { + AvatarWearable[] wearables; + byte[] visualParams; GetDefaultAvatarAppearance(out wearables, out visualParams); - AvatarAppearance wearing = new AvatarAppearance(wearables); - m_avatarsClothes[avatarId] = wearing; + appearance = new AvatarAppearance(avatarId, wearables, visualParams); + m_avatarsAppearance[avatarId] = appearance; return true; } } + public void Initialise(Scene scene, IConfigSource source) { scene.RegisterModuleInterface(this); @@ -92,11 +93,12 @@ namespace OpenSim.Region.Environment.Modules { assetId = baseItem.assetID; //temporary dictionary storage. This should be storing to a database - if (m_avatarsClothes.ContainsKey(clientView.AgentId)) + + if (m_avatarsAppearance.ContainsKey(clientView.AgentId)) { - AvatarAppearance avWearing = m_avatarsClothes[clientView.AgentId]; - avWearing.IsWearing[wear.Type].AssetID = assetId; - avWearing.IsWearing[wear.Type].ItemID = wear.ItemID; + AvatarAppearance avatAppearance = m_avatarsAppearance[clientView.AgentId]; + avatAppearance.Wearables[wear.Type].AssetID = assetId; + avatAppearance.Wearables[wear.Type].ItemID = wear.ItemID; } } @@ -123,41 +125,6 @@ namespace OpenSim.Region.Environment.Modules return visualParams; } - public class AvatarAppearance - { - public AvatarWearable[] IsWearing; - public byte[] VisualParams; - - public AvatarAppearance() - { - IsWearing = new AvatarWearable[13]; - for (int i = 0; i < 13; i++) - { - IsWearing[i] = new AvatarWearable(); - } - } - - public AvatarAppearance(AvatarWearable[] wearing) - { - if (wearing.Length == 13) - { - IsWearing = new AvatarWearable[13]; - for (int i = 0; i < 13; i++) - { - IsWearing[i] = new AvatarWearable(); - IsWearing[i].AssetID = wearing[i].AssetID; - IsWearing[i].ItemID = wearing[i].ItemID; - } - } - else - { - IsWearing = new AvatarWearable[13]; - for (int i = 0; i < 13; i++) - { - IsWearing[i] = new AvatarWearable(); - } - } - } - } + } } -- cgit v1.1