From fd1b2a1c574a3397383a91279d56cece81945547 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Mon, 24 Feb 2014 19:20:50 +0000 Subject: [PATCH] Stop mesh avatars that specify the alpha texture in their bake slots from causing the simulator to continually request that they rebake This is because the alpha texture is not in the cache, we must continue to have the fallback of looking for these and other persisted bakes in the asset service. Relates to http://opensimulator.org/mantis/view.php?id=6927 --- .../AvatarFactory/AvatarFactoryModule.cs | 50 +++++------------ .../Tests/AvatarFactoryModuleTests.cs | 55 ++++++++++++++++++- OpenSim/Tests/Common/Mock/TestClient.cs | 3 + 3 files changed, 70 insertions(+), 38 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index cdad729a26..856c4e1ab5 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -460,7 +460,6 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory } } - // m_log.DebugFormat( // "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}", // face.TextureID, idx, client.Name, client.AgentId); @@ -474,16 +473,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory defonly = false; // found a non-default texture reference - if (cache != null) - { - if (!cache.Check(face.TextureID.ToString())) - return false; - } - else - { - if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) - return false; - } + if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) + return false; } // m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID); @@ -519,36 +510,21 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory if (missingTexturesOnly) { - if (cache != null) + if (m_scene.AssetService.Get(face.TextureID.ToString()) != null) { - if (cache.Check(face.TextureID.ToString())) - continue; - else - { - m_log.DebugFormat( - "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", - face.TextureID, idx, sp.Name); - } + continue; } else { - if (m_scene.AssetService.Get(face.TextureID.ToString()) != null) - { - continue; - } - - else - { - // On inter-simulator teleports, this occurs if baked textures are not being stored by the - // grid asset service (which means that they are not available to the new region and so have - // to be re-requested from the client). - // - // The only available core OpenSimulator behaviour right now - // is not to store these textures, temporarily or otherwise. - m_log.DebugFormat( - "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", - face.TextureID, idx, sp.Name); - } + // On inter-simulator teleports, this occurs if baked textures are not being stored by the + // grid asset service (which means that they are not available to the new region and so have + // to be re-requested from the client). + // + // The only available core OpenSimulator behaviour right now + // is not to store these textures, temporarily or otherwise. + m_log.DebugFormat( + "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", + face.TextureID, idx, sp.Name); } } else diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs index ff4c6c9972..2019726bfa 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs @@ -116,5 +116,58 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory Assert.That(eyesBake.Local, Is.False); */ } + + /// + /// Test appearance setting where the baked texture UUID are library alpha textures. + /// + /// + /// For a mesh avatar, it appears these 'baked textures' are used. So these should not trigger a request to + /// rebake. + /// + [Test] + public void TestSetAppearanceAlphaBakedTextures() + { + TestHelpers.InMethod(); + TestHelpers.EnableLogging(); + + UUID userId = TestHelpers.ParseTail(0x1); + UUID alphaTextureID = new UUID("3a367d1c-bef1-6d43-7595-e88c1e3aadb3"); + + + // We need an asset cache because otherwise the LocalAssetServiceConnector will short-circuit directly + // to the AssetService, which will then store temporary and local assets permanently + CoreAssetCache assetCache = new CoreAssetCache(); + + AvatarFactoryModule afm = new AvatarFactoryModule(); + TestScene scene = new SceneHelpers(assetCache).SetupScene(); + SceneHelpers.SetupSceneModules(scene, afm); + ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId); + + AssetBase libraryAsset; + libraryAsset + = new AssetBase( + alphaTextureID, "Default Alpha Layer Texturee", (sbyte)AssetType.Texture, userId.ToString()); + libraryAsset.Data = new byte[] { 2 }; // Not necessary to have a genuine JPEG2000 asset here yet + libraryAsset.Temporary = false; + libraryAsset.Local = false; + scene.AssetService.Store(libraryAsset); + + byte[] visualParams = new byte[AvatarAppearance.VISUALPARAM_COUNT]; + for (byte i = 0; i < visualParams.Length; i++) + visualParams[i] = i; + + Primitive.TextureEntry bakedTextureEntry = new Primitive.TextureEntry(TestHelpers.ParseTail(0x10)); + uint eyesFaceIndex = (uint)AppearanceManager.BakeTypeToAgentTextureIndex(BakeType.Eyes); + Primitive.TextureEntryFace eyesFace = bakedTextureEntry.CreateFace(eyesFaceIndex); + + int rebakeRequestsReceived = 0; + ((TestClient)sp.ControllingClient).OnReceivedSendRebakeAvatarTextures += id => rebakeRequestsReceived++; + + // This is the alpha texture + eyesFace.TextureID = alphaTextureID; + afm.SetAppearance(sp, bakedTextureEntry, visualParams, null); + + Assert.That(rebakeRequestsReceived, Is.EqualTo(0)); + } } -} +} \ No newline at end of file diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index a4247e303a..09ff531934 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -63,6 +63,7 @@ namespace OpenSim.Tests.Common.Mock public event Action OnTestClientInformClientOfNeighbour; public event TestClientOnSendRegionTeleportDelegate OnTestClientSendRegionTeleport; public event Action OnReceivedInstantMessage; + public event Action OnReceivedSendRebakeAvatarTextures; public delegate void TestClientOnSendRegionTeleportDelegate( ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, @@ -1227,6 +1228,8 @@ namespace OpenSim.Tests.Common.Mock public void SendRebakeAvatarTextures(UUID textureID) { + if (OnReceivedSendRebakeAvatarTextures != null) + OnReceivedSendRebakeAvatarTextures(textureID); } public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages)