From f99b516eecc13f13b2a8063c0cf03cd646dddd23 Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Wed, 16 Feb 2011 14:29:08 -0800 Subject: [PATCH 1/6] Added serialization/deserilaization of Attachment related SOP properties to sync AttachObject. --- .../SymmetricSync/ClientManagerSyncModule.cs | 2 +- .../SymmetricSync/PhysicsEngineSyncModule.cs | 2 +- .../Framework/Scenes/SceneObjectPart.cs | 70 ++++++++++++++++--- .../Serialization/SceneObjectSerializer.cs | 53 +++++++++++--- 4 files changed, 104 insertions(+), 23 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ClientManagerSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ClientManagerSyncModule.cs index 1e2dd6fee6..dd35d1b621 100755 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ClientManagerSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/ClientManagerSyncModule.cs @@ -48,7 +48,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //Read in configuration, if the local actor is configured to be a client manager, load this module. if (!actorType.Equals("client_manager")) { - m_log.Warn(LogHeader + ": not configured as Scene Persistence Actor. Shut down."); + m_log.Warn(LogHeader + ": not configured as Client Manager Actor. Shut down."); return; } diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/PhysicsEngineSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/PhysicsEngineSyncModule.cs index addb52e041..a9346ecad8 100755 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/PhysicsEngineSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/PhysicsEngineSyncModule.cs @@ -48,7 +48,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //Read in configuration, if the local actor is configured to be a client manager, load this module. if (!actorType.Equals("physics_engine")) { - m_log.Warn(LogHeader + ": not configured as Scene Persistence Actor. Shut down."); + m_log.Warn(LogHeader + ": not configured as Physics Engine Actor. Shut down."); return; } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 41df189fac..733d898678 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -226,19 +226,49 @@ namespace OpenSim.Region.Framework.Scenes } - public bool IsAttachment; + //public bool IsAttachment; + private bool m_isAttachment; + public bool IsAttachment + { + get { return m_isAttachment; } + set { m_isAttachment = value; } + } - public scriptEvents AggregateScriptEvents; + //public scriptEvents AggregateScriptEvents; + private scriptEvents m_aggregateScriptEvents; + public scriptEvents AggregateScriptEvents + { + get { return m_aggregateScriptEvents; } + set { m_aggregateScriptEvents = value; } + } + + + //public UUID AttachedAvatar; + private UUID m_attachedAvatar; + public UUID AttachedAvatar + { + get { return m_attachedAvatar; } + set { m_attachedAvatar = value; } + } - public UUID AttachedAvatar; + //public Vector3 AttachedPos; + private Vector3 m_attachedPos; + public Vector3 AttachedPos + { + get { return m_attachedPos; } + set { m_attachedPos = value; } + } - public Vector3 AttachedPos; - - - public uint AttachmentPoint; + //public uint AttachmentPoint; + private uint m_attachmentPoint; + public uint AttachmentPoint + { + get { return m_attachmentPoint; } + set { m_attachmentPoint = value; } + } public Vector3 RotationAxis = Vector3.One; @@ -5158,11 +5188,13 @@ namespace OpenSim.Region.Framework.Scenes IsPhysical, Flying, Buoyancy, - //TODO!!!! To be handled in serialization/deserizaltion for synchronization AggregateScriptEvents, - IsSelected, - AttachmentPoint, + IsAttachment, + AttachedAvatar, AttachedPos, + AttachmentPoint, + //TODO!!!! To be handled in serialization/deserizaltion for synchronization + IsSelected, Sound, //This indicates any Sound related property has changed: Sound, SoundGain, SoundFlags,SoundRadius, //Addition properties to be added here @@ -5406,6 +5438,22 @@ namespace OpenSim.Region.Framework.Scenes localPart.TextureAnimation = updatedPart.TextureAnimation; localPart.ParticleSystem = updatedPart.ParticleSystem; + if (!localPart.AttachedAvatar.Equals(updatedPart.AttachedAvatar)) + { + localPart.AttachedAvatar = updatedPart.AttachedAvatar; + ScenePresence avatar = m_parentGroup.Scene.GetScenePresence(AttachedAvatar); + localPart.ParentGroup.RootPart.SetParentLocalId(avatar.LocalId); + } + localPart.AttachedPos = updatedPart.AttachedPos; + localPart.AttachmentPoint = updatedPart.AttachmentPoint; + //NOTE!!!! IsAttachment can only be set after AttachedAvatar is set, see GroupPosition get function. + if (!localPart.AttachedAvatar.Equals(UUID.Zero) && updatedPart.IsAttachment) + { + localPart.IsAttachment = updatedPart.IsAttachment; + } + + localPart.AggregateScriptEvents = updatedPart.AggregateScriptEvents; + m_bucketSyncInfoList[bucketName].LastUpdateTimeStamp = updatedPart.BucketSyncInfoList[bucketName].LastUpdateTimeStamp; m_bucketSyncInfoList[bucketName].LastUpdateActorID = updatedPart.BucketSyncInfoList[bucketName].LastUpdateActorID; @@ -5486,7 +5534,7 @@ namespace OpenSim.Region.Framework.Scenes } long timeStamp = DateTime.Now.Ticks; - m_log.Debug("InitializeBucketSyncInfo called at " + timeStamp); + //m_log.Debug("InitializeBucketSyncInfo called at " + timeStamp); for (int i = 0; i < m_propertyBucketNames.Count; i++) { diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 9659845567..250e6c9bc8 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -330,9 +330,15 @@ namespace OpenSim.Region.Framework.Scenes.Serialization m_SOPXmlProcessors.Add("ParticleSystem", ProcessParticleSystem); //SYMMETRIC SYNC - m_SOPXmlProcessors.Add("LocalFlags", ProcessLocalFlags); + //m_SOPXmlProcessors.Add("LocalFlags", ProcessLocalFlags); //m_SOPXmlProcessors.Add("LastUpdateTimeStamp", ProcessUpdateTimeStamp); //m_SOPXmlProcessors.Add("LastUpdateActorID", ProcessLastUpdateActorID); + m_SOPXmlProcessors.Add("IsAttachment", ProcessIsAttachment); + m_SOPXmlProcessors.Add("AttachedAvatar", ProcessAttachedAvatar); + m_SOPXmlProcessors.Add("AttachedPos", ProcessAttachedPos); + m_SOPXmlProcessors.Add("AttachmentPoint", ProcessAttachmentPoint); + m_SOPXmlProcessors.Add("AggregateScriptEvents", ProcessAggregateScriptEvents); + m_SOPXmlProcessors.Add("BucketSyncInfoList", ProcessBucketSyncInfo); //end of SYMMETRIC SYNC @@ -420,11 +426,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization #region SOPXmlProcessors //SYMMETRIC SYNC NOTE: -- assignments in de-serialization should directly set the values w/o triggering SceneObjectPart.UpdateBucketSyncInfo; - //That is, calling SetXXX(value) instead of using "XXX = value". private static void ProcessAllowedDrop(SceneObjectPart obj, XmlTextReader reader) { - obj.AllowedDrop = Util.ReadBoolean(reader); - //obj.SetAllowedDrop(Util.ReadBoolean(reader)); + obj.AllowedDrop = Util.ReadBoolean(reader); } private static void ProcessCreatorID(SceneObjectPart obj, XmlTextReader reader) @@ -714,12 +718,38 @@ namespace OpenSim.Region.Framework.Scenes.Serialization { obj.LastUpdateActorID = reader.ReadElementContentAsString("LastUpdateActorID", string.Empty); } - * */ + private static void ProcessLocalFlags(SceneObjectPart obj, XmlTextReader reader) { obj.LocalFlags = Util.ReadEnum(reader, "LocalFlags"); } + * */ + + private static void ProcessIsAttachment(SceneObjectPart obj, XmlTextReader reader) + { + obj.IsAttachment = Util.ReadBoolean(reader); + } + + private static void ProcessAttachedAvatar(SceneObjectPart obj, XmlTextReader reader) + { + obj.AttachedAvatar = Util.ReadUUID(reader, "AttachedAvatar"); + } + + private static void ProcessAttachedPos(SceneObjectPart obj, XmlTextReader reader) + { + obj.AttachedPos = Util.ReadVector(reader, "AttachedPos"); + } + + private static void ProcessAttachmentPoint(SceneObjectPart obj, XmlTextReader reader) + { + obj.AttachmentPoint = (uint)reader.ReadElementContentAsInt("AttachmentPoint", string.Empty); + } + + private static void ProcessAggregateScriptEvents(SceneObjectPart obj, XmlTextReader reader) + { + obj.AggregateScriptEvents = Util.ReadEnum(reader, "AggregateScriptEvents"); + } public static void ProcessBucketSyncInfo(SceneObjectPart obj, XmlTextReader reader) { @@ -1243,9 +1273,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization writer.WriteElementString("NextOwnerMask", sop.NextOwnerMask.ToString()); //SYMMETRIC SYNC: also serialize SceneObjectPart:LocalFlags, so that it can be propogated across actors WriteFlags(writer, "Flags", sop.Flags.ToString(), options); - WriteFlags(writer, "LocalFlags", sop.LocalFlags.ToString(), options); - //writer.WriteElementString("Flags", sop.Flags.ToString()); - //writer.WriteElementString("LocalFlags", sop.Flags.ToString()); + //WriteFlags(writer, "LocalFlags", sop.LocalFlags.ToString(), options); //end SYMMETRIC SYNC WriteUUID(writer, "CollisionSound", sop.CollisionSound, options); writer.WriteElementString("CollisionSoundVolume", sop.CollisionSoundVolume.ToString()); @@ -1255,8 +1283,13 @@ namespace OpenSim.Region.Framework.Scenes.Serialization WriteBytes(writer, "ParticleSystem", sop.ParticleSystem); //SYMMETRIC SYNC - //writer.WriteElementString("LastUpdateTimeStamp", sop.LastUpdateTimeStamp.ToString()); - //writer.WriteElementString("LastUpdateActorID", sop.LastUpdateActorID); + //These properties are only meaningful for synchronization purpose. For saving oar files, they are not necessary. + //We may remove these if later we use a different method to encode object properties for synchronization. + writer.WriteElementString("IsAttachment", sop.IsAttachment.ToString().ToLower()); + WriteUUID(writer, "AttachedAvatar", sop.AttachedAvatar, options); + WriteVector(writer, "AttachedPos", sop.AttachedPos); + writer.WriteElementString("AttachmentPoint", sop.AttachmentPoint.ToString()); + WriteFlags(writer, "AggregateScriptEvents", sop.AggregateScriptEvents.ToString(), options); WriteBucketSyncInfo(writer, sop.BucketSyncInfoList); //end of SYMMETRIC SYNC From 7b9bd89a5cee634b700c6299896f108b4755a0ef Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Wed, 16 Feb 2011 15:42:10 -0800 Subject: [PATCH 2/6] Made sure IsAttachment is set only after AttachedAvatar is set. Also, in GroupPosition get, added checking of "if m_parentGroup==null". --- .../Framework/Scenes/SceneObjectPart.cs | 20 +++++++++++-------- .../Serialization/SceneObjectSerializer.cs | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 733d898678..ace1df11e3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -771,9 +771,12 @@ namespace OpenSim.Region.Framework.Scenes if (IsAttachment) { - ScenePresence sp = m_parentGroup.Scene.GetScenePresence(AttachedAvatar); - if (sp != null) - return sp.AbsolutePosition; + if (m_parentGroup != null) //need to check this, it would be null while deserialization -- IsAttachment is now serialized + { + ScenePresence sp = m_parentGroup.Scene.GetScenePresence(AttachedAvatar); + if (sp != null) + return sp.AbsolutePosition; + } } return m_groupPosition; @@ -5445,12 +5448,13 @@ namespace OpenSim.Region.Framework.Scenes localPart.ParentGroup.RootPart.SetParentLocalId(avatar.LocalId); } localPart.AttachedPos = updatedPart.AttachedPos; - localPart.AttachmentPoint = updatedPart.AttachmentPoint; + localPart.SetAttachmentPoint(updatedPart.AttachmentPoint); + //localPart.AttachmentPoint = updatedPart.AttachmentPoint; //NOTE!!!! IsAttachment can only be set after AttachedAvatar is set, see GroupPosition get function. - if (!localPart.AttachedAvatar.Equals(UUID.Zero) && updatedPart.IsAttachment) - { - localPart.IsAttachment = updatedPart.IsAttachment; - } + //if (!localPart.AttachedAvatar.Equals(UUID.Zero) && updatedPart.IsAttachment) + //{ + // localPart.IsAttachment = updatedPart.IsAttachment; + //} localPart.AggregateScriptEvents = updatedPart.AggregateScriptEvents; diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 250e6c9bc8..9e8276e322 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -1285,10 +1285,10 @@ namespace OpenSim.Region.Framework.Scenes.Serialization //SYMMETRIC SYNC //These properties are only meaningful for synchronization purpose. For saving oar files, they are not necessary. //We may remove these if later we use a different method to encode object properties for synchronization. - writer.WriteElementString("IsAttachment", sop.IsAttachment.ToString().ToLower()); WriteUUID(writer, "AttachedAvatar", sop.AttachedAvatar, options); WriteVector(writer, "AttachedPos", sop.AttachedPos); writer.WriteElementString("AttachmentPoint", sop.AttachmentPoint.ToString()); + writer.WriteElementString("IsAttachment", sop.IsAttachment.ToString().ToLower()); //IsAttachment is written last, so that on deserialization, it will be deserialized later than other Attachment properties WriteFlags(writer, "AggregateScriptEvents", sop.AggregateScriptEvents.ToString(), options); WriteBucketSyncInfo(writer, sop.BucketSyncInfoList); //end of SYMMETRIC SYNC From 3d1048f1e2d4ff079afa0bd17299774ddd9e24cc Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Wed, 16 Feb 2011 16:57:47 -0800 Subject: [PATCH 3/6] In SOG.UpdateGroupPosition, added AttachedPos as an updated property is the object is an attachment. --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 7 ++++++- .../Scenes/Serialization/SceneObjectSerializer.cs | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 36f033c824..5120e90783 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2909,7 +2909,12 @@ namespace OpenSim.Region.Framework.Scenes //we need to do a terse update even if the move wasn't allowed // so that the position is reset in the client (the object snaps back) //ScheduleGroupForTerseUpdate(); - ScheduleGroupForTerseUpdate(new List(){SceneObjectPartProperties.GroupPosition}); + List updatedProperties = new List() { SceneObjectPartProperties.GroupPosition }; + if (IsAttachment) + { + updatedProperties.Add(SceneObjectPartProperties.AttachedPos); + } + ScheduleGroupForTerseUpdate(updatedProperties); } /// diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 9e8276e322..170c45a030 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -1288,7 +1288,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization WriteUUID(writer, "AttachedAvatar", sop.AttachedAvatar, options); WriteVector(writer, "AttachedPos", sop.AttachedPos); writer.WriteElementString("AttachmentPoint", sop.AttachmentPoint.ToString()); - writer.WriteElementString("IsAttachment", sop.IsAttachment.ToString().ToLower()); //IsAttachment is written last, so that on deserialization, it will be deserialized later than other Attachment properties + //writer.WriteElementString("IsAttachment", sop.IsAttachment.ToString().ToLower()); //IsAttachment is written last, so that on deserialization, it will be deserialized later than other Attachment properties WriteFlags(writer, "AggregateScriptEvents", sop.AggregateScriptEvents.ToString(), options); WriteBucketSyncInfo(writer, sop.BucketSyncInfoList); //end of SYMMETRIC SYNC From 10a41ad5b516ced043a1a0323e0bc2e24081e18f Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Fri, 18 Feb 2011 15:49:01 -0800 Subject: [PATCH 4/6] Added code in SceneGraph.AddSceneObjectByStateSynch to handle attachment objects. --- .../RegionSync/RegionSyncModule/RegionSyncAvatar.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncAvatar.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncAvatar.cs index 55b1f4b837..d5f243c8f6 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncAvatar.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncAvatar.cs @@ -601,7 +601,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule public void SendPrimUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags) { - m_log.Debug("[REGION SYNC AVATAR] SendPrimUpdate"); + //m_log.Debug("[REGION SYNC AVATAR] SendPrimUpdate"); } public virtual void AttachObject(uint localID, Quaternion rotation, byte attachPoint, UUID ownerID) diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 564461d315..c9a354374c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -2059,10 +2059,15 @@ namespace OpenSim.Region.Framework.Scenes } m_numPrim += children.Length; - //SYMMETRIC SYNC, sceneObject.AttachToScene(m_parentScene); - //sceneObject.AttachToSceneBySync(m_parentScene); - //end of SYMMETRIC SYNC, + + //Take some special care of the case of this object being an attachment + sceneObject.RootPart.SetAttachmentPoint(sceneObject.RootPart.AttachmentPoint); + if (sceneObject.IsAttachment) + { + ScenePresence avatar = m_parentScene.GetScenePresence(sceneObject.RootPart.AttachedAvatar); + sceneObject.RootPart.SetParentLocalId(avatar.LocalId); + } //SYMMETRIC SYNC, sceneObject.ScheduleGroupForFullUpdate_SyncInfoUnchanged(); From 1d2a25689a5a4f6d8dbdb327fa24d1a4d2785f84 Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Fri, 18 Feb 2011 16:08:12 -0800 Subject: [PATCH 5/6] RegionSyncServer and RegionSyncClient will not trigger RezAttachment anymore. Attachments are synced via object sync protocol. --- .../RegionSync/RegionSyncModule/RegionSyncClient.cs | 3 ++- .../RegionSync/RegionSyncModule/RegionSyncClientView.cs | 3 ++- OpenSim/Region/Framework/Scenes/Scene.cs | 9 ++++++--- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs index bc8e4bac76..5b2fb1f442 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClient.cs @@ -395,7 +395,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule RegionSyncAvatar av = new RegionSyncAvatar(m_scene, agentID, first, last, startPos); m_remoteAvatars.Add(agentID, av); - m_scene.AddNewClient(av); + //m_scene.AddNewClient(av); + m_scene.AddNewClient2(av, true, false); m_scene.TryGetScenePresence(agentID, out sp); if (sp == null) { diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientView.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientView.cs index 81f7166443..c9fc75c524 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientView.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/RegionSyncClientView.cs @@ -374,7 +374,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } m_syncedAvatars.Add(agentID, av); } - m_scene.AddNewClient(av); + //m_scene.AddNewClient(av); + m_scene.AddNewClient2(av, true, false); RegionSyncMessage.HandleSuccess(LogHeader, msg, String.Format("Handled AddAgent for UUID {0} at {1}", agentID, startPos.ToString())); return; } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index b9bc9c5ed5..33130e6b63 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3008,9 +3008,11 @@ namespace OpenSim.Region.Framework.Scenes /// public override void AddNewClient(IClientAPI client) { - AddNewClient2(client, true); + //AddNewClient2(client, true); + AddNewClient2(client, true, true); } - public void AddNewClient2(IClientAPI client, bool managed) + //public void AddNewClient2(IClientAPI client, bool managed) + public void AddNewClient2(IClientAPI client, bool managed, bool rezAttachment) { AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); @@ -3049,7 +3051,8 @@ namespace OpenSim.Region.Framework.Scenes if (aCircuit == null || (aCircuit != null && aCircuit.child == false)) { sp.IsChildAgent = false; - Util.FireAndForget(delegate(object o) { sp.RezAttachments(); }); + if(rezAttachment) + Util.FireAndForget(delegate(object o) { sp.RezAttachments(); }); } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index ace1df11e3..bb68000377 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1650,7 +1650,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - m_log.DebugFormat("[SOP]: physics actor is null for {0} with parent {1}", UUID, this.ParentGroup.UUID); + //m_log.DebugFormat("[SOP]: physics actor is null for {0} with parent {1}", UUID, this.ParentGroup.UUID); } } } From 513ca97eb038efea3dd7685a314b3f64e8770784 Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Fri, 18 Feb 2011 17:05:25 -0800 Subject: [PATCH 6/6] Added code to propogate event OnAttach. --- .../SymmetricSync/RegionSyncModule.cs | 45 ++++++++++++++++++- .../SymmetricSync/SymmetricSyncMessage.cs | 1 + .../Region/Framework/Scenes/EventManager.cs | 23 +++++++++- 3 files changed, 67 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index 5624abba2d..51fed7c2c8 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -692,6 +692,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule case EventManager.EventNames.ObjectDeGrab: OnLocalDeGrabObject((uint)evArgs[0], (uint)evArgs[1], (IClientAPI)evArgs[2], (SurfaceTouchEventArgs)evArgs[3]); return; + case EventManager.EventNames.Attach: + OnLocalAttach((uint)evArgs[0], (UUID)evArgs[1], (UUID)evArgs[2]); + return; default: return; } @@ -1431,6 +1434,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule case SymmetricSyncMessage.MsgType.ObjectGrab: case SymmetricSyncMessage.MsgType.ObjectGrabbing: case SymmetricSyncMessage.MsgType.ObjectDeGrab: + case SymmetricSyncMessage.MsgType.Attach: { HandleRemoteEvent(msg, senderActorID); return; @@ -1766,6 +1770,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule case SymmetricSyncMessage.MsgType.ObjectDeGrab: HandleRemoteEvent_OnObjectDeGrab(init_actorID, evSeqNum, data); break; + case SymmetricSyncMessage.MsgType.Attach: + HandleRemoteEvent_OnAttach(init_actorID, evSeqNum, data); + break; } //if this is a relay node, forwards the event @@ -2018,6 +2025,24 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_scene.EventManager.TriggerObjectDeGrabLocally(part.LocalId, originalID, remoteClinet, surfaceArgs); } + private void HandleRemoteEvent_OnAttach(string actorID, ulong evSeqNum, OSDMap data) + { + + UUID primID = data["primID"].AsUUID(); + UUID itemID = data["itemID"].AsUUID(); + UUID avatarID = data["avatarID"].AsUUID(); + + SceneObjectPart part = m_scene.GetSceneObjectPart(primID); + if (part == null) + { + m_log.Warn(LogHeader + ", HandleRemoteEvent_OnAttach: no part with UUID " + primID + " found"); + return; + } + + uint localID = part.LocalId; + m_scene.EventManager.TriggerOnAttachLocally(localID, itemID, avatarID); + + } /// /// The handler for (locally initiated) event OnNewScript: triggered by client's RezSript packet, publish it to other actors. @@ -2127,7 +2152,23 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule data["type"] = OSD.FromInteger((int)chat.Type); SendSceneEvent(SymmetricSyncMessage.MsgType.ChatFromWorld, data); } - + + private void OnLocalAttach(uint localID, UUID itemID, UUID avatarID) + { + + OSDMap data = new OSDMap(); + SceneObjectPart part = m_scene.GetSceneObjectPart(localID); + if (part == null) + { + m_log.Warn(LogHeader + ", OnLocalAttach: no part with localID: " + localID); + return; + } + data["primID"] = OSD.FromUUID(part.UUID); + data["itemID"] = OSD.FromUUID(itemID); + data["avatarID"] = OSD.FromUUID(avatarID); + SendSceneEvent(SymmetricSyncMessage.MsgType.Attach, data); + } + private void OnLocalGrabObject(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) { /* @@ -2239,6 +2280,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } + + 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 fe61355f20..522eb2d9a0 100755 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SymmetricSyncMessage.cs @@ -45,6 +45,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule ObjectGrab, ObjectGrabbing, ObjectDeGrab, + Attach, } #endregion diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index d5f5cc93d3..ba02ca258e 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -58,6 +58,7 @@ namespace OpenSim.Region.Framework.Scenes ObjectGrab, ObjectGrabbing, ObjectDeGrab, + Attach, //attaching object to avatar } @@ -238,6 +239,25 @@ namespace OpenSim.Region.Framework.Scenes base.TriggerObjectDeGrab(localID, originalID, remoteClient, surfaceArgs); } + + public override void TriggerOnAttach(uint localID, UUID itemID, UUID avatarID) + { + if (m_scene.RegionSyncModule != null) + { + Object[] eventArgs = new Object[4]; + eventArgs[0] = (Object)localID; + eventArgs[1] = (Object)itemID; + eventArgs[2] = (Object)avatarID; + m_scene.RegionSyncModule.PublishSceneEvent(EventNames.Attach, eventArgs); + } + TriggerOnAttachLocally(localID, itemID, avatarID); + } + + public void TriggerOnAttachLocally(uint localID, UUID itemID, UUID avatarID) + { + base.TriggerOnAttach(localID, itemID, avatarID); + } + #endregion //GrabObject } @@ -645,7 +665,8 @@ namespace OpenSim.Region.Framework.Scenes public event LandBuy OnLandBuy; public event LandBuy OnValidateLandBuy; - public void TriggerOnAttach(uint localID, UUID itemID, UUID avatarID) + //public void TriggerOnAttach(uint localID, UUID itemID, UUID avatarID) + public virtual void TriggerOnAttach(uint localID, UUID itemID, UUID avatarID) { Attach handlerOnAttach = OnAttach; if (handlerOnAttach != null)