diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index e8aee3eafe..d64a0c170c 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -156,7 +156,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory changed = sp.Appearance.SetTextureEntries(textureEntry) || changed; // WriteBakedTexturesReport(sp, m_log.DebugFormat); - ValidateBakedTextureCache(sp, false); + if (!ValidateBakedTextureCache(sp)) + 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 @@ -250,15 +251,6 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory return true; } - /// - /// Check for the existence of the baked texture assets. - /// - /// - public bool ValidateBakedTextureCache(IScenePresence sp) - { - return ValidateBakedTextureCache(sp, true); - } - /// /// Queue up a request to send appearance. /// @@ -292,17 +284,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory } } - #endregion - - #region AvatarFactoryModule private methods - - /// - /// Check for the existence of the baked texture assets. Request a rebake - /// unless checkonly is true. - /// - /// - /// - private bool ValidateBakedTextureCache(IScenePresence sp, bool checkonly) + public bool ValidateBakedTextureCache(IScenePresence sp) { bool defonly = true; // are we only using default textures @@ -330,16 +312,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory defonly = false; // found a non-default texture reference if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) - { - if (checkonly) - return false; - - m_log.DebugFormat( - "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", - face.TextureID, idx, sp.Name); - - sp.ControllingClient.SendRebakeAvatarTextures(face.TextureID); - } + return false; } m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0}", sp.UUID); @@ -348,6 +321,43 @@ 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); + } + } + + #endregion + + #region AvatarFactoryModule private methods + private Dictionary GetBakedTextureFaces(ScenePresence sp) { if (sp.IsChildAgent) diff --git a/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs b/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs index 8670229e8b..04df9c3723 100644 --- a/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs @@ -61,7 +61,29 @@ namespace OpenSim.Region.Framework.Interfaces /// true if a valid agent was found, false otherwise bool SaveBakedTextures(UUID agentId); + /// + /// 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(IScenePresence sp); + + /// + /// 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); + void QueueAppearanceSend(UUID agentid); void QueueAppearanceSave(UUID agentid);