From 5dfd2643dfc530280e5dcd0056b59add7d49f313 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Wed, 30 Sep 2009 15:53:03 -0700 Subject: * Change the signature of the agent set appearance callback to prevent unnecessary serialization/deserialization of TextureEntry objects and allow TextureEntry to be inspected for missing bakes * Inspect incoming TextureEntry updates for bakes that do not exist on the simulator and request the missing textures * Properly handle appearance updates that do not have a TextureEntry set --- OpenSim/Client/MXP/ClientStack/MXPClientView.cs | 7 +--- OpenSim/Framework/AvatarAppearance.cs | 12 +++---- OpenSim/Framework/IClientAPI.cs | 2 +- OpenSim/Framework/Tests/AgentCircuitDataTest.cs | 3 +- .../Region/ClientStack/LindenUDP/LLClientView.cs | 14 ++++---- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 39 ++++++++++++++++++---- .../Server/IRCClientView.cs | 7 +--- .../Region/OptionalModules/World/NPC/NPCModule.cs | 8 +---- 8 files changed, 51 insertions(+), 41 deletions(-) diff --git a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs index 82ad942..180f5e0 100644 --- a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs +++ b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs @@ -826,12 +826,7 @@ namespace OpenSim.Client.MXP.ClientStack OpenSim.Region.Framework.Scenes.Scene scene=(OpenSim.Region.Framework.Scenes.Scene)Scene; AvatarAppearance appearance; scene.GetAvatarAppearance(this,out appearance); - List visualParams = new List(); - foreach (byte visualParam in appearance.VisualParams) - { - visualParams.Add(visualParam); - } - OnSetAppearance(appearance.Texture.GetBytes(), visualParams); + OnSetAppearance(appearance.Texture, (byte[])appearance.VisualParams.Clone()); } public void Stop() diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index 940ae3b..3f4214e 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs @@ -380,13 +380,13 @@ namespace OpenSim.Framework /// /// Set up appearance textures and avatar parameters, including a height calculation /// - /// - /// - public virtual void SetAppearance(byte[] texture, List visualParam) + public virtual void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams) { - Primitive.TextureEntry textureEnt = new Primitive.TextureEntry(texture, 0, texture.Length); - m_texture = textureEnt; - m_visualparams = visualParam.ToArray(); + if (textureEntry != null) + m_texture = textureEntry; + if (visualParams != null) + m_visualparams = visualParams; + m_avatarHeight = 1.23077f // Shortest possible avatar height + 0.516945f * (float)m_visualparams[(int)VPElement.SHAPE_HEIGHT] / 255.0f // Body height + 0.072514f * (float)m_visualparams[(int)VPElement.SHAPE_HEAD_SIZE] / 255.0f // Head size diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 2ca2df9..430cbd7 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -65,7 +65,7 @@ namespace OpenSim.Framework public delegate void NetworkStats(int inPackets, int outPackets, int unAckedBytes); - public delegate void SetAppearance(byte[] texture, List visualParamList); + public delegate void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams); public delegate void StartAnim(IClientAPI remoteClient, UUID animID); diff --git a/OpenSim/Framework/Tests/AgentCircuitDataTest.cs b/OpenSim/Framework/Tests/AgentCircuitDataTest.cs index ecd35c0..2fda6f3 100644 --- a/OpenSim/Framework/Tests/AgentCircuitDataTest.cs +++ b/OpenSim/Framework/Tests/AgentCircuitDataTest.cs @@ -227,8 +227,7 @@ namespace OpenSim.Framework.Tests wearbyte.Add(VisualParams[i]); } - - AvAppearance.SetAppearance(AvAppearance.Texture.GetBytes(), wearbyte); + AvAppearance.SetAppearance(AvAppearance.Texture, (byte[])VisualParams.Clone()); } /// diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index dae525d..9788f40 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -5272,13 +5272,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP // for the client session anyway, in order to protect ourselves against bad code in plugins try { - List visualparams = new List(); - foreach (AgentSetAppearancePacket.VisualParamBlock x in appear.VisualParam) - { - visualparams.Add(x.ParamValue); - } + byte[] visualparams = new byte[appear.VisualParam.Length]; + for (int i = 0; i < appear.VisualParam.Length; i++) + visualparams[i] = appear.VisualParam[i].ParamValue; + + Primitive.TextureEntry te = null; + if (appear.ObjectData.TextureEntry.Length > 1) + te = new Primitive.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length); - handlerSetAppearance(appear.ObjectData.TextureEntry, visualparams); + handlerSetAppearance(te, visualparams); } catch (Exception e) { diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 23fe2d3..ea5240e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -73,6 +73,8 @@ namespace OpenSim.Region.Framework.Scenes private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; + public static byte[] DefaultTexture; public UUID currentParcelUUID = UUID.Zero; @@ -2685,7 +2687,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - public void SetAppearance(byte[] texture, List visualParam) + public void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams) { if (m_physicsActor != null) { @@ -2703,7 +2705,30 @@ namespace OpenSim.Region.Framework.Scenes AddToPhysicalScene(flyingTemp); } } - m_appearance.SetAppearance(texture, visualParam); + + #region Bake Cache Check + + if (textureEntry != null) + { + for (int i = 0; i < BAKE_INDICES.Length; i++) + { + int j = BAKE_INDICES[i]; + Primitive.TextureEntryFace face = textureEntry.FaceTextures[j]; + + if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE) + { + if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) + { + m_log.Warn("[APPEARANCE]: Missing baked texture " + face.TextureID + " (" + (AppearanceManager.TextureIndex)j + ") for avatar " + this.Name); + this.ControllingClient.SendRebakeAvatarTextures(face.TextureID); + } + } + } + } + + #endregion Bake Cache Check + + m_appearance.SetAppearance(textureEntry, visualParams); if (m_appearance.AvatarHeight > 0) SetHeight(m_appearance.AvatarHeight); m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); @@ -3253,14 +3278,14 @@ namespace OpenSim.Region.Framework.Scenes wears[i++] = new AvatarWearable(itemId, assetId); } m_appearance.Wearables = wears; - byte[] te = null; - if (cAgent.AgentTextures != null) - te = cAgent.AgentTextures; + Primitive.TextureEntry te; + if (cAgent.AgentTextures != null && cAgent.AgentTextures.Length > 1) + te = new Primitive.TextureEntry(cAgent.AgentTextures, 0, cAgent.AgentTextures.Length); else - te = AvatarAppearance.GetDefaultTexture().GetBytes(); + te = AvatarAppearance.GetDefaultTexture(); if ((cAgent.VisualParams == null) || (cAgent.VisualParams.Length < AvatarAppearance.VISUALPARAM_COUNT)) cAgent.VisualParams = AvatarAppearance.GetDefaultVisualParams(); - m_appearance.SetAppearance(te, new List(cAgent.VisualParams)); + m_appearance.SetAppearance(te, (byte[])cAgent.VisualParams.Clone()); } catch (Exception e) { diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 2316267..57f5d29 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -861,12 +861,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server Scene scene = (Scene)Scene; AvatarAppearance appearance; scene.GetAvatarAppearance(this, out appearance); - List visualParams = new List(); - foreach (byte visualParam in appearance.VisualParams) - { - visualParams.Add(visualParam); - } - OnSetAppearance(appearance.Texture.GetBytes(), visualParams); + OnSetAppearance(appearance.Texture, (byte[])appearance.VisualParams.Clone()); } public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args) diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index b3bfe07..30a2675 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -163,13 +163,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC { AvatarAppearance x = GetAppearance(p_cloneAppearanceFrom, p_scene); - List wearbyte = new List(); - for (int i = 0; i < x.VisualParams.Length; i++) - { - wearbyte.Add(x.VisualParams[i]); - } - - sp.SetAppearance(x.Texture.GetBytes(), wearbyte); + sp.SetAppearance(x.Texture, (byte[])x.VisualParams.Clone()); } m_avatars.Add(npcAvatar.AgentId, npcAvatar); -- cgit v1.1