/// <summary> /// Tell the Avatar Service about these baked textures and items /// </summary> /// <param name = "sp"></param> /// <param name = "textureEntry"></param> /// <param name = "wearables"></param> private void CacheWearableData(IScenePresence sp, Primitive.TextureEntry textureEntry, WearableCache[] wearables) { /*if (textureEntry == null || wearables.Length == 0) return; AvatarWearable cachedWearable = new AvatarWearable {MaxItems = 0}; //Unlimited items #if (!ISWIN) foreach (WearableCache item in wearables) { if (textureEntry.FaceTextures[item.TextureIndex] != null) { cachedWearable.Add(item.CacheID, textureEntry.FaceTextures[item.TextureIndex].TextureID); } } #else foreach (WearableCache item in wearables.Where(item => textureEntry.FaceTextures[item.TextureIndex] != null)) { cachedWearable.Add(item.CacheID, textureEntry.FaceTextures[item.TextureIndex].TextureID); } #endif m_scene.AvatarService.CacheWearableData(sp.UUID, cachedWearable);*/ }
/// <summary> /// Set appearance data (textureentry and slider settings) received from the client /// </summary> /// <param name = "textureEntry"></param> /// <param name = "visualParams"></param> /// <param name="client"></param> /// <param name="wearables"></param> public void SetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams, WearableCache[] wearables) { IScenePresence sp = m_scene.GetScenePresence(client.AgentId); IAvatarAppearanceModule appearance = sp.RequestModuleInterface<IAvatarAppearanceModule>(); //MainConsole.Instance.InfoFormat("[AVFACTORY]: start SetAppearance for {0}", client.AgentId); // Process the texture entry transactionally, this doesn't guarantee that Appearance is // going to be handled correctly but it does serialize the updates to the appearance lock (m_setAppearanceLock) { bool texturesChanged = false; bool visualParamsChanged = false; if (textureEntry != null) { List<UUID> ChangedTextures = new List<UUID>(); texturesChanged = appearance.Appearance.SetTextureEntries(textureEntry, out ChangedTextures); // MainConsole.Instance.WarnFormat("[AVFACTORY]: Prepare to check textures for {0}",client.AgentId); //Do this async as it accesses the asset service (could be remote) multiple times Util.FireAndForget(delegate { //Validate all the textures now that we've updated ValidateBakedTextureCache(client, false); //The client wants us to cache the baked textures CacheWearableData(sp, textureEntry, wearables); }); // MainConsole.Instance.WarnFormat("[AVFACTORY]: Complete texture check for {0}",client.AgentId); } // Process the visual params, this may change height as well if (visualParams != null) { //Now update the visual params and see if they have changed visualParamsChanged = appearance.Appearance.SetVisualParams(visualParams); //Fix the height only if the parameters have changed if (visualParamsChanged && appearance.Appearance.AvatarHeight > 0) sp.SetHeight(appearance.Appearance.AvatarHeight); } // If something changed in the appearance then queue an appearance save if (texturesChanged || visualParamsChanged) QueueAppearanceSave(client.AgentId); appearance.Appearance.Serial++; } // And always queue up an appearance update to send out QueueAppearanceSend(client.AgentId); // MainConsole.Instance.WarnFormat("[AVFACTORY]: complete SetAppearance for {0}:\n{1}",client.AgentId,sp.Appearance.ToString()); }