From 20eb8e54ac511b5e8988cb3c3701c824b41170c4 Mon Sep 17 00:00:00 2001 From: diva Date: Mon, 23 Feb 2009 00:51:31 +0000 Subject: A little bit more tweaking with appearance. Now passing both the wearables and the textures referred to in the Texture faces of AvatarAppearance. The textures are still not being acted upon on the other side, but they will. Note: will make avies coming from older sims casper or grey. Upgrade! Related to mantis #3204. --- .../Framework/Scenes/ChildAgentDataUpdate.cs | 91 +++++++++------------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 50 ++++++++---- 2 files changed, 75 insertions(+), 66 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/ChildAgentDataUpdate.cs b/OpenSim/Region/Framework/Scenes/ChildAgentDataUpdate.cs index 38eceb1..be3069a 100644 --- a/OpenSim/Region/Framework/Scenes/ChildAgentDataUpdate.cs +++ b/OpenSim/Region/Framework/Scenes/ChildAgentDataUpdate.cs @@ -207,39 +207,6 @@ namespace OpenSim.Region.Framework.Scenes } } - //public class AgentAnimationData - //{ - // public UUID Animation; - // public UUID ObjectID; - - // public AgentAnimationData(UUID anim, UUID obj) - // { - // Animation = anim; - // ObjectID = obj; - // } - - // public AgentAnimationData(OSDMap args) - // { - // UnpackUpdateMessage(args); - // } - - // public OSDMap PackUpdateMessage() - // { - // OSDMap anim = new OSDMap(); - // anim["animation"] = OSD.FromUUID(Animation); - // anim["object_id"] = OSD.FromUUID(ObjectID); - // return anim; - // } - - // public void UnpackUpdateMessage(OSDMap args) - // { - // if (args["animation"] != null) - // Animation = args["animation"].AsUUID(); - // if (args["object_id"] != null) - // ObjectID = args["object_id"].AsUUID(); - // } - //} - public class AgentData : IAgentData { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -276,16 +243,17 @@ namespace OpenSim.Region.Framework.Scenes public bool AlwaysRun; public UUID PreyAgent; public Byte AgentAccess; - public UUID[] AgentTextures; public UUID ActiveGroupID; public AgentGroupData[] Groups; public Animation[] Anims; public UUID GranterID; - public Dictionary NVPairs; + // Appearance + public UUID[] AgentTextures; public byte[] VisualParams; + public UUID[] Wearables; public string CallbackURI; @@ -325,14 +293,6 @@ namespace OpenSim.Region.Framework.Scenes args["prey_agent"] = OSD.FromUUID(PreyAgent); args["agent_access"] = OSD.FromString(AgentAccess.ToString()); - if ((AgentTextures != null) && (AgentTextures.Length > 0)) - { - OSDArray textures = new OSDArray(AgentTextures.Length); - foreach (UUID uuid in AgentTextures) - textures.Add(OSD.FromUUID(uuid)); - args["agent_textures"] = textures; - } - args["active_group_id"] = OSD.FromUUID(ActiveGroupID); if ((Groups != null) && (Groups.Length > 0)) @@ -351,10 +311,26 @@ namespace OpenSim.Region.Framework.Scenes args["animations"] = anims; } + if ((AgentTextures != null) && (AgentTextures.Length > 0)) + { + OSDArray textures = new OSDArray(AgentTextures.Length); + foreach (UUID uuid in AgentTextures) + textures.Add(OSD.FromUUID(uuid)); + args["agent_textures"] = textures; + } + if ((VisualParams != null) && (VisualParams.Length > 0)) args["visual_params"] = OSD.FromBinary(VisualParams); - // Last few fields are still missing: granter and NVPais + // We might not pass this in all cases... + if ((Wearables != null) && (Wearables.Length > 0)) + { + OSDArray wears = new OSDArray(Wearables.Length); + foreach (UUID uuid in Wearables) + wears.Add(OSD.FromUUID(uuid)); + args["wearables"] = wears; + } + if ((CallbackURI != null) && (!CallbackURI.Equals(""))) args["callback_uri"] = OSD.FromString(CallbackURI); @@ -441,15 +417,6 @@ namespace OpenSim.Region.Framework.Scenes if (args["agent_access"] != null) Byte.TryParse(args["agent_access"].AsString(), out AgentAccess); - if ((args["agent_textures"] != null) && (args["agent_textures"]).Type == OSDType.Array) - { - OSDArray textures = (OSDArray)(args["agent_textures"]); - AgentTextures = new UUID[textures.Count]; - int i = 0; - foreach (OSD o in textures) - AgentTextures[i++] = o.AsUUID(); - } - if (args["active_group_id"] != null) ActiveGroupID = args["active_group_id"].AsUUID(); @@ -481,9 +448,27 @@ namespace OpenSim.Region.Framework.Scenes } } + if ((args["agent_textures"] != null) && (args["agent_textures"]).Type == OSDType.Array) + { + OSDArray textures = (OSDArray)(args["agent_textures"]); + AgentTextures = new UUID[textures.Count]; + int i = 0; + foreach (OSD o in textures) + AgentTextures[i++] = o.AsUUID(); + } + if (args["visual_params"] != null) VisualParams = 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(); + } + if (args["callback_uri"] != null) CallbackURI = args["callback_uri"].AsString(); } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index dd8c719..85437f6 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2646,20 +2646,43 @@ namespace OpenSim.Region.Framework.Scenes try { + // We might not pass the Wearables in all cases... + // They're only needed so that persistent changes to the appearance + // are preserved in the new region where the user is moving to. + // But in Hypergrid we might not let this happen. int i = 0; - UUID[] textures = new UUID[m_appearance.Wearables.Length * 2]; + UUID[] wears = new UUID[m_appearance.Wearables.Length * 2]; foreach (AvatarWearable aw in m_appearance.Wearables) { if (aw != null) { - textures[i++] = aw.ItemID; - textures[i++] = aw.AssetID; + wears[i++] = aw.ItemID; + wears[i++] = aw.AssetID; } else - m_log.DebugFormat("[SCENE PRESENCE]: Null wearable in CopyTo"); + { + wears[i++] = UUID.Zero; + wears[i++] = UUID.Zero; + } } - cAgent.AgentTextures = textures; + cAgent.Wearables = wears; + cAgent.VisualParams = m_appearance.VisualParams; + + // Textures is not really needed in the base case, I think. But it's handy for + // the Hypergrid and other decentralized models, so that we know which + // textures to fecth from the user's asset server. + i = 0; + UUID[] textures = new UUID[m_appearance.Texture.FaceTextures.Length]; + foreach (Primitive.TextureEntryFace face in m_appearance.Texture.FaceTextures) + { + if (face != null) + textures[i] = face.TextureID; + else + textures[i] = UUID.Zero; + ++i; + } + cAgent.AgentTextures = textures; } catch (Exception e) { @@ -2707,18 +2730,19 @@ namespace OpenSim.Region.Framework.Scenes uint i = 0; try { - AvatarWearable[] wearables = new AvatarWearable[cAgent.AgentTextures.Length / 2]; - for (uint n = 0; n < cAgent.AgentTextures.Length; n += 2) + AvatarWearable[] wears = new AvatarWearable[cAgent.Wearables.Length / 2]; + for (uint n = 0; n < cAgent.Wearables.Length; n += 2) { - UUID itemId = cAgent.AgentTextures[n]; - UUID assetId = cAgent.AgentTextures[n + 1]; - wearables[i++] = new AvatarWearable(itemId, assetId); - //te.CreateFace(i++).TextureID = assetId; + UUID itemId = cAgent.Wearables[n]; + UUID assetId = cAgent.Wearables[n + 1]; + wears[i++] = new AvatarWearable(itemId, assetId); } - m_appearance.Wearables = wearables; + m_appearance.Wearables = wears; // We're setting it here to default, but the viewer will soon send a SetAppearance that will - // set things straight. We should probably pass these textures too... + // set things straight. We should probably parse these textures too, we have them... + // In any case, the least we need to do is to check if this is HG and fetch the textures + // so that they can then be distributed to the other clients that ask for them later. Primitive.TextureEntry te = AvatarAppearance.GetDefaultTexture(); //new Primitive.TextureEntry(UUID.Random()); m_appearance.SetAppearance(te.ToBytes(), new List(cAgent.VisualParams)); -- cgit v1.1