From 4f45dcf711e5adf0949c75ed6403af3e5810673d Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Fri, 7 Jan 2011 11:37:03 -0800 Subject: [PATCH 01/20] Commenting out verbose debug in SceneGraph.cs --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index c885fc4e7e..8c7bfca9c2 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -457,7 +457,7 @@ namespace OpenSim.Region.Framework.Scenes lock (m_updateList) { m_updateList[obj.UUID] = obj; - m_log.Debug("added " + obj.UUID + " to m_updateList"); + //m_log.Debug("added " + obj.UUID + " to m_updateList"); } } From 739bb1dc4362dc17439a17f0ad3282744fbf1df3 Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Fri, 7 Jan 2011 12:00:00 -0800 Subject: [PATCH 02/20] Fixed a bug in deserialization during rezzing objects out of inventory: SceneObjecPart.SyncInfoUpdate() fixed. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 566962580f..dfc752a4e8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4922,7 +4922,7 @@ namespace OpenSim.Region.Framework.Scenes //The ID the identifies which actor has caused the most recent update to the prim. //We use type "string" for the ID only to make it human-readable. - private string m_lastUpdateActorID; + private string m_lastUpdateActorID=""; public string LastUpdateActorID { get { return m_lastUpdateActorID; } @@ -4948,12 +4948,12 @@ namespace OpenSim.Region.Framework.Scenes public void SyncInfoUpdate() { - if (m_parentGroup.Scene.ActorSyncModule == null || m_parentGroup.Scene.ActorSyncModule.ActorID == null) - return; + //if (m_parentGroup == null || m_parentGroup.Scene==null || m_parentGroup.Scene.ActorSyncModule == null || m_parentGroup.Scene.ActorSyncModule.ActorID == null) + // return; //Trick: calling UpdateTimestamp here makes sure that when an object was received and de-serialized, before // its parts are linked together, neither TimeStamp or ActorID will be modified. This is because during de-serialization, // ScheduleFullUpdate() is called when m_parentGroup == null - if (m_parentGroup != null) + if (m_parentGroup != null && m_parentGroup.Scene != null && m_parentGroup.Scene.ActorSyncModule!=null) { UpdateTimestamp(); m_lastUpdateActorID = m_parentGroup.Scene.ActorSyncModule.ActorID; From 7eb9affbd3a66b2723c9f7444b372c5b48eae5b3 Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Fri, 7 Jan 2011 15:08:12 -0800 Subject: [PATCH 03/20] Enabled chats from scripted objects to be propogated to other objects and avatars. --- .../SymmetricSync/RegionSyncModule.cs | 70 +++++++++++++------ .../SymmetricSync/SymmetricSyncMessage.cs | 1 + .../Scripting/WorldComm/WorldCommModule.cs | 14 ++-- .../Region/Framework/Scenes/EventManager.cs | 22 +++++- .../Framework/Scenes/Scene.PacketHandlers.cs | 2 + .../Shared/Instance/ScriptInstance.cs | 9 ++- 6 files changed, 89 insertions(+), 29 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index 50cf0bbbd2..5b67dfda89 100755 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -853,6 +853,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule case SymmetricSyncMessage.MsgType.UpdateScript: case SymmetricSyncMessage.MsgType.ScriptReset: case SymmetricSyncMessage.MsgType.ChatFromClient: + case SymmetricSyncMessage.MsgType.ChatFromWorld: { HandleRemoteEvent(msg); return; @@ -1007,6 +1008,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule case SymmetricSyncMessage.MsgType.ChatFromClient: HandleRemoteEvent_OnChatFromClient(init_actorID, evSeqNum, data); break; + case SymmetricSyncMessage.MsgType.ChatFromWorld: + HandleRemoteEvent_OnChatFromWorld(init_actorID, evSeqNum, data); + break; } //if this is a relay node, forwards the event @@ -1075,27 +1079,30 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule ScenePresence sp; m_scene.TryGetScenePresence(id, out sp); - - //m_scene.EventManager.TriggerOnChatFromClientLocally(sp, args); - - m_scene.EventManager.TriggerOnChatFromWorldLocally(sp, args); - /* - if (sp != null) - { - args.Sender = sp.ControllingClient; - args.SenderUUID = id; - m_scene.EventManager.TriggerOnChatBroadcastLocally(sp.ControllingClient, args); - } - else - { - args.Sender = null; - args.SenderUUID = id; - m_scene.EventManager.TriggerOnChatFromWorldLocally(null, args); - } - * */ - //m_scene.EventManager + m_scene.EventManager.TriggerOnChatFromClientLocally(sp, args); //Let WorldCommModule and other modules to catch the event + m_scene.EventManager.TriggerOnChatFromWorldLocally(sp, args); //This is to let ChatModule to get the event and deliver it to avatars } + private void HandleRemoteEvent_OnChatFromWorld(string actorID, ulong evSeqNum, OSDMap data) + { + m_log.Debug(LogHeader + ", " + m_actorID + ": received ChatFromWorld from " + actorID + ", seq " + evSeqNum); + + OSChatMessage args = new OSChatMessage(); + args.Channel = data["channel"].AsInteger(); + args.Message = data["msg"].AsString(); + args.Position = data["pos"].AsVector3(); + args.From = data["name"].AsString(); + UUID id = data["id"].AsUUID(); + args.Scene = m_scene; + //args.Type = ChatTypeEnum.Say; + args.Type = (ChatTypeEnum)data["type"].AsInteger(); + //ScenePresence sp; + //m_scene.TryGetScenePresence(id, out sp); + + m_scene.EventManager.TriggerOnChatFromWorldLocally(m_scene, args); + } + + /// /// Send a sync message to remove the given objects in all connected actors, if this is a relay node. /// UUID is used for identified a removed object. @@ -1149,6 +1156,14 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } OnLocalChatFromClient(evArgs[0], (OSChatMessage)evArgs[1]); return; + case EventManager.EventNames.ChatFromWorld: + if (evArgs.Length < 2) + { + m_log.Error(LogHeader + " not enough event args for ChatFromWorld"); + return; + } + OnLocalChatFromWorld(evArgs[0], (OSChatMessage)evArgs[1]); + return; default: return; } @@ -1211,13 +1226,26 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule data["channel"] = OSD.FromInteger(chat.Channel); data["msg"] = OSD.FromString(chat.Message); data["pos"] = OSD.FromVector3(chat.Position); - //data["name"] = OSD.FromString(chat.From); - data["name"] = OSD.FromString(avatar.Name); + data["name"] = OSD.FromString(avatar.Name); //note this is different from OnLocalChatFromWorld data["id"] = OSD.FromUUID(chat.SenderUUID); data["type"] = OSD.FromInteger((int)chat.Type); SendSceneEvent(SymmetricSyncMessage.MsgType.ChatFromClient, data); } + + private void OnLocalChatFromWorld(Object sender, OSChatMessage chat) + { + + OSDMap data = new OSDMap(); + data["channel"] = OSD.FromInteger(chat.Channel); + data["msg"] = OSD.FromString(chat.Message); + data["pos"] = OSD.FromVector3(chat.Position); + data["name"] = OSD.FromString(chat.From); //note this is different from OnLocalChatFromClient + data["id"] = OSD.FromUUID(chat.SenderUUID); + data["type"] = OSD.FromInteger((int)chat.Type); + SendSceneEvent(SymmetricSyncMessage.MsgType.ChatFromWorld, data); + } + private void SendSceneEvent(SymmetricSyncMessage.MsgType msgType, OSDMap data) { data["actorID"] = OSD.FromString(m_actorID); diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs index f04a6b5616..a10f43e76b 100755 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs @@ -37,6 +37,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule UpdateScript, ScriptReset, ChatFromClient, + ChatFromWorld, } #endregion diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index dc7164925a..7d8df7eb0f 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs @@ -34,8 +34,8 @@ using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; -// using log4net; -// using System.Reflection; +using log4net; +using System.Reflection; /***************************************************** @@ -98,6 +98,8 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm private int m_saydistance = 30; private int m_shoutdistance = 100; + private ILog m_log; + #region IRegionModule Members public void Initialise(Scene scene, IConfigSource config) @@ -126,7 +128,9 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm m_scene.EventManager.OnChatFromClient += DeliverClientMessage; m_scene.EventManager.OnChatBroadcast += DeliverClientMessage; //SYMMETRIC SYNC - m_scene.EventManager.OnChatFromWorld += DeliverClientMessage; + //m_scene.EventManager.OnChatFromWorld += DeliverClientMessage; + //Kitty: temp debug + m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); //end SYMMETRIC SYNC m_pendingQ = new Queue(); m_pending = Queue.Synchronized(m_pendingQ); @@ -244,8 +248,8 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm /// msg to sent public void DeliverMessage(ChatTypeEnum type, int channel, string name, UUID id, string msg, Vector3 position) { - // m_log.DebugFormat("[WorldComm] got[2] type {0}, channel {1}, name {2}, id {3}, msg {4}", - // type, channel, name, id, msg); + m_log.DebugFormat("[WorldComm] got[2] type {0}, channel {1}, name {2}, id {3}, msg {4}", + type, channel, name, id, msg); // Determine which listen event filters match the given set of arguments, this results // in a limited set of listeners, each belonging a host. If the host is in range, add them diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 5fb40cc9e6..b4ae2ea5fa 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -52,7 +52,8 @@ namespace OpenSim.Region.Framework.Scenes { UpdateScript, ScriptReset, - ChatFromClient, + ChatFromClient, //chats from avatars + ChatFromWorld, //chats from objects } public EventManager(Scene scene) @@ -128,10 +129,25 @@ namespace OpenSim.Region.Framework.Scenes base.TriggerOnChatBroadcast(sender, chat); } + #region ChatFromWorld + + public override void TriggerOnChatFromWorld(Object sender, OSChatMessage chat) + { + if (m_scene.RegionSyncModule != null) + { + Object[] eventArgs = new Object[2]; + eventArgs[0] = sender; + eventArgs[1] = (Object)chat; + m_scene.RegionSyncModule.PublishSceneEvent(EventNames.ChatFromWorld, eventArgs); + } + TriggerOnChatFromWorldLocally(sender, chat); + } + public void TriggerOnChatFromWorldLocally(Object sender, OSChatMessage chat) { base.TriggerOnChatFromWorld(sender, chat); } + #endregion //ChatFromWorld } /// @@ -1670,7 +1686,9 @@ namespace OpenSim.Region.Framework.Scenes } } - public void TriggerOnChatFromWorld(Object sender, OSChatMessage chat) + //SYMMETRIC SYNC: the function is overridden in new EventManager + //public void TriggerOnChatFromWorld(Object sender, OSChatMessage chat) + public virtual void TriggerOnChatFromWorld(Object sender, OSChatMessage chat) { ChatFromWorldEvent handlerChatFromWorld = OnChatFromWorld; if (handlerChatFromWorld != null) diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index ab567fbcb0..52611df715 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -69,6 +69,8 @@ namespace OpenSim.Region.Framework.Scenes EventManager.TriggerOnChatBroadcast(this, args); else EventManager.TriggerOnChatFromWorld(this, args); + + m_log.Debug("end of SimChat"); } /// diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 8e712b60fe..57be469bbd 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -51,6 +51,8 @@ using OpenSim.Region.ScriptEngine.Shared.ScriptBase; using OpenSim.Region.ScriptEngine.Shared.CodeTools; using OpenSim.Region.ScriptEngine.Interfaces; +using log4net; + namespace OpenSim.Region.ScriptEngine.Shared.Instance { public class ScriptInstance : MarshalByRefObject, IScriptInstance @@ -214,12 +216,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance get { return m_thisScriptTask; } } + private ILog m_log; + public ScriptInstance(IScriptEngine engine, SceneObjectPart part, UUID itemID, UUID assetID, string assembly, AppDomain dom, string primName, string scriptName, int startParam, bool postOnRez, StateSource stateSource, int maxScriptQueue) { + //Kitty: temp debug + m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + m_Engine = engine; m_LocalID = part.LocalId; @@ -732,7 +739,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance } catch (Exception e) { - // m_log.DebugFormat("[SCRIPT] Exception: {0}", e.Message); + m_log.DebugFormat("[SCRIPT] Exception: {0}", e.Message); m_InEvent = false; m_CurrentEvent = String.Empty; From 5c31e0bdd3f1968069cea9bcee7efe64fc3efe53 Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Mon, 10 Jan 2011 14:14:40 -0800 Subject: [PATCH 04/20] Enabled touch events (ObjectGrab, ObjectGrabbing, ObjectDeGrab) to be propagated to script engine and triggers script. --- .../RegionSyncModule/RegionSyncClient.cs | 9 +- .../SymmetricSync/RegionSyncModule.cs | 252 ++++++++++++++++++ .../SymmetricSync/SymmetricSyncMessage.cs | 3 + .../Scripting/WorldComm/WorldCommModule.cs | 12 +- .../Region/Framework/Scenes/EventManager.cs | 78 +++++- OpenSim/Region/Framework/Scenes/Scene.cs | 7 +- .../Serialization/SceneObjectSerializer.cs | 5 +- 7 files changed, 349 insertions(+), 17 deletions(-) mode change 100755 => 100644 OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs index 91d3ca6bae..1b2df520a2 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs @@ -883,13 +883,14 @@ namespace OpenSim.Region.CoreModules.RegionSync.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; - //SYMMETRIC SYNC: do not subscribe to OnChatFromClientRaw, we may remove this event entirely later + //SYMMETRIC SYNC: do not subscribe to OnChatFromClientRaw: RegionSyncModule + Scene.EventManager will handle this. //client.OnChatFromClientRaw += HandleChatFromClientRaw; client.OnAgentRequestSit += HandleAgentRequestSit; client.OnAgentSit += HandleAgentSit; - client.OnGrabObject += HandleGrabObject; - client.OnGrabUpdate += HandleGrabUpdate; - client.OnDeGrabObject += HandleDeGrabObject; + //SYMMETRIC SYNC: do not subscribe to OnGrabObject, OnGrabUpdate, and OnDeGrabObject: RegionSyncModule + Scene.EventManager will handle this. + //client.OnGrabObject += HandleGrabObject; + //client.OnGrabUpdate += HandleGrabUpdate; + //client.OnDeGrabObject += HandleDeGrabObject; client.OnStartAnim += HandleStartAnim; client.OnStopAnim += HandleStopAnim; } diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs old mode 100755 new mode 100644 index 5b67dfda89..0345dda564 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -854,6 +854,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule case SymmetricSyncMessage.MsgType.ScriptReset: case SymmetricSyncMessage.MsgType.ChatFromClient: case SymmetricSyncMessage.MsgType.ChatFromWorld: + case SymmetricSyncMessage.MsgType.ObjectGrab: + case SymmetricSyncMessage.MsgType.ObjectGrabbing: + case SymmetricSyncMessage.MsgType.ObjectDeGrab: { HandleRemoteEvent(msg); return; @@ -1011,6 +1014,15 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule case SymmetricSyncMessage.MsgType.ChatFromWorld: HandleRemoteEvent_OnChatFromWorld(init_actorID, evSeqNum, data); break; + case SymmetricSyncMessage.MsgType.ObjectGrab: + HandleRemoteEvent_OnObjectGrab(init_actorID, evSeqNum, data); + break; + case SymmetricSyncMessage.MsgType.ObjectGrabbing: + HandleRemoteEvent_OnObjectGrabbing(init_actorID, evSeqNum, data); + break; + case SymmetricSyncMessage.MsgType.ObjectDeGrab: + HandleRemoteEvent_OnObjectDeGrab(init_actorID, evSeqNum, data); + break; } //if this is a relay node, forwards the event @@ -1102,6 +1114,120 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_scene.EventManager.TriggerOnChatFromWorldLocally(m_scene, args); } + /// + /// Special actions for remote event ChatFromClient + /// + /// OSDMap data of event args + private void HandleRemoteEvent_OnObjectGrab(string actorID, ulong evSeqNum, OSDMap data) + { + m_log.Debug(LogHeader + ", " + m_actorID + ": received GrabObject from " + actorID + ", seq " + evSeqNum); + + + UUID agentID = data["agentID"].AsUUID(); + UUID primID = data["primID"].AsUUID(); + UUID originalPrimID = data["originalPrimID"].AsUUID(); + Vector3 offsetPos = data["offsetPos"].AsVector3(); + SurfaceTouchEventArgs surfaceArgs = new SurfaceTouchEventArgs(); + surfaceArgs.Binormal = data["binormal"].AsVector3(); + surfaceArgs.FaceIndex = data["faceIndex"].AsInteger(); + surfaceArgs.Normal = data["normal"].AsVector3(); + surfaceArgs.Position = data["position"].AsVector3(); + surfaceArgs.STCoord = data["stCoord"].AsVector3(); + surfaceArgs.UVCoord = data["uvCoord"].AsVector3(); + + //Create an instance of IClientAPI to pass along agentID, see SOPObject.EventManager_OnObjectGrab() + //We don't really need RegionSyncAvatar's implementation here, just borrow it's IClientAPI interface. + //If we decide to remove RegionSyncAvatar later, we can simple just define a very simple class that implements + //ICleintAPI to be used here. + IClientAPI remoteClinet = new RegionSyncAvatar(m_scene, agentID, "", "", Vector3.Zero); + SceneObjectPart part = m_scene.GetSceneObjectPart(primID); + if (part == null) + { + m_log.Error(LogHeader + ": no prim with ID " + primID); + return; + } + uint originalID = 0; + if (originalPrimID != UUID.Zero) + { + SceneObjectPart originalPart = m_scene.GetSceneObjectPart(originalPrimID); + originalID = originalPart.LocalId; + } + m_scene.EventManager.TriggerObjectGrabLocally(part.LocalId, originalID, offsetPos, remoteClinet, surfaceArgs); + } + + private void HandleRemoteEvent_OnObjectGrabbing(string actorID, ulong evSeqNum, OSDMap data) + { + m_log.Debug(LogHeader + ", " + m_actorID + ": received GrabObject from " + actorID + ", seq " + evSeqNum); + + UUID agentID = data["agentID"].AsUUID(); + UUID primID = data["primID"].AsUUID(); + UUID originalPrimID = data["originalPrimID"].AsUUID(); + Vector3 offsetPos = data["offsetPos"].AsVector3(); + SurfaceTouchEventArgs surfaceArgs = new SurfaceTouchEventArgs(); + surfaceArgs.Binormal = data["binormal"].AsVector3(); + surfaceArgs.FaceIndex = data["faceIndex"].AsInteger(); + surfaceArgs.Normal = data["normal"].AsVector3(); + surfaceArgs.Position = data["position"].AsVector3(); + surfaceArgs.STCoord = data["stCoord"].AsVector3(); + surfaceArgs.UVCoord = data["uvCoord"].AsVector3(); + + //Create an instance of IClientAPI to pass along agentID, see SOPObject.EventManager_OnObjectGrab() + //We don't really need RegionSyncAvatar's implementation here, just borrow it's IClientAPI interface. + //If we decide to remove RegionSyncAvatar later, we can simple just define a very simple class that implements + //ICleintAPI to be used here. + IClientAPI remoteClinet = new RegionSyncAvatar(m_scene, agentID, "", "", Vector3.Zero); + SceneObjectPart part = m_scene.GetSceneObjectPart(primID); + if (part == null) + { + m_log.Error(LogHeader + ": no prim with ID " + primID); + return; + } + uint originalID = 0; + if (originalPrimID != UUID.Zero) + { + SceneObjectPart originalPart = m_scene.GetSceneObjectPart(originalPrimID); + originalID = originalPart.LocalId; + } + + m_scene.EventManager.TriggerObjectGrabbingLocally(part.LocalId, originalID, offsetPos, remoteClinet, surfaceArgs); + } + + private void HandleRemoteEvent_OnObjectDeGrab(string actorID, ulong evSeqNum, OSDMap data) + { + m_log.Debug(LogHeader + ", " + m_actorID + ": received GrabObject from " + actorID + ", seq " + evSeqNum); + + UUID agentID = data["agentID"].AsUUID(); + UUID primID = data["primID"].AsUUID(); + UUID originalPrimID = data["originalPrimID"].AsUUID(); + + SurfaceTouchEventArgs surfaceArgs = new SurfaceTouchEventArgs(); + surfaceArgs.Binormal = data["binormal"].AsVector3(); + surfaceArgs.FaceIndex = data["faceIndex"].AsInteger(); + surfaceArgs.Normal = data["normal"].AsVector3(); + surfaceArgs.Position = data["position"].AsVector3(); + surfaceArgs.STCoord = data["stCoord"].AsVector3(); + surfaceArgs.UVCoord = data["uvCoord"].AsVector3(); + + //Create an instance of IClientAPI to pass along agentID, see SOPObject.EventManager_OnObjectGrab() + //We don't really need RegionSyncAvatar's implementation here, just borrow it's IClientAPI interface. + //If we decide to remove RegionSyncAvatar later, we can simple just define a very simple class that implements + //ICleintAPI to be used here. + IClientAPI remoteClinet = new RegionSyncAvatar(m_scene, agentID, "", "", Vector3.Zero); + SceneObjectPart part = m_scene.GetSceneObjectPart(primID); + if (part == null) + { + m_log.Error(LogHeader + ": no prim with ID " + primID); + return; + } + uint originalID = 0; + if (originalPrimID != UUID.Zero) + { + SceneObjectPart originalPart = m_scene.GetSceneObjectPart(originalPrimID); + originalID = originalPart.LocalId; + } + + m_scene.EventManager.TriggerObjectDeGrabLocally(part.LocalId, originalID, remoteClinet, surfaceArgs); + } /// /// Send a sync message to remove the given objects in all connected actors, if this is a relay node. @@ -1164,6 +1290,15 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } OnLocalChatFromWorld(evArgs[0], (OSChatMessage)evArgs[1]); return; + case EventManager.EventNames.ObjectGrab: + OnLocalGrabObject((uint)evArgs[0], (uint)evArgs[1], (Vector3) evArgs[2], (IClientAPI) evArgs[3], (SurfaceTouchEventArgs)evArgs[4]); + return; + case EventManager.EventNames.ObjectGrabbing: + OnLocalObjectGrabbing((uint)evArgs[0], (uint)evArgs[1], (Vector3)evArgs[2], (IClientAPI)evArgs[3], (SurfaceTouchEventArgs)evArgs[4]); + return; + case EventManager.EventNames.ObjectDeGrab: + OnLocalDeGrabObject((uint)evArgs[0], (uint)evArgs[1], (IClientAPI)evArgs[2], (SurfaceTouchEventArgs)evArgs[3]); + return; default: return; } @@ -1204,6 +1339,12 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //we will use the prim's UUID as the identifier, not the localID, to publish the event for the prim SceneObjectPart part = m_scene.GetSceneObjectPart(localID); + if (part == null) + { + m_log.Warn(LogHeader + ": part with localID " + localID + " not exist"); + return; + } + OSDMap data = new OSDMap(); data["primID"] = OSD.FromUUID(part.UUID); data["itemID"] = OSD.FromUUID(itemID); @@ -1245,6 +1386,117 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule data["type"] = OSD.FromInteger((int)chat.Type); SendSceneEvent(SymmetricSyncMessage.MsgType.ChatFromWorld, data); } + + private void OnLocalGrabObject(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) + { + /* + //we will use the prim's UUID as the identifier, not the localID, to publish the event for the prim + SceneObjectPart part = m_scene.GetSceneObjectPart(localID); + if (part == null) + { + m_log.Warn(LogHeader + ": part with localID " + localID + " not exist"); + return; + } + + //this seems to be useful if the prim touched and the prim handling the touch event are different: + //i.e. a child part is touched, pass the event to root, and root handles the event. then root is the "part", + //and the child part is the "originalPart" + SceneObjectPart originalPart = null; + if (originalID != 0) + { + originalPart = m_scene.GetSceneObjectPart(originalID); + if (originalPart == null) + { + m_log.Warn(LogHeader + ": part with localID " + localID + " not exist"); + return; + } + } + + OSDMap data = new OSDMap(); + data["agentID"] = OSD.FromUUID(remoteClient.AgentId); + data["primID"] = OSD.FromUUID(part.UUID); + if (originalID != 0) + { + data["originalPrimID"] = OSD.FromUUID(originalPart.UUID); + } + else + { + data["originalPrimID"] = OSD.FromUUID(UUID.Zero); + } + data["offsetPos"] = OSD.FromVector3(offsetPos); + + data["binormal"] = OSD.FromVector3(surfaceArgs.Binormal); + data["faceIndex"] = OSD.FromInteger(surfaceArgs.FaceIndex); + data["normal"] = OSD.FromVector3(surfaceArgs.Normal); + data["position"] = OSD.FromVector3(surfaceArgs.Position); + data["stCoord"] = OSD.FromVector3(surfaceArgs.STCoord); + data["uvCoord"] = OSD.FromVector3(surfaceArgs.UVCoord); + * */ + OSDMap data = PrepareObjectGrabArgs(localID, originalID, offsetPos, remoteClient, surfaceArgs); + SendSceneEvent(SymmetricSyncMessage.MsgType.ObjectGrab, data); + } + + private void OnLocalObjectGrabbing(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) + { + OSDMap data = PrepareObjectGrabArgs(localID, originalID, offsetPos, remoteClient, surfaceArgs); + if (data != null) + { + SendSceneEvent(SymmetricSyncMessage.MsgType.ObjectGrabbing, data); + } + } + + private OSDMap PrepareObjectGrabArgs(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) + { + //we will use the prim's UUID as the identifier, not the localID, to publish the event for the prim + SceneObjectPart part = m_scene.GetSceneObjectPart(localID); + if (part == null) + { + m_log.Warn(LogHeader + ": PrepareObjectGrabArgs - part with localID " + localID + " not exist"); + return null; + } + + //this seems to be useful if the prim touched and the prim handling the touch event are different: + //i.e. a child part is touched, pass the event to root, and root handles the event. then root is the "part", + //and the child part is the "originalPart" + SceneObjectPart originalPart = null; + if (originalID != 0) + { + originalPart = m_scene.GetSceneObjectPart(originalID); + if (originalPart == null) + { + m_log.Warn(LogHeader + ": PrepareObjectGrabArgs - part with localID " + localID + " not exist"); + return null; + } + } + + OSDMap data = new OSDMap(); + data["agentID"] = OSD.FromUUID(remoteClient.AgentId); + data["primID"] = OSD.FromUUID(part.UUID); + if (originalID != 0) + { + data["originalPrimID"] = OSD.FromUUID(originalPart.UUID); + } + else + { + data["originalPrimID"] = OSD.FromUUID(UUID.Zero); + } + data["offsetPos"] = OSD.FromVector3(offsetPos); + + data["binormal"] = OSD.FromVector3(surfaceArgs.Binormal); + data["faceIndex"] = OSD.FromInteger(surfaceArgs.FaceIndex); + data["normal"] = OSD.FromVector3(surfaceArgs.Normal); + data["position"] = OSD.FromVector3(surfaceArgs.Position); + data["stCoord"] = OSD.FromVector3(surfaceArgs.STCoord); + data["uvCoord"] = OSD.FromVector3(surfaceArgs.UVCoord); + + return data; + } + + + private void OnLocalDeGrabObject(uint localID, uint originalID, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) + { + + } private void SendSceneEvent(SymmetricSyncMessage.MsgType msgType, OSDMap data) { diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs index a10f43e76b..b093a16702 100755 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs @@ -38,6 +38,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule ScriptReset, ChatFromClient, ChatFromWorld, + ObjectGrab, + ObjectGrabbing, + ObjectDeGrab, } #endregion diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index 7d8df7eb0f..86aa79d7dd 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs @@ -34,8 +34,8 @@ using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; -using log4net; -using System.Reflection; +//using log4net; +//using System.Reflection; /***************************************************** @@ -98,7 +98,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm private int m_saydistance = 30; private int m_shoutdistance = 100; - private ILog m_log; + //private ILog m_log; #region IRegionModule Members @@ -130,7 +130,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm //SYMMETRIC SYNC //m_scene.EventManager.OnChatFromWorld += DeliverClientMessage; //Kitty: temp debug - m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + //m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); //end SYMMETRIC SYNC m_pendingQ = new Queue(); m_pending = Queue.Synchronized(m_pendingQ); @@ -248,8 +248,8 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm /// msg to sent public void DeliverMessage(ChatTypeEnum type, int channel, string name, UUID id, string msg, Vector3 position) { - m_log.DebugFormat("[WorldComm] got[2] type {0}, channel {1}, name {2}, id {3}, msg {4}", - type, channel, name, id, msg); + //m_log.DebugFormat("[WorldComm] got[2] type {0}, channel {1}, name {2}, id {3}, msg {4}", + // type, channel, name, id, msg); // Determine which listen event filters match the given set of arguments, this results // in a limited set of listeners, each belonging a host. If the host is in range, add them diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index b4ae2ea5fa..f3b5e17677 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -54,6 +54,10 @@ namespace OpenSim.Region.Framework.Scenes ScriptReset, ChatFromClient, //chats from avatars ChatFromWorld, //chats from objects + ObjectGrab, + ObjectGrabbing, + ObjectDeGrab, + } public EventManager(Scene scene) @@ -148,6 +152,68 @@ namespace OpenSim.Region.Framework.Scenes base.TriggerOnChatFromWorld(sender, chat); } #endregion //ChatFromWorld + + #region ObjectGrab, ObjectGrabbing, ObjectDeGrab + public override void TriggerObjectGrab(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) + { + if (m_scene.RegionSyncModule != null) + { + Object[] eventArgs = new Object[5]; + eventArgs[0] = (Object)localID; + eventArgs[1] = (Object)originalID; + eventArgs[2] = (Object)offsetPos; + eventArgs[3] = (Object)remoteClient; + eventArgs[4] = (Object)surfaceArgs; + m_scene.RegionSyncModule.PublishSceneEvent(EventNames.ObjectGrab, eventArgs); + } + TriggerObjectGrabLocally(localID, originalID, offsetPos, remoteClient, surfaceArgs); + } + public void TriggerObjectGrabLocally(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) + { + base.TriggerObjectGrab(localID, originalID, offsetPos, remoteClient, surfaceArgs); + } + + public override void TriggerObjectGrabbing(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) + { + if (m_scene.RegionSyncModule != null) + { + Object[] eventArgs = new Object[5]; + eventArgs[0] = (Object)localID; + eventArgs[1] = (Object)originalID; + eventArgs[2] = (Object)offsetPos; + eventArgs[3] = (Object)remoteClient; + eventArgs[4] = (Object)surfaceArgs; + m_scene.RegionSyncModule.PublishSceneEvent(EventNames.ObjectGrabbing, eventArgs); + } + TriggerObjectGrabbingLocally(localID, originalID, offsetPos, remoteClient, surfaceArgs); + } + + public void TriggerObjectGrabbingLocally(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) + { + base.TriggerObjectGrabbing(localID, originalID, offsetPos, remoteClient, surfaceArgs); + } + + public override void TriggerObjectDeGrab(uint localID, uint originalID, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) + { + if (m_scene.RegionSyncModule != null) + { + Object[] eventArgs = new Object[4]; + eventArgs[0] = (Object)localID; + eventArgs[1] = (Object)originalID; + eventArgs[2] = (Object)remoteClient; + eventArgs[3] = (Object)surfaceArgs; + m_scene.RegionSyncModule.PublishSceneEvent(EventNames.ObjectDeGrab, eventArgs); + } + + TriggerObjectDeGrabLocally(localID, originalID, remoteClient, surfaceArgs); + } + + public void TriggerObjectDeGrabLocally(uint localID, uint originalID, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) + { + base.TriggerObjectDeGrab(localID, originalID, remoteClient, surfaceArgs); + } + + #endregion //GrabObject } /// @@ -954,7 +1020,9 @@ namespace OpenSim.Region.Framework.Scenes } } - public void TriggerObjectGrab(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) + //SYMMETRIC SYNC: overridden at new EventManager class + //public void TriggerObjectGrab(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) + public virtual void TriggerObjectGrab(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) { ObjectGrabDelegate handlerObjectGrab = OnObjectGrab; if (handlerObjectGrab != null) @@ -975,7 +1043,9 @@ namespace OpenSim.Region.Framework.Scenes } } - public void TriggerObjectGrabbing(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) + //SYMMETRIC SYNC: overridden at new EventManager class + //public void TriggerObjectGrabbing(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) + public virtual void TriggerObjectGrabbing(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) { ObjectGrabDelegate handlerObjectGrabbing = OnObjectGrabbing; if (handlerObjectGrabbing != null) @@ -996,7 +1066,9 @@ namespace OpenSim.Region.Framework.Scenes } } - public void TriggerObjectDeGrab(uint localID, uint originalID, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) + //SYMMETRIC SYNC: overridden at new EventManager class + //public void TriggerObjectDeGrab(uint localID, uint originalID, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) + public virtual void TriggerObjectDeGrab(uint localID, uint originalID, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) { ObjectDeGrabDelegate handlerObjectDeGrab = OnObjectDeGrab; if (handlerObjectDeGrab != null) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index bec3603ed7..bcbacd3794 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3071,12 +3071,13 @@ namespace OpenSim.Region.Framework.Scenes client.OnUpdatePrimFlags += m_sceneGraph.UpdatePrimFlags; client.OnRequestObjectPropertiesFamily += m_sceneGraph.RequestObjectPropertiesFamily; client.OnObjectPermissions += HandleObjectPermissionsUpdate; - if (IsSyncedServer()) - { + //SYMMETRIC SYNC: return the code back to its original OpenSim version + //if (IsSyncedServer()) + //{ client.OnGrabObject += ProcessObjectGrab; client.OnGrabUpdate += ProcessObjectGrabUpdate; client.OnDeGrabObject += ProcessObjectDeGrab; - } + //} client.OnUndo += m_sceneGraph.HandleUndo; client.OnRedo += m_sceneGraph.HandleRedo; client.OnObjectDescription += m_sceneGraph.PrimDescription; diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 8953ce31ba..0769929421 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -1174,7 +1174,10 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("GroupMask", sop.GroupMask.ToString()); writer.WriteElementString("EveryoneMask", sop.EveryoneMask.ToString()); writer.WriteElementString("NextOwnerMask", sop.NextOwnerMask.ToString()); - WriteFlags(writer, "Flags", sop.Flags.ToString(), options); + //SYMMETRIC SYNC: also serialize SceneObjectPart:LocalFlags, so that it can be propogated across actors + //WriteFlags(writer, "Flags", sop.Flags.ToString(), options); + WriteFlags(writer, "Flags", sop.GetEffectiveObjectFlags().ToString(), options); + //end SYMMETRIC SYNC WriteUUID(writer, "CollisionSound", sop.CollisionSound, options); writer.WriteElementString("CollisionSoundVolume", sop.CollisionSoundVolume.ToString()); if (sop.MediaUrl != null) From f8a0de591dcb3a4b207378bfb8a0e321022e1c94 Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Mon, 10 Jan 2011 16:30:42 -0800 Subject: [PATCH 05/20] Handling RemovedObject as event, instead of as object-update as in the previous approach. --- .../SymmetricSync/RegionSyncModule.cs | 74 ++++++++++--------- OpenSim/Region/Framework/Scenes/Scene.cs | 6 +- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 + .../Framework/Scenes/SceneObjectGroup.cs | 3 + .../Framework/Scenes/SceneObjectPart.cs | 10 +-- 5 files changed, 50 insertions(+), 45 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index 0345dda564..93eea92045 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -935,29 +935,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule SendSyncMessage(SymmetricSyncMessage.MsgType.Terrain, OSDParser.SerializeJsonString(data)); } - private void HandleRemovedObject(SymmetricSyncMessage msg) - { - // Get the data from message and error check - OSDMap data = DeserializeMessage(msg); - if (data == null) - { - - SymmetricSyncMessage.HandleError(LogHeader, msg, "Could not deserialize JSON data."); - return; - } - - // Get the parameters from data - //ulong regionHandle = data["regionHandle"].AsULong(); - //uint localID = data["UUID"].AsUInteger(); - UUID sogUUID = data["UUID"].AsUUID(); - - SceneObjectGroup sog = m_scene.SceneGraph.GetGroupByPrim(sogUUID); - if (sog != null) - { - m_scene.DeleteSceneObjectBySynchronization(sog); - } - } HashSet exceptions = new HashSet(); private OSDMap DeserializeMessage(SymmetricSyncMessage msg) @@ -990,6 +968,34 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } } + private void HandleRemovedObject(SymmetricSyncMessage msg) + { + // Get the data from message and error check + OSDMap data = DeserializeMessage(msg); + string init_actorID = data["actorID"].AsString(); + + if (data == null) + { + + SymmetricSyncMessage.HandleError(LogHeader, msg, "Could not deserialize JSON data."); + return; + } + + UUID sogUUID = data["UUID"].AsUUID(); + + SceneObjectGroup sog = m_scene.SceneGraph.GetGroupByPrim(sogUUID); + if (sog != null) + { + m_scene.DeleteSceneObjectBySynchronization(sog); + } + + //if this is a relay node, forwards the event + if (m_isSyncRelay) + { + SendSceneEventToRelevantSyncConnectors(init_actorID, msg); + } + } + /// /// The common actions for handling remote events (event initiated at other actors and propogated here) /// @@ -1230,8 +1236,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } /// - /// Send a sync message to remove the given objects in all connected actors, if this is a relay node. - /// UUID is used for identified a removed object. + /// Send a sync message to remove the given objects in all connected actors. + /// UUID is used for identified a removed object. This function now should + /// only be triggered by an object removal that is initiated locally. /// /// private void RegionSyncModule_OnObjectBeingRemovedFromScene(SceneObjectGroup sog) @@ -1239,18 +1246,17 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //m_log.DebugFormat("RegionSyncModule_OnObjectBeingRemovedFromScene called at time {0}:{1}:{2}", DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond); //Only send the message out if this is a relay node for sync messages, or this actor caused deleting the object - if (m_isSyncRelay || CheckObjectForSendingUpdate(sog)) - { - OSDMap data = new OSDMap(1); - //data["regionHandle"] = OSD.FromULong(regionHandle); - //data["localID"] = OSD.FromUInteger(sog.LocalId); - data["UUID"] = OSD.FromUUID(sog.UUID); - - SymmetricSyncMessage rsm = new SymmetricSyncMessage(SymmetricSyncMessage.MsgType.RemovedObject, OSDParser.SerializeJsonString(data)); - SendObjectUpdateToRelevantSyncConnectors(sog, rsm); - } + //if (m_isSyncRelay || CheckObjectForSendingUpdate(sog)) + OSDMap data = new OSDMap(1); + //data["regionHandle"] = OSD.FromULong(regionHandle); + //data["localID"] = OSD.FromUInteger(sog.LocalId); + data["UUID"] = OSD.FromUUID(sog.UUID); + data["actorID"] = OSD.FromString(m_actorID); + + SymmetricSyncMessage rsm = new SymmetricSyncMessage(SymmetricSyncMessage.MsgType.RemovedObject, OSDParser.SerializeJsonString(data)); + SendObjectUpdateToRelevantSyncConnectors(sog, rsm); } public void PublishSceneEvent(EventManager.EventNames ev, Object[] evArgs) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index bcbacd3794..07c5d70d6c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -662,7 +662,8 @@ namespace OpenSim.Region.Framework.Scenes if (UnlinkSceneObject(group, false)) { - EventManager.TriggerObjectBeingRemovedFromScene(group); + //For object removals caused by remote events (by other actors), do not trigger local event ObjectBeingRemovedFromScene + //EventManager.TriggerObjectBeingRemovedFromScene(group); EventManager.TriggerParcelPrimCountTainted(); } @@ -2424,12 +2425,13 @@ namespace OpenSim.Region.Framework.Scenes //SYMMETRIC SYNC //Set the ActorID and TimeStamp info for this latest update + /* foreach (SceneObjectPart part in group.Parts) { part.SyncInfoUpdate(); } //end of SYMMETRIC SYNC - + * */ } /// diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 8c7bfca9c2..8666fe8ab9 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -478,10 +478,12 @@ namespace OpenSim.Region.Framework.Scenes { updates = new List(m_updateList.Values); + /* if (updates.Count > 0) { m_log.Debug("SceneGraph: " + updates.Count + " objects to send updates for"); } + * */ m_updateList.Clear(); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 8bc467c3bd..2a8f2990b6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1155,12 +1155,15 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectPart part = parts[i]; + //SYMMETRIC SYNC: object remove should be handled through RegionSyncModule + /* // REGION SYNC if (Scene.IsSyncedServer()) { Scene.RegionSyncServerModule.DeleteObject(part.RegionHandle, part.LocalId, part); //return; } + * */ Scene.ForEachScenePresence(delegate(ScenePresence avatar) { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index dfc752a4e8..c8941f1c55 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -5066,14 +5066,6 @@ namespace OpenSim.Region.Framework.Scenes this.m_lastUpdateActorID = updatedPart.LastUpdateActorID; this.m_lastUpdateTimeStamp = updatedPart.LastUpdateTimeStamp; - - /* - this.m_inventory.Items = (TaskInventoryDictionary)updatedPart.m_inventory.Items.Clone(); - //update shape information, for now, only update fileds in Shape whose set functions are defined in PrimitiveBaseShape - this.Shape = updatedPart.Shape.Copy(); - this.Shape.TextureEntry = updatedPart.Shape.TextureEntry; - * */ - return partUpdateResult; } @@ -5083,7 +5075,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void ScheduleFullUpdate_SyncInfoUnchanged() { - m_log.DebugFormat("[SCENE OBJECT PART]: ScheduleFullUpdate_SyncInfoUnchanged for {0} {1}", Name, LocalId); + //m_log.DebugFormat("[SCENE OBJECT PART]: ScheduleFullUpdate_SyncInfoUnchanged for {0} {1}", Name, LocalId); if (m_parentGroup != null) { From 6a24d0eb2d1aa56333844ed5a39fdb431cc5d76d Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Tue, 11 Jan 2011 11:40:14 -0800 Subject: [PATCH 06/20] Added missing lock in EventQueue Enqueue. --- .../Framework/EventQueue/EventQueueGetModule.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs index 05fe3eee04..9292392445 100644 --- a/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs @@ -177,7 +177,12 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue { Queue queue = GetQueue(avatarID); if (queue != null) - queue.Enqueue(ev); + { + lock (queue) + { + queue.Enqueue(ev); + } + } } catch(NullReferenceException e) { From ed380196ea09d92ae59fb7bed25359b0e92040d6 Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Tue, 11 Jan 2011 11:49:05 -0800 Subject: [PATCH 07/20] Only AvatarFactory module should be calling ScenePresence.SendAppearanceToAllOtherAgents(). --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 8d87dfd142..015604a214 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2517,7 +2517,7 @@ namespace OpenSim.Region.Framework.Scenes // If the avatars baked textures are all in the cache, then we have a // complete appearance... send it out, if not, then we'll send it when // the avatar finishes updating its appearance - SendAppearanceToAllOtherAgents(); + m_scene.AvatarFactory.QueueAppearanceSend(UUID); } } diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index c471636743..0d782a8a4d 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -169,7 +169,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC sp.Appearance.SetTextureEntries(x.Texture); sp.Appearance.SetVisualParams((byte[])x.VisualParams.Clone()); - sp.SendAppearanceToAllOtherAgents(); + p_scene.AvatarFactory.QueueAppearanceSend(sp.UUID); } m_avatars.Add(npcAvatar.AgentId, npcAvatar); From b5463e042cb9ef8c483ec7f3cae3b5895c03d010 Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Tue, 11 Jan 2011 12:20:06 -0800 Subject: [PATCH 08/20] Workaround for NaN in rotation update from PSA to CM. --- .../RegionSync/RegionSyncModule/RegionSyncServerModule.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs index d23098e3c9..d408e87202 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs @@ -308,7 +308,10 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule data["vel"] = OSD.FromVector3(presence.Velocity); else data["vel"] = OSD.FromVector3(Vector3.Zero); - data["rot"] = OSD.FromQuaternion(presence.Rotation); + if(System.Single.IsNaN(presence.Rotation.X)) + data["rot"] = OSD.FromQuaternion(Quaternion.Identity); + else + data["rot"] = OSD.FromQuaternion(presence.Rotation); data["fly"] = OSD.FromBoolean(presence.Flying); data["flags"] = OSD.FromUInteger((uint)presence.AgentControlFlags); data["anim"] = OSD.FromString(presence.Animator.CurrentMovementAnimation); From 9d5888e0f650ab262e14ef72172ee929f3893762 Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Tue, 11 Jan 2011 12:21:04 -0800 Subject: [PATCH 09/20] Fixed typo in Region Sync Module debug message Log Headers. --- .../RegionSyncModule/SymmetricSync/RegionSyncModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index 5b67dfda89..42bd59426f 100755 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -203,7 +203,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule // Existing value of 1 indicates that updates are currently being sent so skip updates this pass if (Interlocked.Exchange(ref m_sendingUpdates, 1) == 1) { - m_log.WarnFormat("[REGION SYNC SERVER MODULE] SendUpdates(): An update thread is already running."); + m_log.WarnFormat("[REGION SYNC MODULE] SendUpdates(): An update thread is already running."); return; } @@ -281,7 +281,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } catch (Exception e) { - m_log.ErrorFormat("[REGION SYNC SERVER MODULE] Caught exception sending presence updates for {0}: {1}", presence.Name, e.Message); + m_log.ErrorFormat("[REGION SYNC MODULE] Caught exception sending presence updates for {0}: {1}", presence.Name, e.Message); } } * */ From 217b28195ca04854e1f7444ceb2c5a57473fac6b Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Tue, 11 Jan 2011 12:21:58 -0800 Subject: [PATCH 10/20] TEMP: Disable saving of appearance to Simian for demonstration purposed only. --- .../CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 3bc68adfea..5b5889df0d 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -333,7 +333,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory // m_log.WarnFormat("[AVFACTORY] avatar {0} save appearance",agentid); - m_scene.AvatarService.SetAppearance(agentid, sp.Appearance); + // Disable saving of appearance for demonstrations + // m_scene.AvatarService.SetAppearance(agentid, sp.Appearance); // REGION SYNC // If this is a client manager, we have received new appearance from a client and saved // it to the avatar service. Now let's tell the parent scene about it. From b29e7c6e5e5b0e7e698c5fdb9df1b6f6783004ab Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Tue, 11 Jan 2011 12:33:32 -0800 Subject: [PATCH 11/20] Let RegionSyncModule to automatically start synchronization when all region loading is done. --- .../SymmetricSync/RegionSyncModule.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index 93eea92045..3db64b3f2a 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -72,7 +72,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //Called after Initialise() public void AddRegion(Scene scene) { - m_log.Warn(LogHeader + " AddRegion() called"); + //m_log.Warn(LogHeader + " AddRegion() called"); if (!m_active) return; @@ -96,10 +96,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //Called after AddRegion() has been called for all region modules of the scene public void RegionLoaded(Scene scene) { - m_log.Warn(LogHeader + " RegionLoaded() called"); + //m_log.Warn(LogHeader + " RegionLoaded() called"); + /* //If this one is configured to start a listener so that other actors can connect to form a overlay, start the listener. - //For now, we use start topology, and ScenePersistence actor is always the one to start the listener. + //For now, we use the star topology, and ScenePersistence actor is always the one to start the listener. if (m_isSyncListenerLocal) { StartLocalSyncListener(); @@ -108,7 +109,12 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { //Start connecting to the remote listener. TO BE IMPLEMENTED. //For now, the connection will be started by manually typing in "sync start". + } + * */ + + //Start symmetric synchronization initialization automatically + //SyncStart(null); } @@ -528,6 +534,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } m_actorType = m_scene.ActorSyncModule.ActorType; } + + //Start symmetric synchronization initialization automatically + SyncStart(null); } private void StartLocalSyncListener() @@ -914,7 +923,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_log.WarnFormat("[{0} Object \"{1}\" ({1}) ({2}) -- add or update ERROR.", LogHeader, sog.Name, sog.UUID.ToString(), sog.LocalId.ToString()); break; case Scene.ObjectUpdateResult.Unchanged: - m_log.DebugFormat("[{0} Object \"{1}\" ({1}) ({2}) unchanged after receiving an update.", LogHeader, sog.Name, sog.UUID.ToString(), sog.LocalId.ToString()); + //m_log.DebugFormat("[{0} Object \"{1}\" ({1}) ({2}) unchanged after receiving an update.", LogHeader, sog.Name, sog.UUID.ToString(), sog.LocalId.ToString()); break; } } From 95be9c1f7d3e9514a748ae3d1fc0aaca348731ac Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Tue, 11 Jan 2011 14:25:33 -0800 Subject: [PATCH 12/20] Fixed a bug so that "ssync start" won't start new connections if a region is already synced. --- .../SymmetricSync/RegionSyncModule.cs | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index 902df11a37..e5a8c3d1b4 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -176,6 +176,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } private RegionSyncListener m_localSyncListener = null; + private bool m_synced = false; // Lock is used to synchronize access to the update status and update queues private object m_updateSceneObjectPartLock = new object(); @@ -620,8 +621,10 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { GetRemoteSyncListenerInfo(); } - StartSyncConnections(); - DoInitialSync(); + if (StartSyncConnections()) + { + DoInitialSync(); + } } } @@ -655,12 +658,18 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //Start connections to each remote listener. //For now, there is only one remote listener. - private void StartSyncConnections() + private bool StartSyncConnections() { if (m_remoteSyncListeners == null) { m_log.Error(LogHeader + " SyncListener's address or port has not been configured."); - return; + return false; + } + + if (m_synced) + { + m_log.Warn(LogHeader + ": Already synced."); + return false; } foreach (RegionSyncListenerInfo remoteListener in m_remoteSyncListeners) @@ -672,6 +681,10 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule AddSyncConnector(syncConnector); } } + + m_synced = true; + + return true; } //To be called when a SyncConnector needs to be created by that the local listener receives a connection request From 9e08ede0bd2ecf74dcfa2670db0ad2e445c42a8b Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Tue, 11 Jan 2011 16:00:14 -0800 Subject: [PATCH 13/20] Commented out DeleteAllSceneObjects in RegionSyncClient, and fixed a bug in "ssync stop". --- .../RegionSyncModule/RegionSyncClient.cs | 2 +- .../SymmetricSync/RegionSyncModule.cs | 20 ++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs index 1b2df520a2..93eaee8286 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs @@ -821,7 +821,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule private void DoInitialSync() { - m_scene.DeleteAllSceneObjects(); + //m_scene.DeleteAllSceneObjects(); //KittyL: added to distinguish different actors //Send(new RegionSyncMessage(RegionSyncMessage.MsgType.ActorType, m_actorType.ToString())); diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index e5a8c3d1b4..52212d87d5 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -635,18 +635,28 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule if (m_localSyncListener!=null && m_localSyncListener.IsListening) { m_localSyncListener.Shutdown(); + //Trigger SyncStop event, ActorSyncModules can then take actor specific action if needed. + //For instance, script engine will save script states + //save script state and stop script instances + m_scene.EventManager.TriggerOnSymmetricSyncStop(); } } else { //Shutdown all sync connectors - StopAllSyncConnectors(); + if (m_synced) + { + StopAllSyncConnectors(); + m_synced = false; + + //Trigger SyncStop event, ActorSyncModules can then take actor specific action if needed. + //For instance, script engine will save script states + //save script state and stop script instances + m_scene.EventManager.TriggerOnSymmetricSyncStop(); + } } - //Trigger SyncStop event, ActorSyncModules can then take actor specific action if needed. - //For instance, script engine will save script states - //save script state and stop script instances - m_scene.EventManager.TriggerOnSymmetricSyncStop(); + } From 039d91928488f313a88b390a4c5cbe6e76ff3618 Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Tue, 11 Jan 2011 19:19:15 -0800 Subject: [PATCH 14/20] RefreshAppearance now tries to find the local avatar a few times before it gives up. --- .../AvatarFactory/AvatarFactoryModule.cs | 39 +++++++++++++++---- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 5b5889df0d..d8e7914d55 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -71,7 +71,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory { m_savetime = Convert.ToInt32(sconfig.GetString("DelayBeforeAppearanceSave",Convert.ToString(m_savetime))); m_sendtime = Convert.ToInt32(sconfig.GetString("DelayBeforeAppearanceSend",Convert.ToString(m_sendtime))); - // m_log.InfoFormat("[AVFACTORY] configured for {0} save and {1} send",m_savetime,m_sendtime); + m_log.WarnFormat("[AVFACTORY] configured for {0} save and {1} send",m_savetime,m_sendtime); } } @@ -261,6 +261,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory m_sendqueue[agentid] = timestamp; m_updateTimer.Start(); } + m_log.WarnFormat("[AVFACTORY]: Queue appearance send for {0} at {1} (now is {2})", agentid, timestamp,DateTime.Now.Ticks); } public void QueueAppearanceSave(UUID agentid) @@ -278,16 +279,37 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory public void RefreshAppearance(UUID agentid) { - ScenePresence sp; - if(!m_scene.TryGetScenePresence(agentid, out sp)) - { - m_log.WarnFormat("[AVFACTORY]: RefreshAppearance unable to find presence for {0}", agentid); - return; - } m_log.DebugFormat("[AVFACTORY]: FireAndForget called for RefreshAppearance on agentid {0}", agentid); Util.FireAndForget(delegate(object o) { - AvatarAppearance appearance = m_scene.AvatarService.GetAppearance(agentid); + int trycount = 20; + ScenePresence sp; + while (!m_scene.TryGetScenePresence(agentid, out sp)) + { + m_log.WarnFormat("[AVFACTORY]: RefreshAppearance unable to find presence for {0}", agentid); + Thread.Sleep(500); + if (trycount-- <= 0) + return; + } + trycount = 5; + AvatarAppearance appearance = null; + while (appearance == null) + { + try + { + appearance = m_scene.AvatarService.GetAppearance(agentid); + } + catch (System.Net.WebException e) + { + if (trycount-- <= 0) + { + m_log.WarnFormat("[AVFACTORY]: RefreshAppearance failed to get appearance from AvatarService: {0}", e.Message); + return; + } + } + Thread.Sleep(500); + } + if (appearance.Texture != null && appearance.VisualParams != null) { sp.Appearance = appearance; @@ -353,6 +375,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory { if (kvp.Value < now) { + m_log.WarnFormat("[AVFACTORY]: send appearance for {0} at time {1}", kvp.Key, now); Util.FireAndForget(delegate(object o) { HandleAppearanceSend(kvp.Key); }); m_sendqueue.Remove(kvp.Key); } From c1e19ead74197a980d5d71f0158cf5d11ad01c8e Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Wed, 12 Jan 2011 17:20:17 -0800 Subject: [PATCH 15/20] Added ScheduleFullUpdate() in SceneObjectPart.AddInventoryItem(), to enable synchronization across actors. --- .../Framework/Scenes/Scene.Inventory.cs | 21 +++++++++++++++++++ .../Scenes/SceneObjectPartInventory.cs | 3 +++ 2 files changed, 24 insertions(+) diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 900b19ce2f..2c6ab2ee6b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -376,6 +376,17 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart part = GetSceneObjectPart(primID); SceneObjectGroup group = part.ParentGroup; + + if (null == group) + { + m_log.ErrorFormat( + "[PRIM INVENTORY]: " + + "Prim inventory update requested for item ID {0} in prim ID {1} but this prim does not exist", + itemID, primID); + + return new ArrayList(); + } + if (isScriptRunning) { m_log.Debug("To RemoveScriptInstance"); @@ -385,6 +396,16 @@ namespace OpenSim.Region.Framework.Scenes // Retrieve item TaskInventoryItem item = group.GetInventoryItem(part.LocalId, itemID); + if (null == item) + { + m_log.ErrorFormat( + "[PRIM INVENTORY]: Tried to retrieve item ID {0} from prim {1}, {2} for caps script update " + + " but the item does not exist in this inventory", + itemID, part.Name, part.UUID); + + return new ArrayList(); + } + // Update item with new asset item.AssetID = newAssetID; group.UpdateInventoryItem(item); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 7a0cc5a8fe..d3d2d73979 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -539,6 +539,9 @@ namespace OpenSim.Region.Framework.Scenes //m_inventorySerial += 2; HasInventoryChanged = true; m_part.ParentGroup.HasGroupChanged = true; + + //SYMMETRIC SYNC: add ScheduleFullUpdate to enable synchronization across actors + m_part.ScheduleFullUpdate(); } /// From 0be2fe7f1341ad744378005c8c2f32ef4345cc3a Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Thu, 13 Jan 2011 15:36:44 -0800 Subject: [PATCH 16/20] Changed the way RemoveObject is handled: now Scene.DeleteSceneObject() calls RegionSyncModule to send RemovedObject message to other actors for synchronization. --- .../SymmetricSync/RegionSyncModule.cs | 5 +++-- .../Framework/Interfaces/IRegionSyncModule.cs | 2 +- OpenSim/Region/Framework/Scenes/Scene.cs | 16 +++++++++++++--- .../Region/Framework/Scenes/SceneObjectGroup.cs | 3 ++- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index 52212d87d5..860b80b708 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -89,7 +89,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //Register for local Scene events m_scene.EventManager.OnPostSceneCreation += OnPostSceneCreation; - m_scene.EventManager.OnObjectBeingRemovedFromScene += new EventManager.ObjectBeingRemovedFromScene(RegionSyncModule_OnObjectBeingRemovedFromScene); + //m_scene.EventManager.OnObjectBeingRemovedFromScene += new EventManager.ObjectBeingRemovedFromScene(RegionSyncModule_OnObjectBeingRemovedFromScene); } @@ -1273,7 +1273,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule /// only be triggered by an object removal that is initiated locally. /// /// - private void RegionSyncModule_OnObjectBeingRemovedFromScene(SceneObjectGroup sog) + //private void RegionSyncModule_OnObjectBeingRemovedFromScene(SceneObjectGroup sog) + public void SendDeleteObject(SceneObjectGroup sog) { //m_log.DebugFormat("RegionSyncModule_OnObjectBeingRemovedFromScene called at time {0}:{1}:{2}", DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond); diff --git a/OpenSim/Region/Framework/Interfaces/IRegionSyncModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionSyncModule.cs index 8733f8ec6d..8709d4cd46 100755 --- a/OpenSim/Region/Framework/Interfaces/IRegionSyncModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IRegionSyncModule.cs @@ -63,7 +63,7 @@ namespace OpenSim.Region.Framework.Interfaces //void SendUpdatesToSynchronizeState(List sog); void SendSceneUpdates(); void SendTerrainUpdates(string lastUpdateActorID); - //void SendDeleteObject(SceneObjectGroup sog); + void SendDeleteObject(SceneObjectGroup sog); //For propogating scene events to other actors void PublishSceneEvent(EventManager.EventNames ev, Object[] evArgs); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 07c5d70d6c..721feda63d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -662,8 +662,7 @@ namespace OpenSim.Region.Framework.Scenes if (UnlinkSceneObject(group, false)) { - //For object removals caused by remote events (by other actors), do not trigger local event ObjectBeingRemovedFromScene - //EventManager.TriggerObjectBeingRemovedFromScene(group); + EventManager.TriggerObjectBeingRemovedFromScene(group); EventManager.TriggerParcelPrimCountTainted(); } @@ -2430,8 +2429,16 @@ namespace OpenSim.Region.Framework.Scenes { part.SyncInfoUpdate(); } - //end of SYMMETRIC SYNC + * * */ + + //Propagate the RemovedObject message + if (RegionSyncModule != null) + { + RegionSyncModule.SendDeleteObject(group); + } + //end of SYMMETRIC SYNC + } /// @@ -3592,9 +3599,12 @@ namespace OpenSim.Region.Framework.Scenes ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); + //SYMMETRIC SYNC: object remove should be handled through RegionSyncModule // REGION SYNC + /* if( IsSyncedServer() ) RegionSyncServerModule.DeleteObject(m_regionHandle, localID, part); + * */ } #endregion diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 2a8f2990b6..1b0c0fcd7b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1163,7 +1163,8 @@ namespace OpenSim.Region.Framework.Scenes Scene.RegionSyncServerModule.DeleteObject(part.RegionHandle, part.LocalId, part); //return; } - * */ + * */ + //end of SYMMETRIC SYNC Scene.ForEachScenePresence(delegate(ScenePresence avatar) { From 719f59db3f1ec12198e6f8dece524f4599f05987 Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Fri, 14 Jan 2011 16:58:06 -0800 Subject: [PATCH 17/20] Added code to propagate OnNewScript event, when client sends in RezScript request (e.g. add new script to a prim). --- .../SymmetricSync/RegionSyncModule.cs | 87 ++++++++++++++++++- .../SymmetricSync/ScriptEngineSyncModule.cs | 10 +++ .../SymmetricSync/SymmetricSyncMessage.cs | 1 + .../Region/Framework/Scenes/EventManager.cs | 55 +++++++++++- .../Framework/Scenes/Scene.Inventory.cs | 55 +++++++++++- .../Framework/Scenes/Scene.PacketHandlers.cs | 2 - 6 files changed, 199 insertions(+), 11 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index 860b80b708..33f9c76776 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -91,6 +91,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_scene.EventManager.OnPostSceneCreation += OnPostSceneCreation; //m_scene.EventManager.OnObjectBeingRemovedFromScene += new EventManager.ObjectBeingRemovedFromScene(RegionSyncModule_OnObjectBeingRemovedFromScene); + LogHeader += "-" + scene.RegionInfo.RegionName; } //Called after AddRegion() has been called for all region modules of the scene @@ -882,6 +883,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule return; } //EVENTS PROCESSING + case SymmetricSyncMessage.MsgType.NewScript: case SymmetricSyncMessage.MsgType.UpdateScript: case SymmetricSyncMessage.MsgType.ScriptReset: case SymmetricSyncMessage.MsgType.ChatFromClient: @@ -1040,6 +1042,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule switch (msg.Type) { + case SymmetricSyncMessage.MsgType.NewScript: + HandleRemoteEvent_OnNewScript(init_actorID, evSeqNum, data); + break; case SymmetricSyncMessage.MsgType.UpdateScript: HandleRemoteEvent_OnUpdateScript(init_actorID, evSeqNum, data); break; @@ -1070,9 +1075,54 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } } + /// + /// + /// + /// the ID of the actor that initiates the event + /// sequence num of the event from the actor + /// OSDMap data of event args + private void HandleRemoteEvent_OnNewScript(string actorID, ulong evSeqNum, OSDMap data) + { + m_log.Debug(LogHeader + ", " + m_actorID + ": received NewScript"); + + UUID agentID = data["agentID"].AsUUID(); + UUID primID = data["primID"].AsUUID(); + UUID itemID = data["itemID"].AsUUID(); + + string sogXml = data["sog"].AsString(); + SceneObjectGroup sog = SceneObjectSerializer.FromXml2Format(sogXml); + SceneObjectPart part = null; + + foreach (SceneObjectPart prim in sog.Parts) + { + if(prim.UUID.Equals(primID)){ + part = prim; + break; + } + } + if(part == null) + { + m_log.Warn(LogHeader+": part "+primID+" not exist in the serialized object, do nothing"); + return; + } + //Update the object first + Scene.ObjectUpdateResult updateResult = m_scene.AddOrUpdateObjectBySynchronization(sog); + + if (updateResult == Scene.ObjectUpdateResult.Updated || updateResult == Scene.ObjectUpdateResult.New) + { + m_log.Debug(LogHeader + ": TriggerNewScriptLocally"); + //Next, trigger creating the new script + SceneObjectPart localPart = m_scene.GetSceneObjectPart(primID); + m_scene.EventManager.TriggerNewScriptLocally(agentID, localPart, itemID); + } + } + + /// /// Special actions for remote event UpdateScript /// + /// the ID of the actor that initiates the event + /// sequence num of the event from the actor /// OSDMap data of event args private void HandleRemoteEvent_OnUpdateScript(string actorID, ulong evSeqNum, OSDMap data) { @@ -1089,7 +1139,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } /// - /// Special actions for remote event UpdateScript + /// Special actions for remote event ScriptReset /// /// OSDMap data of event args private void HandleRemoteEvent_OnScriptReset(string actorID, ulong evSeqNum, OSDMap data) @@ -1296,13 +1346,20 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { switch (ev) { + case EventManager.EventNames.NewScript: + if (evArgs.Length < 3) + { + m_log.Error(LogHeader + " not enough event args for NewScript"); + return; + } + OnLocalNewScript((UUID)evArgs[0], (SceneObjectPart)evArgs[1], (UUID)evArgs[2]); + return; case EventManager.EventNames.UpdateScript: if (evArgs.Length < 5) { m_log.Error(LogHeader + " not enough event args for UpdateScript"); return; } - m_log.Debug(LogHeader + " PublishSceneEvent UpdateScript"); OnLocalUpdateScript((UUID)evArgs[0], (UUID)evArgs[1], (UUID)evArgs[2], (bool)evArgs[3], (UUID)evArgs[4]); return; case EventManager.EventNames.ScriptReset: @@ -1343,6 +1400,32 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } } + /// + /// The handler for (locally initiated) event OnNewScript: triggered by client's RezSript packet, publish it to other actors. + /// + /// ID of the client who creates the new script + /// the prim that contains the new script + private void OnLocalNewScript(UUID clientID, SceneObjectPart part, UUID itemID) + { + m_log.Debug(LogHeader + " RegionSyncModule_OnLocalNewScript"); + + SceneObjectGroup sog = part.ParentGroup; + if(sog==null){ + m_log.Warn(LogHeader + ": part " + part.UUID + " not in an SceneObjectGroup yet. Will not propagating new script event"); + //sog = new SceneObjectGroup(part); + return; + } + //For simplicity, we just leverage a SOP's serialization method to transmit the information of new inventory item for the script). + //This can certainly be optimized later (e.g. only sending serialization of the inventory item) + OSDMap data = new OSDMap(); + data["agentID"] = OSD.FromUUID(clientID); + data["primID"] = OSD.FromUUID(part.UUID); + data["itemID"] = OSD.FromUUID(itemID); //id of the new inventory item of the part + data["sog"] = OSD.FromString(SceneObjectSerializer.ToXml2Format(sog)); + + SendSceneEvent(SymmetricSyncMessage.MsgType.NewScript, data); + } + /// /// The handler for (locally initiated) event OnUpdateScript: publish it to other actors. /// diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScriptEngineSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScriptEngineSyncModule.cs index cc9213b722..ee6ab985bc 100755 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScriptEngineSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ScriptEngineSyncModule.cs @@ -89,8 +89,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //for local OnUpdateScript, we'll handle it the same way as a remove OnUpdateScript. //RegionSyncModule will capture a locally initiated OnUpdateScript event and publish it to other actors. + m_scene.EventManager.OnNewScript += ScriptEngine_OnNewScript; m_scene.EventManager.OnUpdateScript += ScriptEngine_OnUpdateScript; //m_scene.EventManager.OnUpdateScriptBySync += ScriptEngine_OnUpdateScript; + + LogHeader += "-" + m_actorID + "-" + m_scene.RegionInfo.RegionName; } //Called after AddRegion() has been called for all region modules of the scene. @@ -182,6 +185,13 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_scene.DeleteAllSceneObjects(); } + public void ScriptEngine_OnNewScript(UUID agentID, SceneObjectPart part, UUID itemID) + { + m_log.Debug(LogHeader + " ScriptEngine_OnUpdateScript"); + + m_scene.SymSync_OnNewScript(agentID, itemID, part); + } + //Assumption, when this function is triggered, the new script asset has already been saved. public void ScriptEngine_OnUpdateScript(UUID agentID, UUID itemID, UUID primID, bool isScriptRunning, UUID newAssetID) { diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs index b093a16702..8e5f09bb8f 100755 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs @@ -34,6 +34,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //RegionStatus, ActorID, //events + NewScript, UpdateScript, ScriptReset, ChatFromClient, diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index f3b5e17677..0d5d3a749e 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -50,6 +50,7 @@ namespace OpenSim.Region.Framework.Scenes //the events that we'll handle specially in sym-sync public enum EventNames { + NewScript, UpdateScript, ScriptReset, ChatFromClient, //chats from avatars @@ -65,6 +66,30 @@ namespace OpenSim.Region.Framework.Scenes m_scene = scene; } + #region UpdateScript + //triggered by client.OnRezScript + public override void TriggerNewScript(UUID clientID, SceneObjectPart part, UUID itemID) + { + //publish the event to other actors who are intersted in it + if (m_scene.RegionSyncModule != null) + { + Object[] eventArgs = new Object[3]; + eventArgs[0] = (Object)clientID; + eventArgs[1] = (Object)part; + eventArgs[2] = (Object)itemID; + m_scene.RegionSyncModule.PublishSceneEvent(EventNames.NewScript, eventArgs); + } + + //trigger event locally, + TriggerNewScriptLocally(clientID, part, itemID); + } + //public void TriggerNewScriptLocally(UUID clientID, UUID itemId, UUID primId, UUID newAssetID) + public void TriggerNewScriptLocally(UUID clientID, SceneObjectPart part, UUID itemID) + { + base.TriggerNewScript(clientID, part, itemID); + } + #endregion //UpdateScript + #region UpdateScript public override void TriggerUpdateScript(UUID clientId, UUID itemId, UUID primId, bool isScriptRunning, UUID newAssetID) { @@ -80,7 +105,7 @@ namespace OpenSim.Region.Framework.Scenes m_scene.RegionSyncModule.PublishSceneEvent(EventNames.UpdateScript, eventArgs); } - //trigger event locally, as the legacy code does + //trigger event locally, TriggerUpdateScriptLocally(clientId, itemId, primId, isScriptRunning, newAssetID); } public void TriggerUpdateScriptLocally(UUID clientId, UUID itemId, UUID primId, bool isScriptRunning, UUID newAssetID) @@ -2378,8 +2403,32 @@ namespace OpenSim.Region.Framework.Scenes } } } - - //OnUpdateTaskInventoryScriptAsset: triggered after Scene receives client's upload of updated script and stores it as asset + + public delegate void NewScript(UUID clientID, SceneObjectPart part, UUID itemID); + public event NewScript OnNewScript; + public virtual void TriggerNewScript(UUID clientID, SceneObjectPart part, UUID itemID) + { + NewScript handlerNewScript = OnNewScript; + if (handlerNewScript != null) + { + foreach (NewScript d in handlerNewScript.GetInvocationList()) + { + try + { + d(clientID, part, itemID); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[EVENT MANAGER]: Delegate for TriggerNewScript failed - continuing. {0} {1}", + e.Message, e.StackTrace); + } + } + } + } + + + //TriggerUpdateScript: triggered after Scene receives client's upload of updated script and stores it as asset public delegate void UpdateScript(UUID clientID, UUID itemId, UUID primId, bool isScriptRunning, UUID newAssetID); public event UpdateScript OnUpdateScript; public virtual void TriggerUpdateScript(UUID clientId, UUID itemId, UUID primId, bool isScriptRunning, UUID newAssetID) diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 2c6ab2ee6b..9f1a31e7d8 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -310,7 +310,7 @@ namespace OpenSim.Region.Framework.Scenes * */ //SYMMETRIC SYNC: Distributed Scene Graph implementation - m_log.Debug("Scene.Inventory: to call EventManager.TriggerUpdateTaskInventoryScriptAsset, agentID: " + remoteClient.AgentId); + m_log.Debug("Scene.Inventory: to call EventManager.TriggerUpdateScript, agentID: " + remoteClient.AgentId); //Trigger OnUpdateScript event. EventManager.TriggerUpdateScript(remoteClient.AgentId, itemId, primId, isScriptRunning, item.AssetID); @@ -369,6 +369,14 @@ namespace OpenSim.Region.Framework.Scenes #endregion #region SYMMETRIC SYNC + public void SymSync_OnNewScript(UUID avatarID, UUID itemID, SceneObjectPart part) + { + TaskInventoryItem item = part.Inventory.GetInventoryItem(itemID); + + part.Inventory.CreateScriptInstance(item, 0, false, DefaultScriptEngine, 0); + part.ParentGroup.ResumeScripts(); + } + //only a script engine actor is supposed to call this function public ArrayList SymSync_OnUpdateScript(UUID avatarID, UUID itemID, UUID primID, bool isScriptRunning, UUID newAssetID) { @@ -1663,6 +1671,10 @@ namespace OpenSim.Region.Framework.Scenes return; part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID); + part.GetProperties(remoteClient); + + //SYMMETRIC SYNC + /* Original OpenSim code, commented out // TODO: switch to posting on_rez here when scripts // have state in inventory part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0); @@ -1670,8 +1682,26 @@ namespace OpenSim.Region.Framework.Scenes // m_log.InfoFormat("[PRIMINVENTORY]: " + // "Rezzed script {0} into prim local ID {1} for user {2}", // item.inventoryName, localID, remoteClient.Name); - part.GetProperties(remoteClient); + //part.GetProperties(remoteClient); part.ParentGroup.ResumeScripts(); + * */ + if (RegionSyncModule != null) + { + part.SyncInfoUpdate(); + EventManager.TriggerNewScript(remoteClient.AgentId, part, copyID); + } + else + { + part.Inventory.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0); + + // m_log.InfoFormat("[PRIMINVENTORY]: " + + // "Rezzed script {0} into prim local ID {1} for user {2}", + // item.inventoryName, localID, remoteClient.Name); + //part.GetProperties(remoteClient); + part.ParentGroup.ResumeScripts(); + } + //end of SYMMETRIC SYNC + } else { @@ -1730,8 +1760,25 @@ namespace OpenSim.Region.Framework.Scenes part.Inventory.AddInventoryItem(taskItem, false); part.GetProperties(remoteClient); - part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); - part.ParentGroup.ResumeScripts(); + //SYMMETRIC SYNC + //part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); + //part.ParentGroup.ResumeScripts(); + if (RegionSyncModule != null) + { + part.SyncInfoUpdate(); + EventManager.TriggerNewScript(remoteClient.AgentId, part, taskItem.ItemID); + } + else + { + part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0); + + // m_log.InfoFormat("[PRIMINVENTORY]: " + + // "Rezzed script {0} into prim local ID {1} for user {2}", + // item.inventoryName, localID, remoteClient.Name); + //part.GetProperties(remoteClient); + part.ParentGroup.ResumeScripts(); + } + //end of SYMMETRIC SYNC } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 52611df715..ab567fbcb0 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -69,8 +69,6 @@ namespace OpenSim.Region.Framework.Scenes EventManager.TriggerOnChatBroadcast(this, args); else EventManager.TriggerOnChatFromWorld(this, args); - - m_log.Debug("end of SimChat"); } /// From c8dc14fb01d4d87b6ef72f12a604b38a467b1f7d Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Mon, 17 Jan 2011 17:13:15 -0800 Subject: [PATCH 18/20] Configuration of SyncListenerIPAddress, SyncListenerPort, ServerIPAddress, and ServerPort is moved to Regions.ini. --- OpenSim/Framework/RegionInfo.cs | 42 +++++++++++++++++++ .../RegionSyncClientModule.cs | 21 +++++++--- .../RegionSyncServerModule.cs | 14 +++++-- .../SymmetricSync/RegionSyncModule.cs | 17 +++++--- 4 files changed, 80 insertions(+), 14 deletions(-) diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 680e702a11..857d811d23 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -386,6 +386,14 @@ namespace OpenSim.Framework public string RemotingAddress; public UUID ScopeID = UUID.Zero; + //SYMMETRIC SYNC + //IP:port for the symmetric sync listener this actor is configured to connect to + private string m_syncListenerAddr = String.Empty; + private int m_syncListenerPort; + //IP:port for the avatar sync server this actor is configured to connect to + private string m_serverAddr = String.Empty; + private int m_serverPort; + //end of SYMMETRIC SYNC // Apparently, we're applying the same estatesettings regardless of whether it's local or remote. @@ -676,6 +684,25 @@ namespace OpenSim.Framework get { return Util.UIntsToLong((RegionLocX * (uint) Constants.RegionSize), (RegionLocY * (uint) Constants.RegionSize)); } } + //SYMMETRIC SYNC + public string SyncListenerAddress + { + get { return m_syncListenerAddr; } + } + public int SyncListenerPort + { + get { return m_syncListenerPort; } + } + public string ServerIPAddress + { + get { return m_serverAddr; } + } + public int ServerPort + { + get { return m_serverPort; } + } + //end of SYMMETRIC SYNC + public void SetEndPoint(string ipaddr, int port) { IPAddress tmpIP = IPAddress.Parse(ipaddr); @@ -830,6 +857,21 @@ namespace OpenSim.Framework // Multi-tenancy // ScopeID = new UUID(config.GetString("ScopeID", UUID.Zero.ToString())); + + // SYMMETRIC SYNC + m_syncListenerAddr = config.GetString("SyncListenerIPAddress", String.Empty); + m_syncListenerPort = config.GetInt("SyncListenerPort", -1); + //if either IP or port is not configured, we set IP to empty to raise warning later + if (m_syncListenerPort == -1) + m_syncListenerAddr = String.Empty; + + m_serverAddr = config.GetString("ServerIPAddress", String.Empty); + m_serverPort = config.GetInt("ServerPort", -1); + if (m_serverPort == -1) + m_serverAddr = String.Empty; + + // end of SYMMETRIC SYNC + } private void WriteNiniConfig(IConfigSource source) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientModule.cs index a065be3002..c0bd54ca56 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientModule.cs @@ -69,10 +69,12 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_active = true; m_scene.RegionSyncEnabled = true; m_scene.RegionSyncMode = "client"; - string serverAddrDefault = syncConfig.GetString("ServerIPAddress", "127.0.0.1"); - m_serveraddr = syncConfig.GetString(scene.RegionInfo.RegionName+"_ServerIPAddress", serverAddrDefault); - int serverPortDefault = syncConfig.GetInt("ServerPort", 13000); - m_serverport = syncConfig.GetInt(scene.RegionInfo.RegionName+"_ServerPort", serverPortDefault); + + //string serverAddrDefault = syncConfig.GetString("ServerIPAddress", "127.0.0.1"); + //m_serveraddr = syncConfig.GetString(scene.RegionInfo.RegionName+"_ServerIPAddress", serverAddrDefault); + //int serverPortDefault = syncConfig.GetInt("ServerPort", 13000); + //m_serverport = syncConfig.GetInt(scene.RegionInfo.RegionName+"_ServerPort", serverPortDefault); + m_scene.RegisterModuleInterface(this); m_symsync = syncConfig.GetBoolean("SymSync", false); @@ -230,7 +232,16 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule private void Start() { - + m_serveraddr = m_scene.RegionInfo.ServerIPAddress; + m_serverport = m_scene.RegionInfo.ServerPort; + + if (m_serveraddr.Equals(String.Empty) || m_serverport == -1) + { + m_log.Warn("[REGION SYNC CLIENT MODULE] No IP or port of RegionSyncServer has been configured. Shut down."); + m_active = false; + return; + } + lock (m_client_lock) { if (m_client != null) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs index d408e87202..49753fe399 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncServerModule.cs @@ -97,10 +97,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_statsWriter = File.AppendText(syncstats); //Get sync server info for Client Manager actors - string serverAddr = scene.RegionInfo.RegionName + "_ServerIPAddress"; - m_serveraddr = syncConfig.GetString(serverAddr, IPAddrUnknown); - string serverPort = scene.RegionInfo.RegionName + "_ServerPort"; - m_serverport = syncConfig.GetInt(serverPort, PortUnknown); + //string serverAddr = scene.RegionInfo.RegionName + "_ServerIPAddress"; + //m_serveraddr = syncConfig.GetString(serverAddr, IPAddrUnknown); + //string serverPort = scene.RegionInfo.RegionName + "_ServerPort"; + //m_serverport = syncConfig.GetInt(serverPort, PortUnknown); + // Client manager load balancing m_maxClientsPerManager = syncConfig.GetInt("MaxClientsPerManager", 100); DefaultPort++; @@ -154,6 +155,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } //end of SYMMETRIC SYNC // Start the server and listen for RegionSyncClients + m_serveraddr = m_scene.RegionInfo.ServerIPAddress; + m_serverport = m_scene.RegionInfo.ServerPort; + + m_log.Debug("[REGION SYNC SERVER MODULE] to start server on " + m_serveraddr + ":" + m_serverport); + if (!m_serveraddr.Equals(IPAddrUnknown) && m_serverport != PortUnknown) { m_log.Warn("[REGION SYNC SERVER MODULE] Starting RegionSyncServer"); diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index 33f9c76776..a4972d05d6 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -377,7 +377,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule ///////////////////////////////////////////////////////////////////////////////////////// private static int PortUnknown = -1; - private static string IPAddrUnknown = ""; + private static string IPAddrUnknown = String.Empty; private ILog m_log; //private bool m_active = true; @@ -563,8 +563,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { m_log.Debug("reading in " + m_scene.RegionInfo.RegionName + "_SyncListenerIPAddress" + " and " + m_scene.RegionInfo.RegionName + "_SyncListenerPort"); - string addr = m_sysConfig.GetString(m_scene.RegionInfo.RegionName+"_SyncListenerIPAddress", IPAddrUnknown); - int port = m_sysConfig.GetInt(m_scene.RegionInfo.RegionName+"_SyncListenerPort", PortUnknown); + //string addr = m_sysConfig.GetString(m_scene.RegionInfo.RegionName+"_SyncListenerIPAddress", IPAddrUnknown); + //int port = m_sysConfig.GetInt(m_scene.RegionInfo.RegionName+"_SyncListenerPort", PortUnknown); + + string addr = m_scene.RegionInfo.SyncListenerAddress; + int port = m_scene.RegionInfo.SyncListenerPort; m_log.Warn(LogHeader + ", listener addr: " + addr + ", port: " + port); @@ -586,8 +589,12 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { //For now, we assume there is only one remote listener to connect to. Later on, //we may need to modify the code to read in multiple listeners. - string addr = m_sysConfig.GetString(m_scene.RegionInfo.RegionName + "_SyncListenerIPAddress", IPAddrUnknown); - int port = m_sysConfig.GetInt(m_scene.RegionInfo.RegionName + "_SyncListenerPort", PortUnknown); + //string addr = m_sysConfig.GetString(m_scene.RegionInfo.RegionName + "_SyncListenerIPAddress", IPAddrUnknown); + //int port = m_sysConfig.GetInt(m_scene.RegionInfo.RegionName + "_SyncListenerPort", PortUnknown); + + string addr = m_scene.RegionInfo.SyncListenerAddress; + int port = m_scene.RegionInfo.SyncListenerPort; + if (!addr.Equals(IPAddrUnknown) && port != PortUnknown) { RegionSyncListenerInfo info = new RegionSyncListenerInfo(addr, port); From c541b42f7e6b4656becf6f17174276e6b5bbbaa5 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 18 Jan 2011 16:52:37 -0800 Subject: [PATCH 19/20] Converted PhysicsActor identification from localID to UUID --- .../PhysEngineToSceneConnector.cs | 19 +++++++------- .../PhysEngineToSceneConnectorModule.cs | 6 ++--- .../SceneToPhysEngineConnector.cs | 25 ++++++++++--------- .../SceneToPhysEngineSyncServer.cs | 8 +++--- .../Framework/Scenes/SceneObjectGroup.cs | 1 + .../Framework/Scenes/SceneObjectPart.cs | 2 ++ .../Region/Framework/Scenes/ScenePresence.cs | 3 ++- .../Region/Physics/Manager/PhysicsActor.cs | 9 ++++++- 8 files changed, 43 insertions(+), 30 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnector.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnector.cs index 169e99290d..b1c4a5b59c 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnector.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnector.cs @@ -379,10 +379,10 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule OSDMap data = RegionSyncUtil.DeserializeMessage(msg, LogHeader); try { - uint localID = data["localID"].AsUInteger(); + UUID uuid = data["uuid"].AsUUID(); string actorID = data["actorID"].AsString(); - // m_log.DebugFormat("{0}: HandlPhysUpdateAttributes for {1}", LogHeader, localID); - PhysicsActor pa = FindPhysicsActor(localID); + // m_log.DebugFormat("{0}: HandlPhysUpdateAttributes for {1}", LogHeader, uuid); + PhysicsActor pa = FindPhysicsActor(uuid); if (pa != null) { // pa.Size = data["size"].AsVector3(); @@ -396,7 +396,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule pa.Flying = data["flying"].AsBoolean(); // receive?? pa.Kinematic = data["kinematic"].AsBoolean(); // receive?? pa.Buoyancy = (float)(data["buoyancy"].AsReal()); - SceneObjectPart sop = m_validLocalScene.GetSceneObjectPart(localID); + SceneObjectPart sop = m_validLocalScene.GetSceneObjectPart(uuid); if (sop != null) { pa.Shape = sop.Shape; @@ -405,7 +405,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } else { - m_log.WarnFormat("{0}: attribute update for unknown localID {1}", LogHeader, localID); + m_log.WarnFormat("{0}: attribute update for unknown uuid {1}", LogHeader, uuid); return; } } @@ -418,14 +418,14 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } // Find the physics actor whether it is an object or a scene presence - private PhysicsActor FindPhysicsActor(uint localID) + private PhysicsActor FindPhysicsActor(UUID uuid) { - SceneObjectPart sop = m_validLocalScene.GetSceneObjectPart(localID); + SceneObjectPart sop = m_validLocalScene.GetSceneObjectPart(uuid); if (sop != null) { return sop.PhysActor; } - ScenePresence sp = m_validLocalScene.GetScenePresence(localID); + ScenePresence sp = m_validLocalScene.GetScenePresence(uuid); if (sp != null) { return sp.PhysicsActor; @@ -435,9 +435,10 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule public void SendPhysUpdateAttributes(PhysicsActor pa) { - // m_log.DebugFormat("{0}: SendPhysUpdateAttributes for {1}", LogHeader, pa.LocalID); + // m_log.DebugFormat("{0}: SendPhysUpdateAttributes for {1}", LogHeader, pa.UUID); OSDMap data = new OSDMap(9); data["localID"] = OSD.FromUInteger(pa.LocalID); + data["uuid"] = OSD.FromUUID(pa.UUID); data["actorID"] = OSD.FromString(RegionSyncServerModule.ActorID); data["size"] = OSD.FromVector3(pa.Size); data["position"] = OSD.FromVector3(pa.Position); diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnectorModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnectorModule.cs index caa6277035..2a36d176b7 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnectorModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/PhysEngineToSceneConnectorModule.cs @@ -240,7 +240,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { try { - sop = ss.GetSceneObjectPart(pa.LocalID); + sop = ss.GetSceneObjectPart(pa.UUID); } catch { @@ -253,7 +253,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } try { - sp = ss.GetScenePresence(pa.LocalID); + sp = ss.GetScenePresence(pa.UUID); } catch { @@ -278,7 +278,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } else { - Console.WriteLine("RouteUpdate: no SOP found for {0}", pa.LocalID); + Console.WriteLine("RouteUpdate: no SOP found for {0}", pa.UUID); } return; } diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineConnector.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineConnector.cs index 611eb1ed32..f4e66d54a1 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineConnector.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineConnector.cs @@ -296,16 +296,16 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule OSDMap data = RegionSyncUtil.DeserializeMessage(msg, LogHeader); try { - uint localID = data["localID"].AsUInteger(); - // m_log.DebugFormat("{0}: received PhysUpdateAttributes for {1}", LogHeader, localID); - PhysicsActor pa = FindPhysicsActor(localID); + UUID uuid = data["uuid"].AsUUID(); + // m_log.DebugFormat("{0}: received PhysUpdateAttributes for {1}", LogHeader, uuid); + PhysicsActor pa = FindPhysicsActor(uuid); if (pa != null) { pa.RequestPhysicsterseUpdate(); } else { - m_log.WarnFormat("{0}: terse update for unknown localID {1}", LogHeader, localID); + m_log.WarnFormat("{0}: terse update for unknown uuid {1}", LogHeader, uuid); return; } } @@ -339,10 +339,10 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule OSDMap data = RegionSyncUtil.DeserializeMessage(msg, LogHeader); try { - uint localID = data["localID"].AsUInteger(); + UUID uuid = data["uuid"].AsUUID(); string actorID = data["actorID"].AsString(); - // m_log.DebugFormat("{0}: received PhysUpdateAttributes for {1}", LogHeader, localID); - PhysicsActor pa = FindPhysicsActor(localID); + // m_log.DebugFormat("{0}: received PhysUpdateAttributes for {1}", LogHeader, uuid); + PhysicsActor pa = FindPhysicsActor(uuid); if (pa != null) { pa.ChangingActorID = actorID; @@ -363,7 +363,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } else { - m_log.WarnFormat("{0}: attribute update for unknown localID {1}", LogHeader, localID); + m_log.WarnFormat("{0}: attribute update for unknown uuid {1}", LogHeader, uuid); return; } } @@ -376,14 +376,14 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } // Find the physics actor whether it is an object or a scene presence - private PhysicsActor FindPhysicsActor(uint localID) + private PhysicsActor FindPhysicsActor(UUID uuid) { - SceneObjectPart sop = m_scene.GetSceneObjectPart(localID); + SceneObjectPart sop = m_scene.GetSceneObjectPart(uuid); if (sop != null) { return sop.PhysActor; } - ScenePresence sp = m_scene.GetScenePresence(localID); + ScenePresence sp = m_scene.GetScenePresence(uuid); if (sp != null) { return sp.PhysicsActor; @@ -393,9 +393,10 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule public void SendPhysUpdateAttributes(PhysicsActor pa) { - // m_log.DebugFormat("{0}: sending PhysUpdateAttributes for {1}", LogHeader, pa.LocalID); + // m_log.DebugFormat("{0}: sending PhysUpdateAttributes for {1}", LogHeader, pa.UUID); OSDMap data = new OSDMap(9); data["localID"] = OSD.FromUInteger(pa.LocalID); + data["uuid"] = OSD.FromUUID(pa.UUID); data["actorID"] = OSD.FromString(RegionSyncServerModule.ActorID); data["size"] = OSD.FromVector3(pa.Size); data["position"] = OSD.FromVector3(pa.Position); diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineSyncServer.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineSyncServer.cs index 8b432030d0..8c61a466da 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineSyncServer.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SceneToPhysEngineSyncServer.cs @@ -231,7 +231,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { try { - sop = ss.GetSceneObjectPart(pa.LocalID); + sop = ss.GetSceneObjectPart(pa.UUID); } catch { @@ -244,7 +244,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } else { - ScenePresence sp = ss.GetScenePresence(pa.LocalID); + ScenePresence sp = ss.GetScenePresence(pa.UUID); if (sp != null) { s = ss; @@ -260,12 +260,12 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } else { - Console.WriteLine("RouteUpdate: SceneToPhysEngineSyncServer is no available"); + Console.WriteLine("RouteUpdate: SceneToPhysEngineSyncServer is not available"); } } else { - Console.WriteLine("RouteUpdate: no SOP for update of {0}", pa.LocalID); + Console.WriteLine("RouteUpdate: no SOP for update of {0}", pa.UUID); } return; } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 1b0c0fcd7b..044af42cb8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1468,6 +1468,7 @@ namespace OpenSim.Region.Framework.Scenes part.PhysActor.IsPhysical); part.PhysActor.LocalID = part.LocalId; + part.PhysActor.UUID = part.UUID; part.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true); } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index c8941f1c55..bb1669bb6f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1593,6 +1593,7 @@ namespace OpenSim.Region.Framework.Scenes PhysActor.SOPName = this.Name; // save object name and desc into the PhysActor so ODE internals know the joint/body info PhysActor.SOPDescription = this.Description; PhysActor.LocalID = LocalId; + PhysActor.UUID = UUID; DoPhysicsPropertyUpdate(RigidBody, true); PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0); } @@ -4440,6 +4441,7 @@ namespace OpenSim.Region.Framework.Scenes if (pa != null) { pa.LocalID = LocalId; + pa.UUID = this.UUID; DoPhysicsPropertyUpdate(UsePhysics, true); if (m_parentGroup != null) { diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index e92604b570..3a80788147 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3342,8 +3342,9 @@ namespace OpenSim.Region.Framework.Scenes m_physicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong m_physicsActor.SubscribeEvents(500); m_physicsActor.LocalID = LocalId; + m_physicsActor.UUID = this.UUID; } - + private void OutOfBoundsCall(Vector3 pos) { //bool flying = m_physicsActor.Flying; diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index ce4c45a672..cb205de207 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -185,10 +185,17 @@ namespace OpenSim.Region.Physics.Manager // RA: used to be abstract but changed to allow 'get' without changing all the phys engines uint m_baseLocalID; - public virtual uint LocalID { + public virtual uint LocalID + { set { m_baseLocalID = value; } get { return m_baseLocalID; } } + public UUID m_UUID; + public virtual UUID UUID + { + set { m_UUID = value; } + get { return m_UUID; } + } public PhysActorLastValues lastValues; // ID of actor which last updated the values. Send if I did the change. public string ChangingActorID = "YY"; From 8256caad3f5fa0702f588219ceb7227cdcd76edb Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 19 Jan 2011 08:50:41 -0800 Subject: [PATCH 20/20] Remove setting of localID on newly created avatar. This solves the case of later viewers in other regions not seeing position updates for other avatars. --- .../RegionSync/RegionSyncModule/RegionSyncClient.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs index 4b5d475198..77eff38aad 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs @@ -404,12 +404,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule else { sp.IsSyncedAvatar = true; - m_log.DebugFormat("{0}: Setting avatar local ID to {1}", LogHeader(), localID); - sp.LocalId = localID; - if (sp.PhysicsActor != null) - { - sp.PhysicsActor.LocalID = localID; - } } //RegionSyncMessage.HandlerDebug(LogHeader(), msg, String.Format("Added new remote avatar \"{0}\" ({1})", first + " " + last, agentID)); RegionSyncMessage.HandleSuccess(LogHeader(), msg, String.Format("Added new remote avatar \"{0}\" ({1})", first + " " + last, agentID));