aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
authorUbitUmarov2016-09-24 22:21:51 +0100
committerUbitUmarov2016-09-24 22:21:51 +0100
commit6779f41e217ac2d401c3adf319ff307c46bc4dd3 (patch)
tree330773058b7015ed3c88358d84c28f4092afdc25 /OpenSim/Region/Framework/Scenes
parentremove a redundant and potencially dangerous child.AbsolutePosition = child.A... (diff)
downloadopensim-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 'OpenSim/Region/Framework/Scenes')
-rwxr-xr-xOpenSim/Region/Framework/Scenes/SceneGraph.cs116
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs111
2 files changed, 157 insertions, 70 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
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 17dfb85..53a9441 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -3168,10 +3168,11 @@ namespace OpenSim.Region.Framework.Scenes
3168 if (insert) 3168 if (insert)
3169 { 3169 {
3170 linkNum = 2; 3170 linkNum = 2;
3171 int insertSize = objectGroup.PrimCount;
3171 foreach (SceneObjectPart part in Parts) 3172 foreach (SceneObjectPart part in Parts)
3172 { 3173 {
3173 if (part.LinkNum > 1) 3174 if (part.LinkNum > 1)
3174 part.LinkNum++; 3175 part.LinkNum += insertSize;
3175 } 3176 }
3176 } 3177 }
3177 else 3178 else
@@ -3200,14 +3201,14 @@ namespace OpenSim.Region.Framework.Scenes
3200 linkPart.LinkNum = linkNum++; 3201 linkPart.LinkNum = linkNum++;
3201 linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); 3202 linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false);
3202 3203
3203 // Get a list of the SOP's in the old group in order of their linknum's. 3204 // Get a list of the SOP's in the source group in order of their linknum's.
3204 SceneObjectPart[] ogParts = objectGroup.Parts; 3205 SceneObjectPart[] ogParts = objectGroup.Parts;
3205 Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) 3206 Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b)
3206 { 3207 {
3207 return a.LinkNum - b.LinkNum; 3208 return a.LinkNum - b.LinkNum;
3208 }); 3209 });
3209 3210
3210 // Add each of the SOP's from the old linkset to our linkset 3211 // Add each of the SOP's from the source linkset to our linkset
3211 for (int i = 0; i < ogParts.Length; i++) 3212 for (int i = 0; i < ogParts.Length; i++)
3212 { 3213 {
3213 SceneObjectPart part = ogParts[i]; 3214 SceneObjectPart part = ogParts[i];
@@ -3415,6 +3416,110 @@ namespace OpenSim.Region.Framework.Scenes
3415 return objectGroup; 3416 return objectGroup;
3416 } 3417 }
3417 3418
3419/* working on it
3420 public void DelinkFromGroup(List<SceneObjectPart> linkParts, bool sendEvents)
3421 {
3422// m_log.DebugFormat(
3423// "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}",
3424// linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID);
3425
3426 if(PrimCount == 1)
3427 return;
3428
3429 if (m_rootPart.PhysActor != null)
3430 m_rootPart.PhysActor.Building = true;
3431
3432 bool unlinkroot = false;
3433 foreach(SceneObjectPart linkPart in linkParts)
3434 {
3435 // first we only remove child parts
3436 if(linkPart.LocalId == m_rootPart.LocalId)
3437 {
3438 unlinkroot = true;
3439 continue;
3440 }
3441
3442 lock (m_parts.SyncRoot)
3443 if(!m_parts.Remove(linkPart.UUID))
3444 continue;
3445
3446 linkPart.ClearUndoState();
3447
3448 Vector3 worldPos = linkPart.GetWorldPosition();
3449 Quaternion worldRot = linkPart.GetWorldRotation();
3450
3451 linkPart.ParentID = 0;
3452 linkPart.LinkNum = 0;
3453
3454 PhysicsActor linkPartPa = linkPart.PhysActor;
3455
3456 // Remove the SOP from the physical scene.
3457 // If the new SOG is physical, it is re-created later.
3458 // (There is a problem here in that we have not yet told the physics
3459 // engine about the delink. Someday, linksets should be made first
3460 // class objects in the physics engine interface).
3461 if (linkPartPa != null)
3462 {
3463 m_scene.PhysicsScene.RemovePrim(linkPartPa);
3464 linkPart.PhysActor = null;
3465 }
3466
3467 linkPart.setGroupPosition(worldPos);
3468 linkPart.setOffsetPosition(Vector3.Zero);
3469 linkPart.setRotationOffset(worldRot);
3470
3471 // Create a new SOG to go around this unlinked and unattached SOP
3472 SceneObjectGroup objectGroup = new SceneObjectGroup(linkPart);
3473
3474 m_scene.AddNewSceneObject(objectGroup, true);
3475
3476 linkPart.Rezzed = RootPart.Rezzed;
3477
3478 // this is as it seems to be in sl now
3479 if(linkPart.PhysicsShapeType == (byte)PhysShapeType.none)
3480 linkPart.PhysicsShapeType = linkPart.DefaultPhysicsShapeType(); // root prims can't have type none for now
3481
3482 objectGroup.HasGroupChangedDueToDelink = true;
3483 if (sendEvents)
3484 linkPart.TriggerScriptChangedEvent(Changed.LINK);
3485 }
3486
3487 if(unlinkroot)
3488 {
3489 //TODO
3490 }
3491
3492 lock (m_parts.SyncRoot)
3493 {
3494 SceneObjectPart[] parts = m_parts.GetArray();
3495 if (parts.Length == 1)
3496 {
3497 // Single prim left
3498 m_rootPart.LinkNum = 0;
3499 }
3500 else
3501 {
3502 m_rootPart.LinkNum = 1;
3503 int linknum = 2;
3504 for (int i = 1; i < parts.Length; i++)
3505 parts[i].LinkNum = linknum++;
3506 }
3507 }
3508
3509 InvalidBoundsRadius();
3510
3511 if (m_rootPart.PhysActor != null)
3512 m_rootPart.PhysActor.Building = false;
3513
3514 // When we delete a group, we currently have to force persist to the database if the object id has changed
3515 // (since delete works by deleting all rows which have a given object id)
3516
3517 Scene.SimulationDataService.RemoveObject(UUID, Scene.RegionInfo.RegionID);
3518 HasGroupChangedDueToDelink = true;
3519 TriggerScriptChangedEvent(Changed.LINK);
3520 return;
3521 }
3522*/
3418 /// <summary> 3523 /// <summary>
3419 /// Stop this object from being persisted over server restarts. 3524 /// Stop this object from being persisted over server restarts.
3420 /// </summary> 3525 /// </summary>