diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 045a725292..6fb80d303f 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -115,22 +115,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory #endregion - /// - /// Check for the existence of the baked texture assets. - /// - /// public bool ValidateBakedTextureCache(IClientAPI client) - { - return ValidateBakedTextureCache(client, true); - } - - /// - /// Check for the existence of the baked texture assets. Request a rebake - /// unless checkonly is true. - /// - /// - /// - private bool ValidateBakedTextureCache(IClientAPI client, bool checkonly) { ScenePresence sp = m_scene.GetScenePresence(client.AgentId); if (sp == null) @@ -164,17 +149,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory defonly = false; // found a non-default texture reference - if (!CheckBakedTextureAsset(client, face.TextureID, idx)) - { - // 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.InfoFormat("[AVFACTORY]: missing baked texture {0}, requesting rebake", face.TextureID); - - client.SendRebakeAvatarTextures(face.TextureID); - } + if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) + return false; } m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0}", client.AgentId); @@ -183,6 +159,39 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory return (defonly ? false : true); } + public void RequestRebake(IScenePresence sp, bool missingTexturesOnly) + { + 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 there is no texture entry, skip it + if (face == null) + continue; + +// m_log.DebugFormat( +// "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}", +// face.TextureID, idx, client.Name, client.AgentId); + + // 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; + + if (missingTexturesOnly && m_scene.AssetService.Get(face.TextureID.ToString()) != null) + continue; + else + m_log.DebugFormat( + "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", + face.TextureID, idx, sp.Name); + + sp.ControllingClient.SendRebakeAvatarTextures(face.TextureID); + } + } + /// /// Set appearance data (texture asset IDs and slider settings) received from the client /// @@ -230,8 +239,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory { changed = sp.Appearance.SetTextureEntries(textureEntry) || changed; - m_log.InfoFormat("[AVFACTORY]: received texture update for {0}", client.AgentId); - ValidateBakedTextureCache(client, false); + if (!ValidateBakedTextureCache(sp.ControllingClient)) + 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 diff --git a/OpenSim/Region/Framework/Interfaces/IAvatarFactory.cs b/OpenSim/Region/Framework/Interfaces/IAvatarFactory.cs index 4dbddf476b..ffc5a53a37 100644 --- a/OpenSim/Region/Framework/Interfaces/IAvatarFactory.cs +++ b/OpenSim/Region/Framework/Interfaces/IAvatarFactory.cs @@ -57,7 +57,28 @@ namespace OpenSim.Region.Framework.Interfaces /// true if a valid agent was found, false otherwise bool SaveBakedTextures(UUID agentId); + /// + /// Request a rebake of textures for an avatar. + /// + /// + /// This will send the request to the viewer, since it's there that the rebake is done. + /// + /// Avatar to rebake. + /// + /// If true, only request a rebake for the textures that are missing. + /// If false then we request a rebake of all textures for which we already have references. + /// + void RequestRebake(IScenePresence sp, bool missingTexturesOnly); + + /// + /// Validate that OpenSim can find the baked textures need to display a given avatar + /// + /// + /// + /// true if all the baked textures referenced by the texture IDs exist or the appearance is only using default textures. false otherwise. + /// bool ValidateBakedTextureCache(IClientAPI client); + void QueueAppearanceSend(UUID agentid); void QueueAppearanceSave(UUID agentid); }