diff options
author | UbitUmarov | 2016-09-24 22:21:51 +0100 |
---|---|---|
committer | UbitUmarov | 2016-09-24 22:21:51 +0100 |
commit | 6779f41e217ac2d401c3adf319ff307c46bc4dd3 (patch) | |
tree | 330773058b7015ed3c88358d84c28f4092afdc25 /OpenSim/Region/Framework/Scenes/SceneGraph.cs | |
parent | remove a redundant and potencially dangerous child.AbsolutePosition = child.A... (diff) | |
download | opensim-SC-6779f41e217ac2d401c3adf319ff307c46bc4dd3.zip opensim-SC-6779f41e217ac2d401c3adf319ff307c46bc4dd3.tar.gz opensim-SC-6779f41e217ac2d401c3adf319ff307c46bc4dd3.tar.bz2 opensim-SC-6779f41e217ac2d401c3adf319ff307c46bc4dd3.tar.xz |
fix linknumbers when unlink the root prim
Diffstat (limited to '')
-rwxr-xr-x | OpenSim/Region/Framework/Scenes/SceneGraph.cs | 116 |
1 files changed, 49 insertions, 67 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 8fc807a..238ec8e 100755 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -1913,31 +1913,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
1913 | // | 1913 | // |
1914 | foreach (SceneObjectPart part in prims) | 1914 | foreach (SceneObjectPart part in prims) |
1915 | { | 1915 | { |
1916 | if (part != null) | 1916 | if(part == null) |
1917 | continue; | ||
1918 | SceneObjectGroup parentSOG = part.ParentGroup; | ||
1919 | if(parentSOG == null || | ||
1920 | parentSOG.IsDeleted || | ||
1921 | parentSOG.inTransit || | ||
1922 | parentSOG.PrimCount == 1) | ||
1923 | continue; | ||
1924 | |||
1925 | if (!affectedGroups.Contains(parentSOG)) | ||
1917 | { | 1926 | { |
1918 | if (part.KeyframeMotion != null) | 1927 | affectedGroups.Add(parentSOG); |
1919 | { | 1928 | if(parentSOG.RootPart.PhysActor != null) |
1920 | part.KeyframeMotion.Stop(); | 1929 | parentSOG.RootPart.PhysActor.Building = true; |
1921 | part.KeyframeMotion = null; | 1930 | } |
1922 | } | ||
1923 | if (part.ParentGroup.PrimCount != 1) // Skip single | ||
1924 | { | ||
1925 | if (part.LinkNum < 2) // Root | ||
1926 | { | ||
1927 | rootParts.Add(part); | ||
1928 | } | ||
1929 | else | ||
1930 | { | ||
1931 | part.LastOwnerID = part.ParentGroup.RootPart.LastOwnerID; | ||
1932 | childParts.Add(part); | ||
1933 | } | ||
1934 | 1931 | ||
1935 | SceneObjectGroup group = part.ParentGroup; | 1932 | if (part.KeyframeMotion != null) |
1936 | if (!affectedGroups.Contains(group)) | 1933 | { |
1937 | { | 1934 | part.KeyframeMotion.Stop(); |
1938 | affectedGroups.Add(group); | 1935 | part.KeyframeMotion = null; |
1939 | } | 1936 | } |
1940 | } | 1937 | |
1938 | if (part.LinkNum < 2) // Root | ||
1939 | { | ||
1940 | rootParts.Add(part); | ||
1941 | } | ||
1942 | else | ||
1943 | { | ||
1944 | part.LastOwnerID = part.ParentGroup.RootPart.LastOwnerID; | ||
1945 | childParts.Add(part); | ||
1941 | } | 1946 | } |
1942 | } | 1947 | } |
1943 | 1948 | ||
@@ -1946,8 +1951,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1946 | foreach (SceneObjectPart child in childParts) | 1951 | foreach (SceneObjectPart child in childParts) |
1947 | { | 1952 | { |
1948 | // Unlink all child parts from their groups | 1953 | // Unlink all child parts from their groups |
1949 | // | ||
1950 | child.ParentGroup.DelinkFromGroup(child, true); | 1954 | child.ParentGroup.DelinkFromGroup(child, true); |
1955 | //child.ParentGroup is now other | ||
1951 | child.ParentGroup.HasGroupChanged = true; | 1956 | child.ParentGroup.HasGroupChanged = true; |
1952 | child.ParentGroup.ScheduleGroupForFullUpdate(); | 1957 | child.ParentGroup.ScheduleGroupForFullUpdate(); |
1953 | } | 1958 | } |
@@ -1960,74 +1965,51 @@ namespace OpenSim.Region.Framework.Scenes | |||
1960 | // However, editing linked parts and unlinking may be different | 1965 | // However, editing linked parts and unlinking may be different |
1961 | // | 1966 | // |
1962 | SceneObjectGroup group = root.ParentGroup; | 1967 | SceneObjectGroup group = root.ParentGroup; |
1963 | 1968 | ||
1964 | List<SceneObjectPart> newSet = new List<SceneObjectPart>(group.Parts); | 1969 | List<SceneObjectPart> newSet = new List<SceneObjectPart>(group.Parts); |
1965 | int numChildren = newSet.Count; | ||
1966 | 1970 | ||
1967 | if (numChildren == 1) | 1971 | newSet.Remove(root); |
1972 | int numChildren = newSet.Count; | ||
1973 | if(numChildren == 0) | ||
1968 | break; | 1974 | break; |
1969 | 1975 | ||
1970 | // If there are prims left in a link set, but the root is | ||
1971 | // slated for unlink, we need to do this | ||
1972 | // Unlink the remaining set | ||
1973 | // | ||
1974 | bool sendEventsToRemainder = false; | ||
1975 | if (numChildren == 2) // only one child prim no re-link needed | ||
1976 | sendEventsToRemainder = true; | ||
1977 | |||
1978 | foreach (SceneObjectPart p in newSet) | 1976 | foreach (SceneObjectPart p in newSet) |
1979 | { | 1977 | group.DelinkFromGroup(p, false); |
1980 | if (p != group.RootPart) | ||
1981 | { | ||
1982 | group.DelinkFromGroup(p, sendEventsToRemainder); | ||
1983 | if (sendEventsToRemainder) // finish single child prim now | ||
1984 | { | ||
1985 | p.ParentGroup.HasGroupChanged = true; | ||
1986 | p.ParentGroup.ScheduleGroupForFullUpdate(); | ||
1987 | } | ||
1988 | } | ||
1989 | } | ||
1990 | 1978 | ||
1979 | SceneObjectPart newRoot = newSet[0]; | ||
1980 | |||
1991 | // If there is more than one prim remaining, we | 1981 | // If there is more than one prim remaining, we |
1992 | // need to re-link | 1982 | // need to re-link |
1993 | // | 1983 | // |
1994 | if (numChildren > 2) | 1984 | if (numChildren > 1) |
1995 | { | 1985 | { |
1996 | // Remove old root | ||
1997 | // | ||
1998 | if (newSet.Contains(root)) | ||
1999 | newSet.Remove(root); | ||
2000 | |||
2001 | // Preserve link ordering | ||
2002 | // | ||
2003 | newSet.Sort(delegate (SceneObjectPart a, SceneObjectPart b) | ||
2004 | { | ||
2005 | return a.LinkNum.CompareTo(b.LinkNum); | ||
2006 | }); | ||
2007 | |||
2008 | // Determine new root | 1986 | // Determine new root |
2009 | // | 1987 | // |
2010 | SceneObjectPart newRoot = newSet[0]; | ||
2011 | newSet.RemoveAt(0); | 1988 | newSet.RemoveAt(0); |
2012 | 1989 | foreach (SceneObjectPart newChild in newSet) | |
2013 | foreach (SceneObjectPart newChild in newSet) | 1990 | newChild.ClearUpdateSchedule(); |
2014 | newChild.ClearUpdateSchedule(); | ||
2015 | 1991 | ||
2016 | LinkObjects(newRoot, newSet); | 1992 | LinkObjects(newRoot, newSet); |
2017 | // if (!affectedGroups.Contains(newRoot.ParentGroup)) | 1993 | } |
2018 | // affectedGroups.Add(newRoot.ParentGroup); | 1994 | else |
1995 | { | ||
1996 | newRoot.TriggerScriptChangedEvent(Changed.LINK); | ||
1997 | newRoot.ParentGroup.HasGroupChanged = true; | ||
1998 | newRoot.ParentGroup.ScheduleGroupForFullUpdate(); | ||
2019 | } | 1999 | } |
2020 | } | 2000 | } |
2021 | 2001 | ||
2022 | // Finally, trigger events in the roots | 2002 | // trigger events in the roots |
2023 | // | 2003 | // |
2024 | foreach (SceneObjectGroup g in affectedGroups) | 2004 | foreach (SceneObjectGroup g in affectedGroups) |
2025 | { | 2005 | { |
2006 | if(g.RootPart.PhysActor != null) | ||
2007 | g.RootPart.PhysActor.Building = false; | ||
2008 | g.AdjustChildPrimPermissions(false); | ||
2026 | // Child prims that have been unlinked and deleted will | 2009 | // Child prims that have been unlinked and deleted will |
2027 | // return unless the root is deleted. This will remove them | 2010 | // return unless the root is deleted. This will remove them |
2028 | // from the database. They will be rewritten immediately, | 2011 | // from the database. They will be rewritten immediately, |
2029 | // minus the rows for the unlinked child prims. | 2012 | // minus the rows for the unlinked child prims. |
2030 | g.AdjustChildPrimPermissions(false); | ||
2031 | m_parentScene.SimulationDataService.RemoveObject(g.UUID, m_parentScene.RegionInfo.RegionID); | 2013 | m_parentScene.SimulationDataService.RemoveObject(g.UUID, m_parentScene.RegionInfo.RegionID); |
2032 | g.TriggerScriptChangedEvent(Changed.LINK); | 2014 | g.TriggerScriptChangedEvent(Changed.LINK); |
2033 | g.HasGroupChanged = true; // Persist | 2015 | g.HasGroupChanged = true; // Persist |