From 267f18925d06ca05e2a5ffbfbb63582783762439 Mon Sep 17 00:00:00 2001 From: Master ScienceSim Date: Thu, 21 Oct 2010 16:48:58 -0700 Subject: First attempt to get multiple attachments working to support viewer2. The attachment code appears to work correctly for 1.23 viewers so, in spite of some big changes in the internal representation, there don't appear to be regressions. That being said, I still can't get a viewer2 avatar to show correctly. --- OpenSim/Framework/AvatarAppearance.cs | 138 +++++++++++++++++----------------- 1 file changed, 70 insertions(+), 68 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index 55646dd..ba0cad2 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs @@ -51,7 +51,7 @@ namespace OpenSim.Framework protected byte[] m_visualparams; protected Primitive.TextureEntry m_texture; protected AvatarWearable[] m_wearables; - protected Dictionary m_attachments; + protected Dictionary> m_attachments; protected float m_avatarHeight = 0; protected float m_hipOffset = 0; @@ -85,11 +85,6 @@ namespace OpenSim.Framework set { m_wearables = value; } } - public virtual Dictionary Attachments - { - get { return m_attachments; } - } - public virtual UUID BodyItem { get { return m_wearables[AvatarWearable.BODY].ItemID; } set { m_wearables[AvatarWearable.BODY].ItemID = value; } @@ -246,7 +241,7 @@ namespace OpenSim.Framework SetDefaultParams(); SetHeight(); - m_attachments = new Dictionary(); + m_attachments = new Dictionary>(); } public AvatarAppearance(UUID avatarID, OSDMap map) @@ -284,7 +279,7 @@ namespace OpenSim.Framework SetHeight(); - m_attachments = new Dictionary(); + m_attachments = new Dictionary>(); } public AvatarAppearance(AvatarAppearance appearance) @@ -302,7 +297,7 @@ namespace OpenSim.Framework SetDefaultParams(); SetHeight(); - m_attachments = new Dictionary(); + m_attachments = new Dictionary>(); return; } @@ -329,9 +324,10 @@ namespace OpenSim.Framework if (appearance.VisualParams != null) m_visualparams = (byte[])appearance.VisualParams.Clone(); - m_attachments = new Dictionary(); - foreach (KeyValuePair kvp in appearance.Attachments) - m_attachments[kvp.Key] = new AvatarAttachment(kvp.Value); + // Copy the attachment, force append mode since that ensures consistency + m_attachments = new Dictionary>(); + foreach (AvatarAttachment attachment in appearance.GetAttachments()) + AppendAttachment(new AvatarAttachment(attachment)); } protected virtual void SetDefaultWearables() @@ -487,12 +483,41 @@ namespace OpenSim.Framework } // DEBUG OFF - public void SetAttachments(AvatarAttachment[] data) + /// + /// Get a list of the attachments, note that there may be + /// duplicate attachpoints + /// + public List GetAttachments() + { + List alist = new List(); + foreach (KeyValuePair> kvp in m_attachments) + { + foreach (AvatarAttachment attach in kvp.Value) + alist.Add(new AvatarAttachment(attach)); + } + + return alist; + } + + internal void AppendAttachment(AvatarAttachment attach) { - foreach (AvatarAttachment attach in data) - m_attachments[attach.AttachPoint] = new AvatarAttachment(attach); + if (! m_attachments.ContainsKey(attach.AttachPoint)) + m_attachments[attach.AttachPoint] = new List(); + m_attachments[attach.AttachPoint].Add(attach); } + internal void ReplaceAttachment(AvatarAttachment attach) + { + m_attachments[attach.AttachPoint] = new List(); + m_attachments[attach.AttachPoint].Add(attach); + } + + /// + /// Add an attachment, if the attachpoint has the + /// 0x80 bit set then we assume this is an append + /// operation otherwise we replace whatever is + /// currently attached at the attachpoint + /// public void SetAttachment(int attachpoint, UUID item, UUID asset) { if (attachpoint == 0) @@ -505,67 +530,47 @@ namespace OpenSim.Framework return; } - m_attachments[attachpoint] = new AvatarAttachment(attachpoint,item,asset); - } - - public Hashtable GetAttachments() - { - if (m_attachments.Count == 0) - return null; - - Hashtable ret = new Hashtable(); - - foreach (KeyValuePair kvp in m_attachments) + // check if this is an append or a replace, 0x80 marks it as an append + if ((attachpoint & 0x80) > 0) { - Hashtable data = new Hashtable(); - data["item"] = kvp.Value.ItemID.ToString(); - data["asset"] = kvp.Value.AssetID.ToString(); - - ret[kvp.Key] = data; + // strip the append bit + int point = attachpoint & 0x7F; + AppendAttachment(new AvatarAttachment(point, item, asset)); + } + else + { + ReplaceAttachment(new AvatarAttachment(attachpoint,item,asset)); } - - return ret; - } - - public List GetAttachedPoints() - { - return new List(m_attachments.Keys); - } - - public UUID GetAttachedItem(int attachpoint) - { - if (!m_attachments.ContainsKey(attachpoint)) - return UUID.Zero; - - return m_attachments[attachpoint].ItemID; - } - - public UUID GetAttachedAsset(int attachpoint) - { - if (!m_attachments.ContainsKey(attachpoint)) - return UUID.Zero; - - return m_attachments[attachpoint].AssetID; } public int GetAttachpoint(UUID itemID) { - foreach (KeyValuePair kvp in m_attachments) + foreach (KeyValuePair> kvp in m_attachments) { - if (kvp.Value.ItemID == itemID) - { + int index = kvp.Value.FindIndex(delegate(AvatarAttachment a) { return a.ItemID == itemID; }); + if (index >= 0) return kvp.Key; - } } + return 0; } public void DetachAttachment(UUID itemID) { - int attachpoint = GetAttachpoint(itemID); + foreach (KeyValuePair> kvp in m_attachments) + { + int index = kvp.Value.FindIndex(delegate(AvatarAttachment a) { return a.ItemID == itemID; }); + if (index >= 0) + { + // Remove it from the list of attachments at that attach point + m_attachments[kvp.Key].RemoveAt(index); - if (attachpoint > 0) - m_attachments.Remove(attachpoint); + // And remove the list if there are no more attachments here + if (m_attachments[kvp.Key].Count == 0) + m_attachments.Remove(kvp.Key); + return; + } + } } public void ClearAttachments() @@ -607,8 +612,8 @@ namespace OpenSim.Framework // Attachments OSDArray attachs = new OSDArray(m_attachments.Count); - foreach (KeyValuePair kvp in m_attachments) - attachs.Add(kvp.Value.Pack()); + foreach (AvatarAttachment attach in GetAttachments()) + attachs.Add(attach.Pack()); data["attachments"] = attachs; return data; @@ -675,15 +680,12 @@ namespace OpenSim.Framework } // Attachments - m_attachments = new Dictionary(); + m_attachments = new Dictionary>(); if ((data != null) && (data["attachments"] != null) && (data["attachments"]).Type == OSDType.Array) { OSDArray attachs = (OSDArray)(data["attachments"]); for (int i = 0; i < attachs.Count; i++) - { - AvatarAttachment attach = new AvatarAttachment((OSDMap)attachs[i]); - m_attachments[attach.AttachPoint] = attach; - } + AppendAttachment(new AvatarAttachment((OSDMap)attachs[i])); } } catch (Exception e) -- cgit v1.1 From 657cceb8847f94a9af0c8b2358124105d778486c Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Mon, 25 Oct 2010 09:41:08 -0700 Subject: Intermediate commit for backward compatability; does not compile yet --- OpenSim/Framework/AgentCircuitData.cs | 65 ++++++++++++++-------------- OpenSim/Framework/ChildAgentDataUpdate.cs | 70 ++++++++++++++++++------------- 2 files changed, 73 insertions(+), 62 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/AgentCircuitData.cs b/OpenSim/Framework/AgentCircuitData.cs index be98380..30a9548 100644 --- a/OpenSim/Framework/AgentCircuitData.cs +++ b/OpenSim/Framework/AgentCircuitData.cs @@ -206,16 +206,18 @@ namespace OpenSim.Framework args["service_session_id"] = OSD.FromString(ServiceSessionID); args["start_pos"] = OSD.FromString(startpos.ToString()); - args["appearance_serial"] = OSD.FromInteger(Appearance.Serial); args["client_ip"] = OSD.FromString(IPAddress); args["viewer"] = OSD.FromString(Viewer); args["channel"] = OSD.FromString(Channel); args["mac"] = OSD.FromString(Mac); args["id0"] = OSD.FromString(Id0); -/* + // Eventually this code should be deprecated, use full appearance + // packing in packed_appearance if (Appearance != null) { + args["appearance_serial"] = OSD.FromInteger(Appearance.Serial); + //System.Console.WriteLine("XXX Before packing Wearables"); if ((Appearance.Wearables != null) && (Appearance.Wearables.Length > 0)) { @@ -230,20 +232,19 @@ namespace OpenSim.Framework } //System.Console.WriteLine("XXX Before packing Attachments"); - Dictionary attachments = Appearance.Attachments; + List attachments = Appearance.GetAttachments(); if ((attachments != null) && (attachments.Count > 0)) { OSDArray attachs = new OSDArray(attachments.Count); - foreach (KeyValuePair kvp in attachments) + foreach (AvatarAttachment attach in attachments) { - AvatarAttachment adata = new AvatarAttachment(kvp.Value); - attachs.Add(adata.Pack()); + attachs.Add(attach.Pack()); //System.Console.WriteLine("XXX att.pt=" + kvp.Key + "; itemID=" + kvp.Value[0] + "; assetID=" + kvp.Value[1]); } args["attachments"] = attachs; } } -*/ + if (Appearance != null) { OSDMap appmap = Appearance.Pack(); @@ -339,27 +340,9 @@ namespace OpenSim.Framework try { // Unpack various appearance elements Appearance = new AvatarAppearance(AgentID); - if (args["packed_appearance"] != null) - { - if (args["packed_appearance"].Type == OSDType.Map) - { - Appearance.Unpack((OSDMap)args["packed_appearance"]); - m_log.WarnFormat("[AGENTCIRCUITDATA] unpacked appearance"); - } - else - m_log.WarnFormat("[AGENTCIRCUITDATA] packed_appearance is not a map:\n{0}",args["packed_appearance"].ToString()); - } -// DEBUG ON - else - m_log.Warn("[AGENTCIRCUITDATA] failed to find a valid packed_appearance"); -// DEBUG OFF - } catch (Exception e) - { - m_log.ErrorFormat("[AGENTCIRCUITDATA] failed to unpack appearance; {0}",e.Message); - } - - -/* + + // Eventually this code should be deprecated, use full appearance + // packing in packed_appearance if (args["appearance_serial"] != null) Appearance.Serial = args["appearance_serial"].AsInteger(); @@ -376,18 +359,34 @@ namespace OpenSim.Framework if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array) { OSDArray attachs = (OSDArray)(args["attachments"]); - AvatarAttachment[] attachments = new AvatarAttachment[attachs.Count]; - int i = 0; foreach (OSD o in attachs) { if (o.Type == OSDType.Map) { - attachments[i++] = new AvatarAttachment((OSDMap)o); + Appearance.AppendAttachment(new AvatarAttachment((OSDMap)o)); } } - Appearance.SetAttachments(attachments); } -*/ + + if (args["packed_appearance"] != null) + { + if (args["packed_appearance"].Type == OSDType.Map) + { + Appearance.Unpack((OSDMap)args["packed_appearance"]); + m_log.WarnFormat("[AGENTCIRCUITDATA] unpacked appearance"); + } + else + m_log.WarnFormat("[AGENTCIRCUITDATA] packed_appearance is not a map:\n{0}",args["packed_appearance"].ToString()); + } +// DEBUG ON + else + m_log.Warn("[AGENTCIRCUITDATA] failed to find a valid packed_appearance"); +// DEBUG OFF + } catch (Exception e) + { + m_log.ErrorFormat("[AGENTCIRCUITDATA] failed to unpack appearance; {0}",e.Message); + } + ServiceURLs = new Dictionary(); if (args.ContainsKey("service_urls") && args["service_urls"] != null && (args["service_urls"]).Type == OSDType.Array) { diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs index fdebba3..d7a7d1e 100644 --- a/OpenSim/Framework/ChildAgentDataUpdate.cs +++ b/OpenSim/Framework/ChildAgentDataUpdate.cs @@ -387,31 +387,37 @@ namespace OpenSim.Framework // args["agent_textures"] = textures; //} -/* - if ((AgentTextures != null) && (AgentTextures.Length > 0)) - args["texture_entry"] = OSD.FromBinary(AgentTextures); + // The code to pack textures, visuals, wearables and attachments + // should be removed; packed appearance contains the full appearance + // This is retained for backward compatibility only + if ((Appearance.Texture != null) && (Appearance.Texture.Length > 0)) + args["texture_entry"] = OSD.FromBinary(Appearance.Texture); - if ((VisualParams != null) && (VisualParams.Length > 0)) - args["visual_params"] = OSD.FromBinary(VisualParams); + if ((Appearance.VisualParams != null) && (Appearance.VisualParams.Length > 0)) + args["visual_params"] = OSD.FromBinary(Appearance.VisualParams); // We might not pass this in all cases... - if ((Wearables != null) && (Wearables.Length > 0)) + if ((Appearance.Wearables != null) && (Appearance.Wearables.Length > 0)) { - OSDArray wears = new OSDArray(Wearables.Length); - foreach (UUID uuid in Wearables) - wears.Add(OSD.FromUUID(uuid)); + OSDArray wears = new OSDArray(Appearance.Wearables.Length * 2); + foreach (AvatarWearable awear in Appearance.Wearables) + { + wears.Add(OSD.FromUUID(awear.ItemID)); + wears.Add(OSD.FromUUID(awear.AssetID)); + } args["wearables"] = wears; } - - if ((Attachments != null) && (Attachments.Length > 0)) + List attachments = Appearance.GetAttachments(); + if ((attachments != null) && (attachments.Length > 0)) { - OSDArray attachs = new OSDArray(Attachments.Length); - foreach (AvatarAttachment att in Attachments) + OSDArray attachs = new OSDArray(attachments.Length); + foreach (AvatarAttachment att in attachments) attachs.Add(att.Pack()); args["attachments"] = attachs; } -*/ + // End of code to remove + if ((Controllers != null) && (Controllers.Length > 0)) { OSDArray controls = new OSDArray(Controllers.Length); @@ -547,41 +553,47 @@ namespace OpenSim.Framework // AgentTextures[i++] = o.AsUUID(); //} - if (args["packed_appearance"] != null) - Appearance = new AvatarAppearance(AgentID,(OSDMap)args["packed_appearance"]); - else - Appearance = new AvatarAppearance(AgentID); - -/* + + Appearance = new AvatarAppearance(AgentID); + + // The code to pack textures, visuals, wearables and attachments + // should be removed; packed appearance contains the full appearance + // This is retained for backward compatibility only if (args["texture_entry"] != null) - AgentTextures = args["texture_entry"].AsBinary(); + Appearance.SetTextureEntries(args["texture_entry"].AsBinary()); if (args["visual_params"] != null) - VisualParams = args["visual_params"].AsBinary(); + Appearance.SetVisualParams(args["visual_params"].AsBinary()); if ((args["wearables"] != null) && (args["wearables"]).Type == OSDType.Array) { OSDArray wears = (OSDArray)(args["wearables"]); - Wearables = new UUID[wears.Count]; - int i = 0; - foreach (OSD o in wears) - Wearables[i++] = o.AsUUID(); + for (int i = 0; i < wears.Count / 2; i++) + { + Appearance.Wearables[i].ItemID = wears[i*2].AsUUID(); + Appearance.Wearables[i].AssetID = wears[(i*2)+1].AsUUID(); + } } if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array) { OSDArray attachs = (OSDArray)(args["attachments"]); - Attachments = new AvatarAttachment[attachs.Count]; + AvatarAttachment[] attachments = new AvatarAttachment[attachs.Count]; int i = 0; foreach (OSD o in attachs) { if (o.Type == OSDType.Map) { - Attachments[i++] = new AvatarAttachment((OSDMap)o); + attachments[i++] = new AvatarAttachment((OSDMap)o); } } + Appearance.SetAttachments(attachments); } -*/ + // end of code to remove + + if (args["packed_appearance"] != null) + Appearance = new AvatarAppearance(AgentID,(OSDMap)args["packed_appearance"]); + if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array) { OSDArray controls = (OSDArray)(args["controllers"]); -- cgit v1.1 From 6e58c3d563b50c5797d1cfffbaec3fe82f18c2ea Mon Sep 17 00:00:00 2001 From: Master ScienceSim Date: Mon, 25 Oct 2010 14:11:47 -0700 Subject: Half of the compatibility is working. Login into a new region with old data works. Teleport out of a new region with old data works. Teleport into a new region with old data does not trigger the necessary rebake. --- OpenSim/Framework/AgentCircuitData.cs | 13 +++++------- OpenSim/Framework/AvatarAppearance.cs | 2 +- OpenSim/Framework/ChildAgentDataUpdate.cs | 33 ++++++++++++++++++++----------- 3 files changed, 28 insertions(+), 20 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/AgentCircuitData.cs b/OpenSim/Framework/AgentCircuitData.cs index 30a9548..098b33c 100644 --- a/OpenSim/Framework/AgentCircuitData.cs +++ b/OpenSim/Framework/AgentCircuitData.cs @@ -368,15 +368,12 @@ namespace OpenSim.Framework } } - if (args["packed_appearance"] != null) + if (args.ContainsKey("packed_appearance") && (args["packed_appearance"].Type == OSDType.Map)) { - if (args["packed_appearance"].Type == OSDType.Map) - { - Appearance.Unpack((OSDMap)args["packed_appearance"]); - m_log.WarnFormat("[AGENTCIRCUITDATA] unpacked appearance"); - } - else - m_log.WarnFormat("[AGENTCIRCUITDATA] packed_appearance is not a map:\n{0}",args["packed_appearance"].ToString()); + Appearance.Unpack((OSDMap)args["packed_appearance"]); +// DEBUG ON + m_log.WarnFormat("[AGENTCIRCUITDATA] unpacked appearance"); +// DEBUG OFF } // DEBUG ON else diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index ba0cad2..05330c7 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs @@ -389,7 +389,7 @@ namespace OpenSim.Framework changed = true; // DEBUG ON if (newface != null) - m_log.WarnFormat("[SCENEPRESENCE] index {0}, new texture id {1}",i,newface.TextureID); + m_log.WarnFormat("[AVATAR APPEARANCE] index {0}, new texture id {1}",i,newface.TextureID); // DEBUG OFF } diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs index d7a7d1e..215682f 100644 --- a/OpenSim/Framework/ChildAgentDataUpdate.cs +++ b/OpenSim/Framework/ChildAgentDataUpdate.cs @@ -390,8 +390,11 @@ namespace OpenSim.Framework // The code to pack textures, visuals, wearables and attachments // should be removed; packed appearance contains the full appearance // This is retained for backward compatibility only - if ((Appearance.Texture != null) && (Appearance.Texture.Length > 0)) - args["texture_entry"] = OSD.FromBinary(Appearance.Texture); + if (Appearance.Texture != null) + { + byte[] rawtextures = Appearance.Texture.GetBytes(); + args["texture_entry"] = OSD.FromBinary(rawtextures); + } if ((Appearance.VisualParams != null) && (Appearance.VisualParams.Length > 0)) args["visual_params"] = OSD.FromBinary(Appearance.VisualParams); @@ -408,10 +411,10 @@ namespace OpenSim.Framework args["wearables"] = wears; } - List attachments = Appearance.GetAttachments(); - if ((attachments != null) && (attachments.Length > 0)) + List attachments = Appearance.GetAttachments(); + if ((attachments != null) && (attachments.Count > 0)) { - OSDArray attachs = new OSDArray(attachments.Length); + OSDArray attachs = new OSDArray(attachments.Count); foreach (AvatarAttachment att in attachments) attachs.Add(att.Pack()); args["attachments"] = attachs; @@ -560,7 +563,11 @@ namespace OpenSim.Framework // should be removed; packed appearance contains the full appearance // This is retained for backward compatibility only if (args["texture_entry"] != null) - Appearance.SetTextureEntries(args["texture_entry"].AsBinary()); + { + byte[] rawtextures = args["texture_entry"].AsBinary(); + Primitive.TextureEntry textures = new Primitive.TextureEntry(rawtextures,0,rawtextures.Length); + Appearance.SetTextureEntries(textures); + } if (args["visual_params"] != null) Appearance.SetVisualParams(args["visual_params"].AsBinary()); @@ -578,21 +585,25 @@ namespace OpenSim.Framework if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array) { OSDArray attachs = (OSDArray)(args["attachments"]); - AvatarAttachment[] attachments = new AvatarAttachment[attachs.Count]; - int i = 0; foreach (OSD o in attachs) { if (o.Type == OSDType.Map) { - attachments[i++] = new AvatarAttachment((OSDMap)o); + // We know all of these must end up as attachments so we + // append rather than replace to ensure multiple attachments + // per point continues to work + Appearance.AppendAttachment(new AvatarAttachment((OSDMap)o)); } } - Appearance.SetAttachments(attachments); } // end of code to remove - if (args["packed_appearance"] != null) + if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map) Appearance = new AvatarAppearance(AgentID,(OSDMap)args["packed_appearance"]); +// DEBUG ON + else + System.Console.WriteLine("No packed appearance in AgentUpdate"); +// DEBUG OFF if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array) { -- cgit v1.1 From 9cfd3e1d5ac8383087fb09cf076e9ec199808fd7 Mon Sep 17 00:00:00 2001 From: Master ScienceSim Date: Tue, 26 Oct 2010 12:54:28 -0700 Subject: Small cleanup and add more debugging information --- OpenSim/Framework/AgentCircuitData.cs | 4 ++-- OpenSim/Framework/ChildAgentDataUpdate.cs | 27 +++++++++++++++++++++------ 2 files changed, 23 insertions(+), 8 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/AgentCircuitData.cs b/OpenSim/Framework/AgentCircuitData.cs index 098b33c..640a646 100644 --- a/OpenSim/Framework/AgentCircuitData.cs +++ b/OpenSim/Framework/AgentCircuitData.cs @@ -351,8 +351,8 @@ namespace OpenSim.Framework OSDArray wears = (OSDArray)(args["wearables"]); for (int i = 0; i < wears.Count / 2; i++) { - Appearance.Wearables[i].ItemID = wears[i*2].AsUUID(); - Appearance.Wearables[i].AssetID = wears[(i*2)+1].AsUUID(); + AvatarWearable awear = new AvatarWearable(wears[i*2].AsUUID(),wears[(i*2)+1].AsUUID()); + Appearance.SetWearable(i,awear); } } diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs index 215682f..66487f7 100644 --- a/OpenSim/Framework/ChildAgentDataUpdate.cs +++ b/OpenSim/Framework/ChildAgentDataUpdate.cs @@ -28,6 +28,8 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Reflection; +using log4net; using OpenMetaverse; using OpenMetaverse.StructuredData; @@ -310,6 +312,12 @@ namespace OpenSim.Framework // Appearance public AvatarAppearance Appearance; +// DEBUG ON + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); +// DEBUG OFF + /* public byte[] AgentTextures; public byte[] VisualParams; @@ -323,6 +331,10 @@ namespace OpenSim.Framework public virtual OSDMap Pack() { +// DEBUG ON + m_log.WarnFormat("[CHILDAGENTDATAUPDATE] Pack data"); +// DEBUG OFF + OSDMap args = new OSDMap(); args["message_type"] = OSD.FromString("AgentData"); @@ -444,6 +456,10 @@ namespace OpenSim.Framework /// public virtual void Unpack(OSDMap args) { +// DEBUG ON + m_log.WarnFormat("[CHILDAGENTDATAUPDATE] Unpack data"); +// DEBUG OFF + if (args.ContainsKey("region_id")) UUID.TryParse(args["region_id"].AsString(), out RegionID); @@ -556,10 +572,9 @@ namespace OpenSim.Framework // AgentTextures[i++] = o.AsUUID(); //} - Appearance = new AvatarAppearance(AgentID); - // The code to pack textures, visuals, wearables and attachments + // The code to unpack textures, visuals, wearables and attachments // should be removed; packed appearance contains the full appearance // This is retained for backward compatibility only if (args["texture_entry"] != null) @@ -577,8 +592,8 @@ namespace OpenSim.Framework OSDArray wears = (OSDArray)(args["wearables"]); for (int i = 0; i < wears.Count / 2; i++) { - Appearance.Wearables[i].ItemID = wears[i*2].AsUUID(); - Appearance.Wearables[i].AssetID = wears[(i*2)+1].AsUUID(); + AvatarWearable awear = new AvatarWearable(wears[i*2].AsUUID(),wears[(i*2)+1].AsUUID()); + Appearance.SetWearable(i,awear); } } @@ -602,8 +617,8 @@ namespace OpenSim.Framework Appearance = new AvatarAppearance(AgentID,(OSDMap)args["packed_appearance"]); // DEBUG ON else - System.Console.WriteLine("No packed appearance in AgentUpdate"); -// DEBUG OFF + m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance"); +// DEBUG OFF if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array) { -- cgit v1.1 From 0f28fa400d1f853cc3c3ebd2707b08ed06d2f127 Mon Sep 17 00:00:00 2001 From: Master ScienceSim Date: Thu, 28 Oct 2010 09:00:39 -0700 Subject: Added background thread to handle delayed send and save of appearance to accommodate batching of the many updates that happen on login and teleport. Fixed handling of the serial property in appearance. --- OpenSim/Framework/AvatarAppearance.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index 05330c7..e66a1e7 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs @@ -233,7 +233,7 @@ namespace OpenSim.Framework // DEBUG ON m_log.WarnFormat("[AVATAR APPEARANCE] create empty appearance for {0}",owner); // DEBUG OFF - m_serial = 0; + m_serial = 1; m_owner = owner; SetDefaultWearables(); @@ -289,7 +289,7 @@ namespace OpenSim.Framework // DEBUG OFF if (appearance == null) { - m_serial = 0; + m_serial = 1; m_owner = UUID.Zero; SetDefaultWearables(); @@ -467,6 +467,9 @@ namespace OpenSim.Framework public override String ToString() { String s = ""; + + s += String.Format("Serial: {0}\n",m_serial); + for (uint i = 0; i < AvatarAppearance.TEXTURE_COUNT; i++) if (m_texture.FaceTextures[i] != null) s += String.Format("Texture: {0} --> {1}\n",i,m_texture.FaceTextures[i].TextureID); @@ -625,8 +628,8 @@ namespace OpenSim.Framework /// public void Unpack(OSDMap data) { - if ((data != null) && (data["appearance_serial"] != null)) - m_serial = data["appearance_serial"].AsInteger(); + if ((data != null) && (data["serial"] != null)) + m_serial = data["serial"].AsInteger(); if ((data != null) && (data["height"] != null)) m_avatarHeight = (float)data["height"].AsReal(); if ((data != null) && (data["hipoffset"] != null)) -- cgit v1.1 From 68666efd25f4d094949f31eae08ee17fd821b7e4 Mon Sep 17 00:00:00 2001 From: Master ScienceSim Date: Thu, 28 Oct 2010 12:00:04 -0700 Subject: Configuration of persistent baked textures and save/send delays. --- OpenSim/Framework/Capabilities/Caps.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Capabilities/Caps.cs b/OpenSim/Framework/Capabilities/Caps.cs index 6b64e12..872de9a 100644 --- a/OpenSim/Framework/Capabilities/Caps.cs +++ b/OpenSim/Framework/Capabilities/Caps.cs @@ -31,6 +31,7 @@ using System.Collections.Generic; using System.IO; using System.Reflection; using log4net; +using Nini.Config; using OpenMetaverse; using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; @@ -112,6 +113,8 @@ namespace OpenSim.Framework.Capabilities private string m_regionName; private object m_fetchLock = new Object(); + private bool m_persistBakedTextures = false; + public bool SSLCaps { get { return m_httpListener.UseSSL; } @@ -145,6 +148,15 @@ namespace OpenSim.Framework.Capabilities m_httpListenPort = httpPort; + m_persistBakedTextures = false; + IConfigSource config = m_Scene.Config; + if (config != null) + { + IConfig sconfig = config.Configs["Startup"]; + if (sconfig != null) + m_persistBakedTextures = sconfig.GetBoolean("PersistBakedTextures",m_persistBakedTextures); + } + if (httpServer != null && httpServer.UseSSL) { m_httpListenPort = httpServer.SSLPort; @@ -983,7 +995,7 @@ namespace OpenSim.Framework.Capabilities asset = new AssetBase(assetID, "Baked Texture", (sbyte)AssetType.Texture, m_agentID.ToString()); asset.Data = data; asset.Temporary = true; - asset.Local = true; + asset.Local = ! m_persistBakedTextures; // Local assets aren't persisted, non-local are m_assetCache.Store(asset); } -- cgit v1.1 From f5c9a56c8b73ef93db712fefe9f0366c4983e04f Mon Sep 17 00:00:00 2001 From: Master ScienceSim Date: Fri, 29 Oct 2010 13:37:13 -0700 Subject: Bunch of fixes that reduce the number of times appearance and avatar data are sent. And the number of times they are stored. --- OpenSim/Framework/AvatarAppearance.cs | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index e66a1e7..17e4eb4 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs @@ -45,6 +45,7 @@ namespace OpenSim.Framework public readonly static int VISUALPARAM_COUNT = 218; public readonly static int TEXTURE_COUNT = 21; + public readonly static byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; protected UUID m_owner; protected int m_serial = 1; @@ -347,14 +348,8 @@ namespace OpenSim.Framework protected virtual void SetDefaultTexture() { m_texture = new Primitive.TextureEntry(new UUID("C228D1CF-4B5D-4BA8-84F4-899A0796AA97")); - // The initialization of these seems to force a rebake regardless of whether it is needed - // m_textures.CreateFace(0).TextureID = new UUID("00000000-0000-1111-9999-000000000012"); - // m_textures.CreateFace(1).TextureID = Util.BLANK_TEXTURE_UUID; - // m_textures.CreateFace(2).TextureID = Util.BLANK_TEXTURE_UUID; - // m_textures.CreateFace(3).TextureID = new UUID("6522E74D-1660-4E7F-B601-6F48C1659A77"); - // m_textures.CreateFace(4).TextureID = new UUID("7CA39B4C-BD19-4699-AFF7-F93FD03D3E7B"); - // m_textures.CreateFace(5).TextureID = new UUID("00000000-0000-1111-9999-000000000010"); - // m_textures.CreateFace(6).TextureID = new UUID("00000000-0000-1111-9999-000000000011"); + for (uint i = 0; i < TEXTURE_COUNT; i++) + m_texture.CreateFace(i).TextureID = new UUID(AppearanceManager.DEFAULT_AVATAR_TEXTURE); } /// @@ -371,7 +366,7 @@ namespace OpenSim.Framework // made. We determine if any of the textures actually // changed to know if the appearance should be saved later bool changed = false; - for (int i = 0; i < AvatarAppearance.TEXTURE_COUNT; i++) + for (uint i = 0; i < AvatarAppearance.TEXTURE_COUNT; i++) { Primitive.TextureEntryFace newface = textureEntry.FaceTextures[i]; Primitive.TextureEntryFace oldface = m_texture.FaceTextures[i]; @@ -385,7 +380,6 @@ namespace OpenSim.Framework if (oldface != null && oldface.TextureID == newface.TextureID) continue; } - m_texture.FaceTextures[i] = (newface != null) ? new Primitive.TextureEntryFace(newface) : null; changed = true; // DEBUG ON if (newface != null) @@ -393,6 +387,7 @@ namespace OpenSim.Framework // DEBUG OFF } + m_texture = textureEntry; return changed; } @@ -415,8 +410,8 @@ namespace OpenSim.Framework if (visualParams[i] != m_visualparams[i]) { // DEBUG ON - m_log.WarnFormat("[AVATARAPPEARANCE] vparams changed [{0}] {1} ==> {2}", - i,m_visualparams[i],visualParams[i]); +// m_log.WarnFormat("[AVATARAPPEARANCE] vparams changed [{0}] {1} ==> {2}", +// i,m_visualparams[i],visualParams[i]); // DEBUG OFF m_visualparams[i] = visualParams[i]; changed = true; @@ -581,6 +576,8 @@ namespace OpenSim.Framework m_attachments.Clear(); } + #region Packing Functions + /// /// Create an OSDMap from the appearance data /// @@ -605,7 +602,7 @@ namespace OpenSim.Framework if (m_texture.FaceTextures[i] != null) textures.Add(OSD.FromUUID(m_texture.FaceTextures[i].TextureID)); else - textures.Add(OSD.FromUUID(UUID.Zero)); + textures.Add(OSD.FromUUID(AppearanceManager.DEFAULT_AVATAR_TEXTURE)); } data["textures"] = textures; @@ -657,12 +654,10 @@ namespace OpenSim.Framework OSDArray textures = (OSDArray)(data["textures"]); for (int i = 0; i < AvatarAppearance.TEXTURE_COUNT && i < textures.Count; i++) { + UUID textureID = AppearanceManager.DEFAULT_AVATAR_TEXTURE; if (textures[i] != null) - { - UUID textureID = textures[i].AsUUID(); - if (textureID != UUID.Zero) - m_texture.CreateFace((uint)i).TextureID = textureID; - } + textureID = textures[i].AsUUID(); + m_texture.CreateFace((uint)i).TextureID = new UUID(textureID); } } else @@ -697,6 +692,9 @@ namespace OpenSim.Framework } } + #endregion + + #region VPElement /// /// Viewer Params Array Element for AgentSetAppearance @@ -1460,5 +1458,6 @@ namespace OpenSim.Framework SKIRT_SKIRT_GREEN = 216, SKIRT_SKIRT_BLUE = 217 } + #endregion } } \ No newline at end of file -- cgit v1.1