Various bug fixes for appearance handling

This commit is contained in:
Mic Bowman
2010-11-29 16:24:16 -08:00
committed by Melanie
parent 0218845c2e
commit ab2adaf341
4 changed files with 114 additions and 58 deletions

View File

@@ -115,7 +115,13 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
#endregion
public bool ValidateBakedTextureCache(IClientAPI client)
{
return ValidateBakedTextureCache(client, true);
}
private bool ValidateBakedTextureCache(IClientAPI client, bool checkonly)
{
ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
if (sp == null)
@@ -131,15 +137,33 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
{
int idx = AvatarAppearance.BAKE_INDICES[i];
Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx];
if (face == null || face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE)
// if there is no texture entry, skip it
if (face == null)
continue;
// if the texture is one of the "defaults" then skip it
// this should probably be more intelligent (skirt texture doesnt matter
// if the avatar isnt wearing a skirt) but if any of the main baked
// textures is default then the rest should be as well
if (face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE)
continue;
defonly = false; // found a non-default texture reference
if (! CheckBakedTextureAsset(client,face.TextureID,idx))
return false;
{
// the asset didn't exist if we are only checking, then we found a bad
// one and we're done otherwise, ask for a rebake
if (checkonly) return false;
m_log.WarnFormat("[AVFACTORY] missing baked texture {0}, request rebake",face.TextureID);
client.SendRebakeAvatarTextures(face.TextureID);
}
}
m_log.WarnFormat("[AVFACTORY]: complete texture check for {0}",client.AgentId);
// If we only found default textures, then the appearance is not cached
return (defonly ? false : true);
}
@@ -158,7 +182,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
return;
}
// m_log.WarnFormat("[AVFACTORY]: Start SetAppearance for {0}",client.AgentId);
m_log.WarnFormat("[AVFACTORY]: start SetAppearance for {0}",client.AgentId);
bool changed = false;
@@ -166,47 +190,40 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
// going to be handled correctly but it does serialize the updates to the appearance
lock (m_setAppearanceLock)
{
if (textureEntry != null)
{
changed = sp.Appearance.SetTextureEntries(textureEntry);
// m_log.WarnFormat("[AVFACTORY]: Prepare to check textures for {0}",client.AgentId);
for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
{
int idx = AvatarAppearance.BAKE_INDICES[i];
Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx];
if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE)
Util.FireAndForget(delegate(object o) {
if (! CheckBakedTextureAsset(client,face.TextureID,idx))
client.SendRebakeAvatarTextures(face.TextureID);
});
}
m_log.WarnFormat("[AVFACTORY]: Complete texture check for {0}",client.AgentId);
}
// Process the visual params, this may change height as well
if (visualParams != null)
{
if (sp.Appearance.SetVisualParams(visualParams))
{
changed = true;
if (sp.Appearance.AvatarHeight > 0)
sp.SetHeight(sp.Appearance.AvatarHeight);
}
changed = sp.Appearance.SetVisualParams(visualParams);
if (sp.Appearance.AvatarHeight > 0)
sp.SetHeight(sp.Appearance.AvatarHeight);
}
// Process the baked texture array
if (textureEntry != null)
{
changed = sp.Appearance.SetTextureEntries(textureEntry) || changed;
m_log.WarnFormat("[AVFACTORY]: received texture update for {0}",client.AgentId);
Util.FireAndForget(delegate(object o) { ValidateBakedTextureCache(client,false); });
// 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.
QueueAppearanceSave(client.AgentId);
QueueAppearanceSend(client.AgentId);
}
}
// If something changed in the appearance then queue an appearance save
if (changed)
QueueAppearanceSave(client.AgentId);
// // If something changed in the appearance then queue an appearance save
// if (changed)
// QueueAppearanceSave(client.AgentId);
// And always queue up an appearance update to send out
QueueAppearanceSend(client.AgentId);
// // And always queue up an appearance update to send out
// QueueAppearanceSend(client.AgentId);
// 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());
}
/// <summary>
@@ -229,6 +246,10 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
#region UpdateAppearanceTimer
/// <summary>
/// Queue up a request to send appearance, makes it possible to
/// accumulate changes without sending out each one separately.
/// </summary>
public void QueueAppearanceSend(UUID agentid)
{
// m_log.WarnFormat("[AVFACTORY]: Queue appearance send for {0}", agentid);
@@ -268,6 +289,9 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
// Send the appearance to everyone in the scene
sp.SendAppearanceToAllOtherAgents();
// Send animations back to the avatar as well
sp.Animator.SendAnimPack();
}
private void HandleAppearanceSave(UUID agentid)
@@ -355,7 +379,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
// operate on a copy of the appearance so we don't have to lock anything
AvatarAppearance avatAppearance = new AvatarAppearance(sp.Appearance, false);
sp.Appearance.ResetBakedTextures(); // this makes sure we don't reuse old textures if the baking takes time
foreach (AvatarWearingArgs.Wearable wear in e.NowWearing)
{
if (wear.Type < AvatarWearable.MAX_WEARABLES)