diff --git a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs index 75e714d9c0..2c395ae4d0 100644 --- a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs +++ b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs @@ -577,6 +577,7 @@ namespace OpenSim.Client.MXP.ClientStack public event BakeTerrain OnBakeTerrain; public event EstateChangeInfo OnEstateChangeInfo; public event SetAppearance OnSetAppearance; + public event SetAppearanceRaw OnSetAppearanceRaw; public event AvatarNowWearing OnAvatarNowWearing; public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv; public event RezMultipleAttachmentsFromInv OnRezMultipleAttachmentsFromInv; diff --git a/OpenSim/Client/Sirikata/ClientStack/SirikataClientView.cs b/OpenSim/Client/Sirikata/ClientStack/SirikataClientView.cs index 806d069ca5..5287222ec5 100644 --- a/OpenSim/Client/Sirikata/ClientStack/SirikataClientView.cs +++ b/OpenSim/Client/Sirikata/ClientStack/SirikataClientView.cs @@ -223,6 +223,7 @@ namespace OpenSim.Client.Sirikata.ClientStack public event BakeTerrain OnBakeTerrain; public event EstateChangeInfo OnEstateChangeInfo; public event SetAppearance OnSetAppearance; + public event SetAppearanceRaw OnSetAppearanceRaw; public event AvatarNowWearing OnAvatarNowWearing; public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv; public event RezMultipleAttachmentsFromInv OnRezMultipleAttachmentsFromInv; diff --git a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs index a7bab99bc6..f9b7efca01 100644 --- a/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs +++ b/OpenSim/Client/VWoHTTP/ClientStack/VWHClientView.cs @@ -226,6 +226,7 @@ namespace OpenSim.Client.VWoHTTP.ClientStack public event BakeTerrain OnBakeTerrain = delegate { }; public event EstateChangeInfo OnEstateChangeInfo = delegate { }; public event SetAppearance OnSetAppearance = delegate { }; + public event SetAppearanceRaw OnSetAppearanceRaw = delegate { }; public event AvatarNowWearing OnAvatarNowWearing = delegate { }; public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv = delegate { return new UUID(); }; public event RezMultipleAttachmentsFromInv OnRezMultipleAttachmentsFromInv = delegate { }; diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index 5da8ba1368..0c600f6146 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs @@ -382,6 +382,8 @@ namespace OpenSim.Framework m_texture = textureEntry; if (visualParams != null) m_visualparams = visualParams; + if (m_visualparams == null) + return; m_avatarHeight = 1.23077f // Shortest possible avatar height + 0.516945f * (float)m_visualparams[(int)VPElement.SHAPE_HEIGHT] / 255.0f // Body height diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index c6faa0d98d..95cd4984b0 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -67,6 +67,7 @@ namespace OpenSim.Framework public delegate void NetworkStats(int inPackets, int outPackets, int unAckedBytes); public delegate void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams); + public delegate void SetAppearanceRaw(IClientAPI sender, UUID agentID, byte[] vp, Primitive.TextureEntry te); public delegate void StartAnim(IClientAPI remoteClient, UUID animID); @@ -865,6 +866,7 @@ namespace OpenSim.Framework event EstateChangeInfo OnEstateChangeInfo; // [Obsolete("LLClientView Specific.")] event SetAppearance OnSetAppearance; + event SetAppearanceRaw OnSetAppearanceRaw; // [Obsolete("LLClientView Specific - Replace and rename OnAvatarUpdate. Difference from SetAppearance?")] event AvatarNowWearing OnAvatarNowWearing; event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv; diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 48d4c2f7f3..216c499afc 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -120,6 +120,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP public event Action OnRegionHandShakeReply; public event GenericCall2 OnRequestWearables; public event SetAppearance OnSetAppearance; + public event SetAppearanceRaw OnSetAppearanceRaw; public event AvatarNowWearing OnAvatarNowWearing; public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv; public event RezMultipleAttachmentsFromInv OnRezMultipleAttachmentsFromInv; @@ -5606,7 +5607,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP #endregion SetAppearance handlerSetAppearance = OnSetAppearance; - if (handlerSetAppearance != null) + SetAppearanceRaw handlerSetAppearanceRaw = OnSetAppearanceRaw; + //if (handlerSetAppearance != null) { // Temporarily protect ourselves from the mantis #951 failure. // However, we could do this for several other handlers where a failure isn't terminal @@ -5622,7 +5624,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (appear.ObjectData.TextureEntry.Length > 1) te = new Primitive.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length); - handlerSetAppearance(te, visualparams); + if (handlerSetAppearance != null) + handlerSetAppearance(te, visualparams); + if (handlerSetAppearanceRaw != null) + handlerSetAppearanceRaw(this, AgentId, visualparams, te); } catch (Exception e) { diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncAvatar.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncAvatar.cs index c0f4dffeab..a956c76f4e 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncAvatar.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncAvatar.cs @@ -61,6 +61,7 @@ namespace OpenSim.Region.Examples.RegionSyncModule public event ModifyTerrain OnModifyTerrain; public event BakeTerrain OnBakeTerrain; public event SetAppearance OnSetAppearance; + public event SetAppearanceRaw OnSetAppearanceRaw; public event AvatarNowWearing OnAvatarNowWearing; public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv; public event RezMultipleAttachmentsFromInv OnRezMultipleAttachmentsFromInv; diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs index dd60172763..2f12e22efe 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs @@ -121,6 +121,7 @@ namespace OpenSim.Region.Examples.RegionSyncModule RemoveLocalClient(kvp.Key, m_scene); // Remove the agent update handler from the client kvp.Value.OnAgentUpdateRaw -= HandleAgentUpdateRaw; + kvp.Value.OnSetAppearanceRaw -= HandleSetAppearanceRaw; } } // Close the connection @@ -515,6 +516,7 @@ namespace OpenSim.Region.Examples.RegionSyncModule // Register for interesting client events which will be forwarded to auth sim // These are the raw packet data blocks from the client, intercepted and sent up to the sim client.OnAgentUpdateRaw += HandleAgentUpdateRaw; + client.OnSetAppearanceRaw += HandleSetAppearanceRaw; client.OnChatFromClientRaw += HandleChatFromClientRaw; } @@ -536,6 +538,18 @@ namespace OpenSim.Region.Examples.RegionSyncModule Send(new RegionSyncMessage(RegionSyncMessage.MsgType.AgentUpdate, agentData)); } + public void HandleSetAppearanceRaw(object sender, UUID agentID, byte[] vp, Primitive.TextureEntry te) + { + if (te != null) + { + OSDMap data = new OSDMap(2); + data["id"] = OSDUUID.FromUUID(agentID); + data["vp"] = new OSDBinary(vp); + data["te"] = te.GetOSD(); + Send(new RegionSyncMessage(RegionSyncMessage.MsgType.AvatarAppearance, OSDParser.SerializeJsonString(data))); + } + } + public void HandleChatFromClientRaw(object sender, byte[] chatData) { Send(new RegionSyncMessage(RegionSyncMessage.MsgType.ChatFromClient, chatData)); diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientView.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientView.cs index 9367cccbed..9064dd74e6 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientView.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientView.cs @@ -288,6 +288,44 @@ namespace OpenSim.Region.Examples.RegionSyncModule } return HandlerFailure(msg, "Could not deserialize JSON data."); + } + case RegionSyncMessage.MsgType.AvatarAppearance: + { + OSDMap data = DeserializeMessage(msg); + if (data != null) + { + UUID agentID = data["id"].AsUUID(); + + if (agentID != null && agentID != UUID.Zero) + { + ScenePresence presence; + if (m_scene.TryGetScenePresence(agentID, out presence)) + { + string name = presence.Name; + Primitive.TextureEntry te = Primitive.TextureEntry.FromOSD(data["te"]); + byte[] vp = data["vp"].AsBinary(); + + byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; + for (int i = 0; i < BAKE_INDICES.Length; i++) + { + int j = BAKE_INDICES[i]; + Primitive.TextureEntryFace face = te.FaceTextures[j]; + if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE) + if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) + HandlerDebug(msg, "Missing baked texture " + face.TextureID + " (" + j + ") for avatar " + name); + } + + presence.SetAppearance(te, vp); + return HandlerDebug(msg, String.Format("Agent \"{0}\" ({1}) updated their appearance.", name, agentID)); + } + else + { + return HandlerFailure(msg, String.Format("Agent {0} not found in the scene.", agentID)); + } + } + } + return HandlerFailure(msg, "Could not deserialize JSON data."); + } default: { diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncMessage.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncMessage.cs index 3a963c3a8b..282f8a427e 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncMessage.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncMessage.cs @@ -33,6 +33,8 @@ namespace OpenSim.Region.Examples.RegionSyncModule RemovedObject, // objects NewAvatar, // avatars UpdatedAvatar, // avatars + AnimateAvatar, + AvatarAppearance, RemovedAvatar, // avatars ChatFromSim, // BIDIR diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServer.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServer.cs index 8f84dda87a..7b3692599f 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServer.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServer.cs @@ -41,6 +41,7 @@ namespace OpenSim.Region.Examples.RegionSyncModule // The list is read most of the time and only updated when a new client manager // connects, so we just replace the list when it changes. Iterators on this // list need to be able to handle if an element is shutting down. + private object m_clientview_lock = new object(); private HashSet m_client_views = new HashSet(); // Check if any of the client views are in a connected state @@ -55,27 +56,36 @@ namespace OpenSim.Region.Examples.RegionSyncModule // Add the client view to the list and increment synced client counter public void AddSyncedClient(RegionSyncClientView rscv) { - HashSet newlist = new HashSet(m_client_views); - newlist.Add(rscv); - // Threads holding the previous version of the list can keep using it since - // they will not hold it for long and get a new copy next time they need to iterate - Interlocked.Exchange>(ref m_client_views, newlist); + lock (m_clientview_lock) + { + HashSet currentlist = m_client_views; + HashSet newlist = new HashSet(currentlist); + newlist.Add(rscv); + // Threads holding the previous version of the list can keep using it since + // they will not hold it for long and get a new copy next time they need to iterate + m_client_views = newlist; + } } // Remove the client view from the list and decrement synced client counter public void RemoveSyncedClient(RegionSyncClientView rscv) { - HashSet newlist = new HashSet(m_client_views); - newlist.Remove(rscv); - // Threads holding the previous version of the list can keep using it since - // they will not hold it for long and get a new copy next time they need to iterate - Interlocked.Exchange>(ref m_client_views, newlist); + lock (m_clientview_lock) + { + HashSet currentlist = m_client_views; + HashSet newlist = new HashSet(currentlist); + newlist.Remove(rscv); + // Threads holding the previous version of the list can keep using it since + // they will not hold it for long and get a new copy next time they need to iterate + m_client_views = newlist; + } } public void ReportStats() { // We should be able to safely iterate over our reference to the list since // the only places which change it will replace it with an updated version + m_log.Error("SERVER, MSGIN, MSGOUT, BYTESIN, BYTESOUT"); foreach (RegionSyncClientView rscv in m_client_views) { m_log.ErrorFormat("{0}: {1}", rscv.Description, rscv.GetStats()); @@ -160,31 +170,27 @@ namespace OpenSim.Region.Examples.RegionSyncModule public void Broadcast(RegionSyncMessage msg) { List closed = null; - //lock (m_client_views) + foreach (RegionSyncClientView client in m_client_views) { - //m_log.WarnFormat("[REGION SYNC SERVER] Broadcasting {0} to all connected RegionSyncClients", msg.ToString()); - foreach (RegionSyncClientView client in m_client_views) + // If connected, send the message. + if (client.Connected) { - // If connected, send the message. - if (client.Connected) - { - client.Send(msg); - } - // Else, remove the client view from the list - else - { - if (closed == null) - closed = new List(); - closed.Add(client); - } + client.Send(msg); } - if (closed != null) + // Else, remove the client view from the list + else { - foreach (RegionSyncClientView rscv in closed) - RemoveSyncedClient(rscv); - //m_client_views.Remove(rscv); + if (closed == null) + closed = new List(); + closed.Add(client); } } + if (closed != null) + { + foreach (RegionSyncClientView rscv in closed) + RemoveSyncedClient(rscv); + //m_client_views.Remove(rscv); + } } } } diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index e1bfee9cd4..38e1d117ad 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs @@ -62,6 +62,7 @@ namespace OpenSim.Region.Examples.SimpleModule public event ModifyTerrain OnModifyTerrain; public event BakeTerrain OnBakeTerrain; public event SetAppearance OnSetAppearance; + public event SetAppearanceRaw OnSetAppearanceRaw; public event AvatarNowWearing OnAvatarNowWearing; public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv; public event RezMultipleAttachmentsFromInv OnRezMultipleAttachmentsFromInv; diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index ef42e1be9c..fa3a5debe1 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -724,6 +724,10 @@ namespace OpenSim.Region.Framework.Scenes // TODO: Change default to true once the feature is supported m_usePreJump = startupConfig.GetBoolean("enableprejump", false); + m_maxNonphys = 256f; + m_maxPhys = 256f; + + /* m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); if (RegionInfo.NonphysPrimMax > 0) { @@ -736,6 +740,7 @@ namespace OpenSim.Region.Framework.Scenes { m_maxPhys = RegionInfo.PhysPrimMax; } + */ // Here, if clamping is requested in either global or // local config, it will be used @@ -1595,7 +1600,7 @@ namespace OpenSim.Region.Framework.Scenes { List resultIds = new List(); List resultLocations = new List(); - + /* ForEachScenePresence(delegate(ScenePresence sp) { if (sp.IsChildAgent) @@ -1603,9 +1608,10 @@ namespace OpenSim.Region.Framework.Scenes resultIds.Add(sp.UUID); resultLocations.Add(sp.AbsolutePosition); }); + */ ids = resultIds; locations = resultLocations; - + /* if (sp.ParentID != 0) { @@ -2704,6 +2710,10 @@ namespace OpenSim.Region.Framework.Scenes GetAvatarAppearance(client, out appearance); presence.Appearance = appearance; + // REGION SYNC + // The owner is not being set properly when there is no circuit. Hmmm + presence.Appearance.Owner = presence.UUID; + presence.initializeScenePresence(client, RegionInfo, this); m_sceneGraph.AddScenePresence(presence); diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index d230cc61dc..1e360ad957 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -68,7 +68,8 @@ namespace OpenSim.Region.Framework.Scenes #region Fields - protected Dictionary m_scenePresences = new Dictionary(); + protected object m_presenceLock = new object(); + protected Dictionary m_scenePresenceMap = new Dictionary(); protected ScenePresence[] m_scenePresenceArray = new ScenePresence[0]; // SceneObjects is not currently populated or used. @@ -132,10 +133,12 @@ namespace OpenSim.Region.Framework.Scenes protected internal void Close() { - lock (m_scenePresences) + lock (m_presenceLock) { - m_scenePresences.Clear(); - m_scenePresenceArray = new ScenePresence[0]; + Dictionary newmap = new Dictionary(); + ScenePresence[] newarray = new ScenePresence[0]; + m_scenePresenceMap = newmap; + m_scenePresenceArray = newarray; } lock (m_dictionary_lock) @@ -518,34 +521,39 @@ namespace OpenSim.Region.Framework.Scenes Entities[presence.UUID] = presence; - lock (m_scenePresences) + lock (m_presenceLock) { - if (!m_scenePresences.ContainsKey(presence.UUID)) + // We are going to swap the map and array references with modified copies + Dictionary newmap; + ScenePresence[] newarray; + if (m_scenePresenceMap.ContainsKey(presence.UUID)) { - m_scenePresences.Add(presence.UUID, presence); - - // Create a new array of ScenePresence references - int oldLength = m_scenePresenceArray.Length; - ScenePresence[] newArray = new ScenePresence[oldLength + 1]; - Array.Copy(m_scenePresenceArray, newArray, oldLength); - newArray[oldLength] = presence; - m_scenePresenceArray = newArray; + // copy the map and update the presence reference + newmap = new Dictionary(m_scenePresenceMap); + m_scenePresenceMap[presence.UUID] = presence; + // copy the array and update the presence reference + newarray = new ScenePresence[m_scenePresenceArray.Length]; + for(int i = 0; i < m_scenePresenceArray.Length; ++i) + { + if(m_scenePresenceArray[i].UUID == presence.UUID) + newarray[i] = presence; + else + newarray[i] = m_scenePresenceArray[i]; + } } else { - m_scenePresences[presence.UUID] = presence; - - // Do a linear search through the array of ScenePresence references - // and update the modified entry - for (int i = 0; i < m_scenePresenceArray.Length; i++) - { - if (m_scenePresenceArray[i].UUID == presence.UUID) - { - m_scenePresenceArray[i] = presence; - break; - } - } + // copy the map and add the new presence reference + newmap = new Dictionary(m_scenePresenceMap); + newmap[presence.UUID] = presence; + // Copy the array and add the new presence reference + int oldLength = m_scenePresenceArray.Length; + newarray = new ScenePresence[oldLength+1]; + Array.Copy(m_scenePresenceArray, newarray, oldLength); + newarray[oldLength] = presence; } + m_scenePresenceMap = newmap; + m_scenePresenceArray = newarray; } } @@ -561,25 +569,30 @@ namespace OpenSim.Region.Framework.Scenes agentID); } - lock (m_scenePresences) + lock (m_presenceLock) { - if (m_scenePresences.Remove(agentID)) + // Copy the map + Dictionary newmap = new Dictionary(m_scenePresenceMap); + // Remove the presence reference from the dictionary + if (newmap.Remove(agentID)) { // Copy all of the elements from the previous array // into the new array except the removed element int oldLength = m_scenePresenceArray.Length; - ScenePresence[] newArray = new ScenePresence[oldLength - 1]; + ScenePresence[] newarray = new ScenePresence[oldLength - 1]; int j = 0; - for (int i = 0; i < m_scenePresenceArray.Length; i++) + for (int i = 0; i < oldLength; ++i) { ScenePresence presence = m_scenePresenceArray[i]; if (presence.UUID != agentID) { - newArray[j] = presence; + newarray[j] = presence; ++j; } } - m_scenePresenceArray = newArray; + // Swap out the dictionary and list with new references + m_scenePresenceMap = newmap; + m_scenePresenceArray = newarray; } else { @@ -698,16 +711,15 @@ namespace OpenSim.Region.Framework.Scenes } /// - /// Request a copy of m_scenePresences in this World + /// Get a reference to the scene presence list. Changes to the list will be done in a copy /// There is no guarantee that presences will remain in the scene after the list is returned. /// This list should remain private to SceneGraph. Callers wishing to iterate should instead /// pass a delegate to ForEachScenePresence. /// /// - private List GetScenePresences() + private ScenePresence[] GetScenePresences() { - lock (m_scenePresences) - return new List(m_scenePresenceArray); + return m_scenePresenceArray; } /// @@ -717,12 +729,10 @@ namespace OpenSim.Region.Framework.Scenes /// null if the presence was not found protected internal ScenePresence GetScenePresence(UUID agentID) { - ScenePresence sp; - lock (m_scenePresences) - { - m_scenePresences.TryGetValue(agentID, out sp); - } - return sp; + Dictionary presences = m_scenePresenceMap; + ScenePresence presence; + presences.TryGetValue(agentID, out presence); + return presence; } /// @@ -733,10 +743,11 @@ namespace OpenSim.Region.Framework.Scenes /// null if the presence was not found protected internal ScenePresence GetScenePresence(string firstName, string lastName) { - foreach (ScenePresence presence in GetScenePresences()) + ScenePresence[] presences = GetScenePresences(); + for(int i = 0; i < presences.Length; ++i) { - if (presence.Firstname == firstName && presence.Lastname == lastName) - return presence; + if (presences[i].Firstname == firstName && presences[i].Lastname == lastName) + return presences[i]; } return null; } @@ -748,29 +759,31 @@ namespace OpenSim.Region.Framework.Scenes /// null if the presence was not found protected internal ScenePresence GetScenePresence(uint localID) { - foreach (ScenePresence presence in GetScenePresences()) - if (presence.LocalId == localID) - return presence; + ScenePresence[] presences = GetScenePresences(); + for (int i = 0; i < presences.Length; ++i) + { + if (presences[i].LocalId == localID) + return presences[i]; + } return null; } protected internal bool TryGetScenePresence(UUID agentID, out ScenePresence avatar) { - lock (m_scenePresences) - { - m_scenePresences.TryGetValue(agentID, out avatar); - } + Dictionary presences = m_scenePresenceMap; + presences.TryGetValue(agentID, out avatar); return (avatar != null); } protected internal bool TryGetAvatarByName(string name, out ScenePresence avatar) { avatar = null; - foreach (ScenePresence presence in GetScenePresences()) + ScenePresence[] presences = GetScenePresences(); + for(int i = 0; i < presences.Length; ++i ) { - if (String.Compare(name, presence.ControllingClient.Name, true) == 0) + if (String.Compare(name, presences[i].ControllingClient.Name, true) == 0) { - avatar = presence; + avatar = presences[i]; break; } } @@ -1036,12 +1049,14 @@ namespace OpenSim.Region.Framework.Scenes }); Parallel.ForEach(GetScenePresences(), protectedAction); */ - // For now, perform actiona serially - foreach (ScenePresence sp in GetScenePresences()) + // For now, perform actions serially + ScenePresence[] presences = GetScenePresences(); + for(int i = 0; i < presences.Length; ++i) { + ScenePresence presence = presences[i]; try { - action(sp); + action(presence); } catch (Exception e) { diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 8279c803ae..bed8aea8b0 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -77,7 +77,7 @@ 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 }; -// private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); + private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags)); private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f); @@ -672,6 +672,11 @@ namespace OpenSim.Region.Framework.Scenes m_sendCourseLocationsMethod = SendCoarseLocationsDefault; CreateSceneViewer(); m_animator = new ScenePresenceAnimator(this); + + Primitive.TextureEntry te = AvatarAppearance.GetDefaultTexture(); + byte[] vp = AvatarAppearance.GetDefaultVisualParams(); + m_appearance = new AvatarAppearance(UUID); + m_appearance.SetAppearance(te, vp); } private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this() @@ -707,7 +712,7 @@ namespace OpenSim.Region.Framework.Scenes AdjustKnownSeeds(); // TODO: I think, this won't send anything, as we are still a child here... - Animator.TrySetMovementAnimation("STAND"); + Animator.TrySetMovementAnimation("STAND"); // we created a new ScenePresence (a new child agent) in a fresh region. // Request info about all the (root) agents in this region @@ -722,13 +727,13 @@ namespace OpenSim.Region.Framework.Scenes AvatarWearable[] wearables) : this(client, world, reginfo) { - m_appearance = new AvatarAppearance(m_uuid, wearables, visualParams); + //m_appearance = new AvatarAppearance(m_uuid, wearables, visualParams); } public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance) : this(client, world, reginfo) { - m_appearance = appearance; + //m_appearance = appearance; } private void CreateSceneViewer() @@ -738,14 +743,17 @@ namespace OpenSim.Region.Framework.Scenes public void RegisterToEvents() { - m_controllingClient.OnRequestWearables += SendWearables; + // REGION SYNC + if (!m_scene.IsSyncedClient()) + { + m_controllingClient.OnAgentUpdate += HandleAgentUpdate; + } + m_controllingClient.OnSetAppearance += SetAppearance; + m_controllingClient.OnRequestWearables += SendWearables; m_controllingClient.OnCompleteMovementToRegion += CompleteMovement; //m_controllingClient.OnCompleteMovementToRegion += SendInitialData; - // REGION SYNC - if(!m_scene.IsSyncedClient()) - m_controllingClient.OnAgentUpdate += HandleAgentUpdate; m_controllingClient.OnAgentRequestSit += HandleAgentRequestSit; m_controllingClient.OnAgentSit += HandleAgentSit; m_controllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; @@ -2443,11 +2451,14 @@ namespace OpenSim.Region.Framework.Scenes public void SendCoarseLocations() { + SendCoarseLocationsDefault(m_scene.RegionInfo.originRegionID, this); + /* SendCourseLocationsMethod d = m_sendCourseLocationsMethod; if (d != null) { d.Invoke(m_scene.RegionInfo.originRegionID, this); } + * */ } public void SetSendCourseLocationMethod(SendCourseLocationsMethod d) @@ -2463,7 +2474,9 @@ namespace OpenSim.Region.Framework.Scenes List CoarseLocations = new List(); // This is not cheap to compile this list of locations. // It should ideally be done once and then sent to every client rather than compiled for each client - m_scene.GetCoarseLocations(out AvatarUUIDs, out CoarseLocations); + //m_scene.GetCoarseLocations(out AvatarUUIDs, out CoarseLocations); + AvatarUUIDs.Add(UUID); + CoarseLocations.Add(AbsolutePosition); m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations); m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); } @@ -2602,6 +2615,8 @@ namespace OpenSim.Region.Framework.Scenes /// public void SendAppearanceToOtherAgent(ScenePresence avatar) { + //m_log.WarnFormat("{0} sending appearance to {1}, owner={2}", UUID, avatar.UUID, m_appearance.Owner); + m_appearance.Owner = UUID; avatar.ControllingClient.SendAppearance( m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes()); } diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 4610b38899..488daf8355 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -659,6 +659,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server public event BakeTerrain OnBakeTerrain; public event EstateChangeInfo OnEstateChangeInfo; public event SetAppearance OnSetAppearance; + public event SetAppearanceRaw OnSetAppearanceRaw; public event AvatarNowWearing OnAvatarNowWearing; public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv; public event RezMultipleAttachmentsFromInv OnRezMultipleAttachmentsFromInv; diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 2b44f06709..b38df5a95e 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -168,6 +168,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public event RezObject OnRezObject; public event ModifyTerrain OnModifyTerrain; public event SetAppearance OnSetAppearance; + public event SetAppearanceRaw OnSetAppearanceRaw; public event AvatarNowWearing OnAvatarNowWearing; public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv; public event RezMultipleAttachmentsFromInv OnRezMultipleAttachmentsFromInv; diff --git a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs index 65b3537041..f054e8a280 100644 --- a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs +++ b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs @@ -204,6 +204,7 @@ namespace OpenSim.Services.Connectors public string Store(AssetBase asset) { + /* if (asset.Temporary || asset.Local) { if (m_Cache != null) @@ -211,6 +212,8 @@ namespace OpenSim.Services.Connectors return asset.ID; } + * */ + m_Cache.Cache(asset); string uri = m_ServerURI + "/assets/"; diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs index 79e49a11b9..9acbd9a750 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs @@ -257,7 +257,7 @@ namespace OpenSim.Services.Connectors.SimianGrid } // Local asset handling - if (asset.Local) + /*if (asset.Local) { if (!storedInCache) { @@ -267,7 +267,7 @@ namespace OpenSim.Services.Connectors.SimianGrid } return asset.ID; - } + }*/ // Distinguish public and private assets bool isPublic = true; diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index cdf9bb4a52..63f6129587 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -74,6 +74,7 @@ namespace OpenSim.Tests.Common.Mock public event ModifyTerrain OnModifyTerrain; public event BakeTerrain OnBakeTerrain; public event SetAppearance OnSetAppearance; + public event SetAppearanceRaw OnSetAppearanceRaw; public event AvatarNowWearing OnAvatarNowWearing; public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv; public event RezMultipleAttachmentsFromInv OnRezMultipleAttachmentsFromInv;