From c803ed28c3365c230d513837efc9ded8e8d1a4bd Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 5 Nov 2011 00:09:37 +0000 Subject: [PATCH] Replacing te linking code with the code from Avination. Link sets prims are now numbered properly even when sets are linked to sets. --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 +- .../Framework/Scenes/SceneObjectGroup.cs | 46 +++++-------------- 2 files changed, 12 insertions(+), 36 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index a137bca7e2..b2e5dc36e3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1669,7 +1669,7 @@ namespace OpenSim.Region.Framework.Scenes List childGroups = new List(); // We do this in reverse to get the link order of the prims correct - for (int i = children.Count - 1; i >= 0; i--) + for (int i = 0 ; i < children.Count ; i++) { SceneObjectGroup child = children[i].ParentGroup; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index ef2682f82d..4d6c4cb90e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1963,16 +1963,6 @@ namespace OpenSim.Region.Framework.Scenes /// The group of prims which should be linked to this group public void LinkToGroup(SceneObjectGroup objectGroup) { - // Make sure we have sent any pending unlinks or stuff. - //if (objectGroup.RootPart.UpdateFlag > 0) - //{ - // m_log.WarnFormat( - // "[SCENE OBJECT GROUP]: Forcing send of linkset {0}, {1} to {2}, {3} as its still waiting.", - // objectGroup.RootPart.Name, objectGroup.RootPart.UUID, RootPart.Name, RootPart.UUID); - - // objectGroup.RootPart.SendScheduledUpdates(); - //} - // m_log.DebugFormat( // "[SCENE OBJECT GROUP]: Linking group with root part {0}, {1} to group with root part {2}, {3}", // objectGroup.RootPart.Name, objectGroup.RootPart.UUID, RootPart.Name, RootPart.UUID); @@ -1983,6 +1973,7 @@ namespace OpenSim.Region.Framework.Scenes Quaternion oldRootRotation = linkPart.RotationOffset; linkPart.OffsetPosition = linkPart.GroupPosition - AbsolutePosition; + linkPart.ParentID = m_rootPart.LocalId; linkPart.GroupPosition = AbsolutePosition; Vector3 axPos = linkPart.OffsetPosition; @@ -1995,42 +1986,27 @@ namespace OpenSim.Region.Framework.Scenes linkPart.RotationOffset = newRot; linkPart.ParentID = m_rootPart.LocalId; + if (m_rootPart.LinkNum == 0) m_rootPart.LinkNum = 1; lock (m_parts.SyncRoot) { + int linkNum = PrimCount + 1; + m_parts.Add(linkPart.UUID, linkPart); - // Insert in terms of link numbers, the new links - // before the current ones (with the exception of - // the root prim. Shuffle the old ones up - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - { - SceneObjectPart part = parts[i]; - if (part.LinkNum != 1) - { - // Don't update root prim link number - part.LinkNum += objectGroup.PrimCount; - } - } - - linkPart.LinkNum = 2; - linkPart.SetParent(this); linkPart.CreateSelected = true; - //if (linkPart.PhysActor != null) - //{ - // m_scene.PhysicsScene.RemovePrim(linkPart.PhysActor); + linkPart.LinkNum = linkNum++; - //linkPart.PhysActor = null; - //} - - //TODO: rest of parts - int linkNum = 3; SceneObjectPart[] ogParts = objectGroup.Parts; + Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) + { + return a.LinkNum - b.LinkNum; + }); + for (int i = 0; i < ogParts.Length; i++) { SceneObjectPart part = ogParts[i]; @@ -2044,7 +2020,7 @@ namespace OpenSim.Region.Framework.Scenes objectGroup.IsDeleted = true; objectGroup.m_parts.Clear(); - + // Can't do this yet since backup still makes use of the root part without any synchronization // objectGroup.m_rootPart = null;