Refactor appearance saving for NPC to use AvatarFactoryModule interface.
parent
a9e8bd59a3
commit
2ebb421331
|
@ -111,6 +111,15 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
|
||||||
|
|
||||||
#region IAvatarFactoryModule
|
#region IAvatarFactoryModule
|
||||||
|
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sp"></param>
|
||||||
|
/// <param name="texture"></param>
|
||||||
|
/// <param name="visualParam"></param>
|
||||||
|
public void SetAppearance(IScenePresence sp, AvatarAppearance appearance)
|
||||||
|
{
|
||||||
|
SetAppearance(sp, appearance.Texture, appearance.VisualParams);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set appearance data (texture asset IDs and slider settings)
|
/// Set appearance data (texture asset IDs and slider settings)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -156,14 +165,23 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
|
||||||
changed = sp.Appearance.SetTextureEntries(textureEntry) || changed;
|
changed = sp.Appearance.SetTextureEntries(textureEntry) || changed;
|
||||||
|
|
||||||
// WriteBakedTexturesReport(sp, m_log.DebugFormat);
|
// 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);
|
RequestRebake(sp, true);
|
||||||
|
|
||||||
// This appears to be set only in the final stage of the appearance
|
// 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
|
// update transaction. In theory, we should be able to do an immediate
|
||||||
// appearance send and save here.
|
// 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)
|
// save only if there were changes, send no matter what (doesn't hurt to send twice)
|
||||||
if (changed)
|
if (changed)
|
||||||
QueueAppearanceSave(sp.ControllingClient.AgentId);
|
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());
|
// 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)
|
public bool SendAppearance(UUID agentId)
|
||||||
{
|
{
|
||||||
// m_log.DebugFormat("[AVFACTORY]: Sending appearance for {0}", agentId);
|
// m_log.DebugFormat("[AVFACTORY]: Sending appearance for {0}", agentId);
|
||||||
|
@ -185,12 +212,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send the appearance to everyone in the scene
|
SendAppearance(sp);
|
||||||
sp.SendAppearanceToAllOtherAgents();
|
|
||||||
|
|
||||||
// Send animations back to the avatar as well
|
|
||||||
sp.Animator.SendAnimPack();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -626,4 +648,4 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
|
||||||
outputAction("{0} baked appearance texture is {1}", sp.Name, bakedTextureValid ? "OK" : "corrupt");
|
outputAction("{0} baked appearance texture is {1}", sp.Name, bakedTextureValid ? "OK" : "corrupt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
|
|
||||||
public interface IAvatarFactoryModule
|
public interface IAvatarFactoryModule
|
||||||
{
|
{
|
||||||
|
void SetAppearance(IScenePresence sp, AvatarAppearance appearance);
|
||||||
void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams);
|
void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -96,15 +96,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||||
if (!m_avatars.ContainsKey(agentId))
|
if (!m_avatars.ContainsKey(agentId))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// Delete existing sp attachments
|
||||||
scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, false);
|
scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, false);
|
||||||
|
|
||||||
AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true);
|
// Set new sp appearance. Also sends to clients.
|
||||||
sp.Appearance = npcAppearance;
|
scene.RequestModuleInterface<IAvatarFactoryModule>().SetAppearance(sp, new AvatarAppearance(appearance, true));
|
||||||
|
|
||||||
|
// Rez needed sp attachments
|
||||||
scene.AttachmentsModule.RezAttachments(sp);
|
scene.AttachmentsModule.RezAttachments(sp);
|
||||||
|
|
||||||
IAvatarFactoryModule module = scene.RequestModuleInterface<IAvatarFactoryModule>();
|
|
||||||
module.SendAppearance(sp.UUID);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue