From 854cb58d6d50fb343feb0176b5f66624f3f7a8b8 Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Wed, 4 May 2011 14:36:18 -0700 Subject: [PATCH] Revised SetSOPPropertyValue in RegionSyncModule.cs: added calling aggregateScriptEventSubscriptions() after SOP.AggregateScriptEvents is set. for properties AttachedAvatar and AttachmentPoint, do extra work besides copying the property values. Propogation of colission event and attachment (attached after avatar login) both working now. --- .../SymmetricSync/RegionSyncModule.cs | 90 +++++++++++++------ OpenSim/Region/Framework/Scenes/SceneGraph.cs | 11 ++- .../Framework/Scenes/SceneObjectPart.cs | 2 +- .../Serialization/SceneObjectSerializer.cs | 4 + 4 files changed, 74 insertions(+), 33 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index a504bc6e91..ea1e683f50 100644 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -1977,9 +1977,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { pos = part.PhysActor.Position; } - m_log.WarnFormat(" -- part {0}, UUID {1}, LocalID {2}, GroupPos {3}, offset-position {4}, Position {5}, AggregateScriptEvents ={6}, Flags = {7}, LocalFlags {8}", + m_log.WarnFormat("-- part {0}, UUID {1}, LocalID {2}, GroupPos {3}, offset-position {4}, Position {5}, AggregateScriptEvents ={6}, Flags = {7}, LocalFlags {8}, Scale {9}", part.Name, part.UUID, part.LocalId, part.GroupPosition, part.OffsetPosition, - pos, part.AggregateScriptEvents, part.Flags, part.LocalFlags); + pos, part.AggregateScriptEvents, part.Flags, part.LocalFlags, part.Scale); } } @@ -2003,26 +2003,51 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { if (entity is SceneObjectGroup) { - //Legacy serialization/deserialization for bucket based sync - /* - //first test serialization - StringWriter sw = new StringWriter(); - XmlTextWriter writer = new XmlTextWriter(sw); - Dictionary bucketSyncInfoList = new Dictionary(); - BucketSyncInfo generalBucket = new BucketSyncInfo(DateTime.Now.Ticks, m_actorID, "General"); - bucketSyncInfoList.Add("General", generalBucket); - BucketSyncInfo physicsBucket = new BucketSyncInfo(DateTime.Now.Ticks, m_actorID, "Physics"); - bucketSyncInfoList.Add("Physics", physicsBucket); - SceneObjectSerializer.WriteBucketSyncInfo(writer, bucketSyncInfoList); - string xmlString = sw.ToString(); - m_log.DebugFormat("Serialized xml string: {0}", xmlString); + SceneObjectGroup sog = (SceneObjectGroup)entity; - //second, test de-serialization - XmlTextReader reader = new XmlTextReader(new StringReader(xmlString)); - SceneObjectPart part = new SceneObjectPart(); - SceneObjectSerializer.ProcessBucketSyncInfo(part, reader); - * */ + string sogXml = sog.ToXml2(); + + SceneObjectGroup sogCopy = SceneXmlLoader.DeserializeGroupFromXml2(sogXml); + } + } + } + } + + //debug functions + private void BucketSyncDebug() + { + //Legacy serialization/deserialization for bucket based sync + /* + //first test serialization + StringWriter sw = new StringWriter(); + XmlTextWriter writer = new XmlTextWriter(sw); + Dictionary bucketSyncInfoList = new Dictionary(); + BucketSyncInfo generalBucket = new BucketSyncInfo(DateTime.Now.Ticks, m_actorID, "General"); + bucketSyncInfoList.Add("General", generalBucket); + BucketSyncInfo physicsBucket = new BucketSyncInfo(DateTime.Now.Ticks, m_actorID, "Physics"); + bucketSyncInfoList.Add("Physics", physicsBucket); + SceneObjectSerializer.WriteBucketSyncInfo(writer, bucketSyncInfoList); + + string xmlString = sw.ToString(); + m_log.DebugFormat("Serialized xml string: {0}", xmlString); + + //second, test de-serialization + XmlTextReader reader = new XmlTextReader(new StringReader(xmlString)); + SceneObjectPart part = new SceneObjectPart(); + SceneObjectSerializer.ProcessBucketSyncInfo(part, reader); + * */ + } + + private void PrimSyncSerializationDebug() + { + if (m_scene != null) + { + EntityBase[] entities = m_scene.GetEntities(); + foreach (EntityBase entity in entities) + { + if (entity is SceneObjectGroup) + { SceneObjectGroup sog = (SceneObjectGroup)entity; @@ -2032,7 +2057,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { m_primSyncInfoManager.InsertPrimSyncInfo(part, DateTime.Now.Ticks, m_syncID); } - + //Next test serialization OSDMap sogData = SceneObjectEncoder(sog); @@ -2050,7 +2075,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule UUID oldUUID = part.UUID; part.UUID = UUID.Random(); - PrimSyncInfo syncInfo = primsSyncInfo[oldUUID]; + PrimSyncInfo syncInfo = primsSyncInfo[oldUUID]; primsSyncInfo.Add(part.UUID, syncInfo); } @@ -2068,8 +2093,12 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule } } } + } + //end of debug functions + + //Start connections to each remote listener. //For now, there is only one remote listener. private bool StartSyncConnections() @@ -3664,7 +3693,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //Skip if the prim is on longer in the local Scene Graph if (prim == null) { - m_log.WarnFormat("{0}: in SyncOutPrimUpdates, prim {1} no longer in local SceneGraph", LogHeader, primUUID); + //m_log.WarnFormat("{0}: in SyncOutPrimUpdates, prim {1} no longer in local SceneGraph", LogHeader, primUUID); continue; } //Skip if the object group is being deleted @@ -3694,6 +3723,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //Sync the SOP data and cached property values in PrimSyncInfoManager again HashSet propertiesWithSyncInfoUpdated = m_primSyncInfoManager.UpdatePrimSyncInfoByLocal(sop, new List(updatedProperties)); + updatedProperties.UnionWith(propertiesWithSyncInfoUpdated); SendPrimPropertyUpdates(sop, updatedProperties); } } @@ -6658,7 +6688,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule /////////////////////// case SceneObjectPartSyncProperties.AggregateScriptEvents: part.AggregateScriptEvents = (scriptEvents)pSyncInfo.LastUpdateValue; - + part.aggregateScriptEventSubscriptions(); //DebugLog.DebugFormat("set {0} value to be {1}", property.ToString(), part.AggregateScriptEvents); break; @@ -6669,13 +6699,21 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule part.AngularVelocity = (Vector3)pSyncInfo.LastUpdateValue; break; case SceneObjectPartSyncProperties.AttachedAvatar: - part.AttachedAvatar = (UUID)pSyncInfo.LastUpdateValue; + //part.AttachedAvatar = (UUID)pSyncInfo.LastUpdateValue; + UUID attachedAvatar = (UUID)pSyncInfo.LastUpdateValue; + if (!part.AttachedAvatar.Equals(attachedAvatar)) + { + part.AttachedAvatar = attachedAvatar; + ScenePresence avatar = part.ParentGroup.Scene.GetScenePresence(attachedAvatar); + part.ParentGroup.RootPart.SetParentLocalId(avatar.LocalId); + } break; case SceneObjectPartSyncProperties.AttachedPos: part.AttachedPos = (Vector3)pSyncInfo.LastUpdateValue; break; case SceneObjectPartSyncProperties.AttachmentPoint: - part.AttachmentPoint = (uint)pSyncInfo.LastUpdateValue; + //part.AttachmentPoint = (uint)pSyncInfo.LastUpdateValue; + part.SetAttachmentPoint((uint)pSyncInfo.LastUpdateValue); break; case SceneObjectPartSyncProperties.BaseMask: part.BaseMask = (uint)pSyncInfo.LastUpdateValue; diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 70a63b9f19..8d1ae3a36c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -2167,7 +2167,9 @@ namespace OpenSim.Region.Framework.Scenes sceneObject.AttachToScene(m_parentScene); - //Take some special care of the case of this object being an attachment + //Take some special care of the case of this object being an attachment, + //since localID of attachedAvatar is different in different sync node's + //Scene copies. sceneObject.RootPart.SetAttachmentPoint(sceneObject.RootPart.AttachmentPoint); if (sceneObject.IsAttachment) { @@ -2175,13 +2177,10 @@ namespace OpenSim.Region.Framework.Scenes sceneObject.RootPart.SetParentLocalId(avatar.LocalId); } - //DSG SYNC, sceneObject.HasGroupChanged = true; //NewObject is sent via a specific sync message, not through updates; - //hence not passing any property list here in calling - //ScheduleGroupForFullUpdate(). - sceneObject.ScheduleGroupForFullUpdate(null); - //end of DSG SYNC, + //hence not passing any property list here + sceneObject.ScheduleGroupForFullUpdate(null); Entities.Add(sceneObject); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 081ea22343..ad470467b2 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -5641,7 +5641,7 @@ namespace OpenSim.Region.Framework.Scenes } // Do any subscriptions based on the AggregateScriptEvents - protected void aggregateScriptEventSubscriptions() + public void aggregateScriptEventSubscriptions() { if ( ((AggregateScriptEvents & scriptEvents.collision) != 0) || diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index b651720e8d..4abbf7d06d 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -346,6 +346,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization m_SOPXmlProcessors.Add("TextureAnimation", ProcessTextureAnimation); m_SOPXmlProcessors.Add("ParticleSystem", ProcessParticleSystem); + /* //DSG SYNC m_SOPXmlProcessors.Add("LocalFlags", ProcessLocalFlags); //m_SOPXmlProcessors.Add("LastUpdateTimeStamp", ProcessUpdateTimeStamp); @@ -358,6 +359,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization m_SOPXmlProcessors.Add("BucketSyncInfoList", ProcessBucketSyncInfo); //end of DSG SYNC + * */ #endregion @@ -1302,12 +1304,14 @@ namespace OpenSim.Region.Framework.Scenes.Serialization //DSG 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. + /* 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 DSG SYNC writer.WriteEndElement();