From 2ebb421331c4e6c4f57e0cc1bab79cea70937172 Mon Sep 17 00:00:00 2001
From: Dan Lake
Date: Tue, 14 Feb 2012 17:20:34 -0800
Subject: Refactor appearance saving for NPC to use AvatarFactoryModule
interface.
---
.../Avatar/AvatarFactory/AvatarFactoryModule.cs | 40 +++++++++++++++++-----
1 file changed, 31 insertions(+), 9 deletions(-)
(limited to 'OpenSim/Region/CoreModules/Avatar')
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index 8d503bd..c7f4c20 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -111,6 +111,15 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
#region IAvatarFactoryModule
+ ///
+ ///
+ ///
+ ///
+ public void SetAppearance(IScenePresence sp, AvatarAppearance appearance)
+ {
+ SetAppearance(sp, appearance.Texture, appearance.VisualParams);
+ }
+
///
/// Set appearance data (texture asset IDs and slider settings)
///
@@ -156,14 +165,23 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
changed = sp.Appearance.SetTextureEntries(textureEntry) || changed;
// WriteBakedTexturesReport(sp, m_log.DebugFormat);
- if (!ValidateBakedTextureCache(sp))
+
+ // If bake textures are missing and this is not an NPC, request a rebake from client
+ if (!ValidateBakedTextureCache(sp) && (((ScenePresence)sp).PresenceType != PresenceType.Npc))
RequestRebake(sp, true);
// This appears to be set only in the final stage of the appearance
// update transaction. In theory, we should be able to do an immediate
// appearance send and save here.
}
-
+
+ // NPC should send to clients immediately and skip saving appearance
+ if (((ScenePresence)sp).PresenceType == PresenceType.Npc)
+ {
+ SendAppearance((ScenePresence)sp);
+ return;
+ }
+
// save only if there were changes, send no matter what (doesn't hurt to send twice)
if (changed)
QueueAppearanceSave(sp.ControllingClient.AgentId);
@@ -174,6 +192,15 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
// m_log.WarnFormat("[AVFACTORY]: complete SetAppearance for {0}:\n{1}",client.AgentId,sp.Appearance.ToString());
}
+ private void SendAppearance(ScenePresence sp)
+ {
+ // Send the appearance to everyone in the scene
+ sp.SendAppearanceToAllOtherAgents();
+
+ // Send animations back to the avatar as well
+ sp.Animator.SendAnimPack();
+ }
+
public bool SendAppearance(UUID agentId)
{
// m_log.DebugFormat("[AVFACTORY]: Sending appearance for {0}", agentId);
@@ -185,12 +212,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
return false;
}
- // Send the appearance to everyone in the scene
- sp.SendAppearanceToAllOtherAgents();
-
- // Send animations back to the avatar as well
- sp.Animator.SendAnimPack();
-
+ SendAppearance(sp);
return true;
}
@@ -626,4 +648,4 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
outputAction("{0} baked appearance texture is {1}", sp.Name, bakedTextureValid ? "OK" : "corrupt");
}
}
-}
\ No newline at end of file
+}
--
cgit v1.1