From 8ab4b277c1e1d5470a0322ec49dde665f3cceadc Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 7 Sep 2010 17:12:28 +0200 Subject: Fix some issues with unlinking --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 109 +++++++++++++------------- 1 file changed, 53 insertions(+), 56 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 905c683..a39f27a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1678,28 +1678,23 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectGroup group = part.ParentGroup; if (!affectedGroups.Contains(group)) + { + group.areUpdatesSuspended = true; affectedGroups.Add(group); + } } } } if (childParts.Count > 0) { - try + foreach (SceneObjectPart child in childParts) { - childParts[0].ParentGroup.areUpdatesSuspended = true; - foreach (SceneObjectPart child in childParts) - { - // Unlink all child parts from their groups - // - child.ParentGroup.DelinkFromGroup(child, true); - child.ParentGroup.HasGroupChanged = true; - child.ParentGroup.ScheduleGroupForFullUpdate(); - } - } - finally - { - childParts[0].ParentGroup.areUpdatesSuspended = false; + // Unlink all child parts from their groups + // + child.ParentGroup.DelinkFromGroup(child, true); + child.ParentGroup.HasGroupChanged = true; + child.ParentGroup.ScheduleGroupForFullUpdate(); } } @@ -1710,9 +1705,10 @@ namespace OpenSim.Region.Framework.Scenes // However, editing linked parts and unlinking may be different // SceneObjectGroup group = root.ParentGroup; + group.areUpdatesSuspended = true; List newSet = null; - int numChildren = -1; + int numChildren; lock (group.Children) { @@ -1720,63 +1716,63 @@ namespace OpenSim.Region.Framework.Scenes numChildren = group.PrimCount; } + if (numChildren == 1) + break; + // If there are prims left in a link set, but the root is // slated for unlink, we need to do this + // Unlink the remaining set // - if (numChildren != 1) - { - // Unlink the remaining set - // - bool sendEventsToRemainder = true; - if (numChildren > 1) - sendEventsToRemainder = false; + bool sendEventsToRemainder = true; + if (numChildren > 1) + sendEventsToRemainder = false; - if (newSet.Count > 0) + foreach (SceneObjectPart p in newSet) + { + if (p != group.RootPart) { - try + group.DelinkFromGroup(p, sendEventsToRemainder); + if (numChildren > 2) { - newSet[0].ParentGroup.areUpdatesSuspended = true; - foreach (SceneObjectPart p in newSet) - { - if (p != group.RootPart) - group.DelinkFromGroup(p, sendEventsToRemainder); - } + p.ParentGroup.areUpdatesSuspended = true; } - finally + else { - newSet[0].ParentGroup.areUpdatesSuspended = false; + p.ParentGroup.HasGroupChanged = true; + p.ParentGroup.ScheduleGroupForFullUpdate(); } } + } + + // If there is more than one prim remaining, we + // need to re-link + // + if (numChildren > 2) + { + // Remove old root + // + if (newSet.Contains(root)) + newSet.Remove(root); - // If there is more than one prim remaining, we - // need to re-link + // Preserve link ordering // - if (numChildren > 2) + newSet.Sort(delegate (SceneObjectPart a, SceneObjectPart b) { - // Remove old root - // - if (newSet.Contains(root)) - newSet.Remove(root); - - // Preserve link ordering - // - newSet.Sort(delegate (SceneObjectPart a, SceneObjectPart b) - { - return a.LinkNum.CompareTo(b.LinkNum); - }); + return a.LinkNum.CompareTo(b.LinkNum); + }); - // Determine new root - // - SceneObjectPart newRoot = newSet[0]; - newSet.RemoveAt(0); + // Determine new root + // + SceneObjectPart newRoot = newSet[0]; + newSet.RemoveAt(0); - foreach (SceneObjectPart newChild in newSet) - newChild.UpdateFlag = 0; + foreach (SceneObjectPart newChild in newSet) + newChild.UpdateFlag = 0; - LinkObjects(newRoot, newSet); - if (!affectedGroups.Contains(newRoot.ParentGroup)) - affectedGroups.Add(newRoot.ParentGroup); - } + newRoot.ParentGroup.areUpdatesSuspended = true; + LinkObjects(newRoot, newSet); + if (!affectedGroups.Contains(newRoot.ParentGroup)) + affectedGroups.Add(newRoot.ParentGroup); } } @@ -1786,6 +1782,7 @@ namespace OpenSim.Region.Framework.Scenes { g.TriggerScriptChangedEvent(Changed.LINK); g.HasGroupChanged = true; // Persist + g.areUpdatesSuspended = false; g.ScheduleGroupForFullUpdate(); } } -- cgit v1.1