From 29e2067ec354435c2cde8f4cd7c9fd869fd931b3 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Fri, 21 Aug 2009 14:10:21 +1000 Subject: * Implements a cache in NPCModule for Appearance. --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 775dc91..d6b90e1 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -41,6 +41,16 @@ namespace OpenSim.Region.OptionalModules.World.NPC private Dictionary m_avatars = new Dictionary(); + private Dictionary m_appearanceCache = new Dictionary(); + + private AvatarAppearance GetAppearance(UUID target, Scene scene) + { + if (m_appearanceCache.ContainsKey(target)) + return m_appearanceCache[target]; + + return scene.CommsManager.AvatarService.GetUserAppearance(target); + } + public UUID CreateNPC(string firstname, string lastname,Vector3 position, Scene scene, UUID cloneAppearanceFrom) { NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, scene); @@ -52,7 +62,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC ScenePresence sp; if(scene.TryGetAvatar(npcAvatar.AgentId, out sp)) { - AvatarAppearance x = scene.CommsManager.AvatarService.GetUserAppearance(cloneAppearanceFrom); + AvatarAppearance x = GetAppearance(cloneAppearanceFrom, scene); List wearbyte = new List(); for (int i = 0; i < x.VisualParams.Length; i++) -- cgit v1.1