From ce8419fdd0d3384a9df037d9df1b5d7d8960d1d8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 2 Nov 2011 23:42:09 +0100 Subject: Fix link order when linking sets to sets --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 8 +++- .../Region/Framework/Scenes/SceneObjectGroup.cs | 50 +++++----------------- 2 files changed, 18 insertions(+), 40 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index a6178e7..0f5e99d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1752,7 +1752,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; @@ -1784,6 +1784,12 @@ namespace OpenSim.Region.Framework.Scenes } finally { + lock (SceneObjectGroupsByLocalPartID) + { + foreach (SceneObjectPart part in parentGroup.Parts) + SceneObjectGroupsByLocalPartID[part.LocalId] = parentGroup; + } + parentGroup.areUpdatesSuspended = false; parentGroup.HasGroupChanged = true; parentGroup.ProcessBackup(m_parentScene.SimulationDataService, true); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 8b71f5b..3a863e7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2351,16 +2351,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); @@ -2384,45 +2374,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) { - 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; - } - } - } + int linkNum = PrimCount + 1; - linkPart.LinkNum = 2; + m_parts.Add(linkPart.UUID, linkPart); - linkPart.SetParent(this); - linkPart.CreateSelected = true; + linkPart.SetParent(this); + linkPart.CreateSelected = true; - lock (m_parts.SyncRoot) - { - //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]; -- cgit v1.1