From a0eddfcf61f89e9b8355a92fa8a5dd6e93dfe529 Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Wed, 19 Jan 2011 17:34:28 -0800 Subject: [PATCH] Added AddNewPart for synchronization of linked objects. --- OpenSim/Region/Framework/Scenes/Scene.cs | 9 +++++++++ OpenSim/Region/Framework/Scenes/SceneGraph.cs | 20 +++++++++++++++++++ .../Framework/Scenes/SceneObjectGroup.cs | 11 +++++++++- 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index f2fe7f7364..6c7aade51f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -709,6 +709,15 @@ namespace OpenSim.Region.Framework.Scenes } + public void AddNewSceneObjectPart(SceneObjectPart newPart, SceneObjectGroup parentGroup) + { + //assign a local ID. + newPart.LocalId = AllocateLocalId(); + //add it to SceneGraph's record. + m_sceneGraph.AddNewSceneObjectPart(newPart, parentGroup); + } + + #endregion //SYMMETRIC SYNC public ICapabilitiesModule CapsModule diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index f81fc17cf3..af789e78f1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -2027,6 +2027,26 @@ namespace OpenSim.Region.Framework.Scenes return true; } + public void AddNewSceneObjectPart(SceneObjectPart newPart, SceneObjectGroup parentGroup) + { + SceneObjectPart[] children = parentGroup.Parts; + + lock (SceneObjectGroupsByFullID) + { + SceneObjectGroupsByFullID[parentGroup.UUID] = parentGroup; + foreach (SceneObjectPart part in children) + SceneObjectGroupsByFullID[newPart.UUID] = parentGroup; + } + + lock (SceneObjectGroupsByLocalID) + { + SceneObjectGroupsByLocalID[parentGroup.LocalId] = parentGroup; + foreach (SceneObjectPart part in children) + SceneObjectGroupsByLocalID[newPart.LocalId] = parentGroup; + } + } + + #endregion //SYMMETRIC SYNC } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index ce518f6442..175b37567b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3546,7 +3546,8 @@ namespace OpenSim.Region.Framework.Scenes //Add in new parts foreach (SceneObjectPart newPart in newParts.Values) { - AddPart(newPart); + //AddPart(newPart); + AddNewPart(newPart); } //remove parts that are no longer in the group -- !!!!! need to further test how to do correct book-keeping and synchornized with other actors !!!!!!!! @@ -3637,6 +3638,14 @@ namespace OpenSim.Region.Framework.Scenes return groupUpdateResult; } + private void AddNewPart(SceneObjectPart newPart) + { + //set the parent relationship + AddPart(newPart); + + m_scene.AddNewSceneObjectPart(newPart, this); + } + public void ScheduleGroupForFullUpdate_SyncInfoUnchanged() { if (IsAttachment)