diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index 8d503bd7e6..c7f4c20d67 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
+}
diff --git a/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs b/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs
index 39a760cbf4..34aca33349 100644
--- a/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs
@@ -35,6 +35,7 @@ namespace OpenSim.Region.Framework.Interfaces
public interface IAvatarFactoryModule
{
+ void SetAppearance(IScenePresence sp, AvatarAppearance appearance);
void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams);
///
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index dc6eefcb16..53593545ef 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -96,15 +96,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC
if (!m_avatars.ContainsKey(agentId))
return false;
+ // Delete existing sp attachments
scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, false);
- AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true);
- sp.Appearance = npcAppearance;
+ // Set new sp appearance. Also sends to clients.
+ scene.RequestModuleInterface().SetAppearance(sp, new AvatarAppearance(appearance, true));
+
+ // Rez needed sp attachments
scene.AttachmentsModule.RezAttachments(sp);
-
- IAvatarFactoryModule module = scene.RequestModuleInterface();
- module.SendAppearance(sp.UUID);
-
+
return true;
}