From 1a06045c981bae6fa982d0dcafcf311f78ce47fc Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Tue, 28 Oct 2008 11:26:23 +0000 Subject: From: Christopher Yeoh The attached patch fixes the bug where when linking in a new set of prims to an already linked set of objects the prims were placed at the end of the list rather than just after the root prim. ie. link prim order result was different on OpenSim compared to an LL server. This causes a few issues with respect to compatibility of scripts, especially when using llCreateLink. --- OpenSim/Region/Environment/Scenes/InnerScene.cs | 3 +- .../Region/Environment/Scenes/SceneObjectGroup.cs | 67 +++++++++++++--------- 2 files changed, 41 insertions(+), 29 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index 34224a7..295569e 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs @@ -1373,7 +1373,8 @@ namespace OpenSim.Region.Environment.Scenes List children = new List(); if (parenPrim != null) { - for (int i = 0; i < childPrims.Count; i++) + // We do this in reverse to get the link order of the prims correct + for (int i = childPrims.Count - 1; i >= 0; i--) { foreach (EntityBase ent in EntityList) { diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 02098b7..32c9255 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -1830,29 +1830,42 @@ namespace OpenSim.Region.Environment.Scenes lock (m_parts) { m_parts.Add(linkPart.UUID, linkPart); - } - - linkPart.LinkNum = m_parts.Count; - - linkPart.SetParent(this); - linkPart.AddFlag(PrimFlags.CreateSelected); - - //if (linkPart.PhysActor != null) - //{ - // m_scene.PhysicsScene.RemovePrim(linkPart.PhysActor); - //linkPart.PhysActor = null; - //} - - //TODO: rest of parts - foreach (SceneObjectPart part in objectGroup.Children.Values) - { - if (part.UUID != objectGroup.m_rootPart.UUID) - { - LinkNonRootPart(part, oldGroupPosition, oldRootRotation); - } - part.ClearUndoState(); - } + // 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 + foreach (KeyValuePair kvp in m_parts) + { + if (kvp.Value.LinkNum != 1) { + // Don't update root prim link number + kvp.Value.LinkNum += objectGroup.PrimCount; + } + } + + + linkPart.LinkNum = 2; + + linkPart.SetParent(this); + linkPart.AddFlag(PrimFlags.CreateSelected); + + //if (linkPart.PhysActor != null) + //{ + // m_scene.PhysicsScene.RemovePrim(linkPart.PhysActor); + + //linkPart.PhysActor = null; + //} + + //TODO: rest of parts + int linkNum = 3; + foreach (SceneObjectPart part in objectGroup.Children.Values) + { + if (part.UUID != objectGroup.m_rootPart.UUID) + { + LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++); + } + part.ClearUndoState(); + } + } m_scene.UnlinkSceneObject(objectGroup.UUID, true); objectGroup.Children.Clear(); @@ -1961,17 +1974,15 @@ namespace OpenSim.Region.Environment.Scenes m_isBackedUp = false; } - private void LinkNonRootPart(SceneObjectPart part, Vector3 oldGroupPosition, Quaternion oldGroupRotation) + private void LinkNonRootPart(SceneObjectPart part, Vector3 oldGroupPosition, Quaternion oldGroupRotation, int linkNum) { part.SetParent(this); part.ParentID = m_rootPart.LocalId; - lock (m_parts) - { - m_parts.Add(part.UUID, part); - } + // Caller locks m_parts for us + m_parts.Add(part.UUID, part); - part.LinkNum = m_parts.Count; + part.LinkNum = linkNum; Vector3 oldPos = part.OffsetPosition; oldPos *= oldGroupRotation; -- cgit v1.1