From f97278610c2ab9717b32b9c64bc5865b0b47dd41 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Mon, 4 Jul 2011 17:54:14 +0300 Subject: [PATCH] Fixed updating avatar appearance Signed-off-by: root --- OpenSim/Framework/AvatarAppearance.cs | 4 ++- .../AvatarFactory/AvatarFactoryModule.cs | 27 ++++++++++++------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index 5a6b265aad..716baab300 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs @@ -196,6 +196,9 @@ namespace OpenSim.Framework if (appearance.VisualParams != null) m_visualparams = (byte[])appearance.VisualParams.Clone(); + m_avatarHeight = appearance.m_avatarHeight; + m_hipOffset = appearance.m_hipOffset; + // Copy the attachment, force append mode since that ensures consistency m_attachments = new Dictionary>(); foreach (AvatarAttachment attachment in appearance.GetAttachments()) @@ -237,7 +240,6 @@ namespace OpenSim.Framework { m_serial = 0; - SetDefaultParams(); SetDefaultTexture(); //for (int i = 0; i < BAKE_INDICES.Length; i++) diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 75dbeb898e..9037c804a0 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -210,7 +210,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory changed = sp.Appearance.SetVisualParams(visualParams); if (sp.Appearance.AvatarHeight > 0) sp.SetHeight(sp.Appearance.AvatarHeight); - } + } // Process the baked texture array if (textureEntry != null) @@ -387,11 +387,11 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory // m_log.WarnFormat("[AVFACTORY]: AvatarIsWearing called for {0}", client.AgentId); // we need to clean out the existing textures - sp.Appearance.ResetAppearance(); + sp.Appearance.ResetAppearance(); - // operate on a copy of the appearance so we don't have to lock anything + // operate on a copy of the appearance so we don't have to lock anything yet AvatarAppearance avatAppearance = new AvatarAppearance(sp.Appearance, false); - + foreach (AvatarWearingArgs.Wearable wear in e.NowWearing) { if (wear.Type < AvatarWearable.MAX_WEARABLES) @@ -403,12 +403,19 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory // This could take awhile since it needs to pull inventory SetAppearanceAssets(sp.UUID, ref avatAppearance); - // could get fancier with the locks here, but in the spirit of "last write wins" - // this should work correctly, also, we don't need to send the appearance here - // since the "iswearing" will trigger a new set of visual param and baked texture changes - // when those complete, the new appearance will be sent - sp.Appearance = avatAppearance; - QueueAppearanceSave(client.AgentId); + lock (m_setAppearanceLock) + { + // Update only those fields that we have changed. This is important because the viewer + // often sends AvatarIsWearing and SetAppearance packets at once, and AvatarIsWearing + // shouldn't overwrite the changes made in SetAppearance. + sp.Appearance.Wearables = avatAppearance.Wearables; + sp.Appearance.Texture = avatAppearance.Texture; + + // We don't need to send the appearance here since the "iswearing" will trigger a new set + // of visual param and baked texture changes. When those complete, the new appearance will be sent + + QueueAppearanceSave(client.AgentId); + } } private void SetAppearanceAssets(UUID userID, ref AvatarAppearance appearance)