aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs166
1 files changed, 61 insertions, 105 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 35684e0..ea6aab0 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1245,7 +1245,7 @@ namespace OpenSim.Region.Framework.Scenes
1245 1245
1246 public void DetachToGround() 1246 public void DetachToGround()
1247 { 1247 {
1248 ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.AttachedAvatar); 1248 ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar);
1249 if (avatar == null) 1249 if (avatar == null)
1250 return; 1250 return;
1251 1251
@@ -1259,14 +1259,14 @@ namespace OpenSim.Region.Framework.Scenes
1259 RootPart.FromItemID = UUID.Zero; 1259 RootPart.FromItemID = UUID.Zero;
1260 1260
1261 AbsolutePosition = detachedpos; 1261 AbsolutePosition = detachedpos;
1262 m_rootPart.AttachedAvatar = UUID.Zero; 1262 AttachedAvatar = UUID.Zero;
1263 1263
1264 SceneObjectPart[] parts = m_parts.GetArray(); 1264 //SceneObjectPart[] parts = m_parts.GetArray();
1265 for (int i = 0; i < parts.Length; i++) 1265 //for (int i = 0; i < parts.Length; i++)
1266 parts[i].AttachedAvatar = UUID.Zero; 1266 // parts[i].AttachedAvatar = UUID.Zero;
1267 1267
1268 m_rootPart.SetParentLocalId(0); 1268 m_rootPart.SetParentLocalId(0);
1269 SetAttachmentPoint((byte)0); 1269 AttachmentPoint = (byte)0;
1270 m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_scene.m_physicalPrim); 1270 m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_scene.m_physicalPrim);
1271 HasGroupChanged = true; 1271 HasGroupChanged = true;
1272 RootPart.Rezzed = DateTime.Now; 1272 RootPart.Rezzed = DateTime.Now;
@@ -1279,7 +1279,7 @@ namespace OpenSim.Region.Framework.Scenes
1279 1279
1280 public void DetachToInventoryPrep() 1280 public void DetachToInventoryPrep()
1281 { 1281 {
1282 ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.AttachedAvatar); 1282 ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar);
1283 //Vector3 detachedpos = new Vector3(127f, 127f, 127f); 1283 //Vector3 detachedpos = new Vector3(127f, 127f, 127f);
1284 if (avatar != null) 1284 if (avatar != null)
1285 { 1285 {
@@ -1287,15 +1287,15 @@ namespace OpenSim.Region.Framework.Scenes
1287 avatar.RemoveAttachment(this); 1287 avatar.RemoveAttachment(this);
1288 } 1288 }
1289 1289
1290 m_rootPart.AttachedAvatar = UUID.Zero; 1290 AttachedAvatar = UUID.Zero;
1291 1291
1292 SceneObjectPart[] parts = m_parts.GetArray(); 1292 /*SceneObjectPart[] parts = m_parts.GetArray();
1293 for (int i = 0; i < parts.Length; i++) 1293 for (int i = 0; i < parts.Length; i++)
1294 parts[i].AttachedAvatar = UUID.Zero; 1294 parts[i].AttachedAvatar = UUID.Zero;*/
1295 1295
1296 m_rootPart.SetParentLocalId(0); 1296 m_rootPart.SetParentLocalId(0);
1297 //m_rootPart.SetAttachmentPoint((byte)0); 1297 //m_rootPart.SetAttachmentPoint((byte)0);
1298 m_rootPart.IsAttachment = false; 1298 IsAttachment = false;
1299 AbsolutePosition = m_rootPart.AttachedPos; 1299 AbsolutePosition = m_rootPart.AttachedPos;
1300 //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim); 1300 //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim);
1301 //AttachToBackup(); 1301 //AttachToBackup();
@@ -1471,7 +1471,7 @@ namespace OpenSim.Region.Framework.Scenes
1471 public void DeleteGroupFromScene(bool silent) 1471 public void DeleteGroupFromScene(bool silent)
1472 { 1472 {
1473 // We need to keep track of this state in case this group is still queued for backup. 1473 // We need to keep track of this state in case this group is still queued for backup.
1474 m_isDeleted = true; 1474 IsDeleted = true;
1475 1475
1476 DetachFromBackup(); 1476 DetachFromBackup();
1477 1477
@@ -1746,97 +1746,63 @@ namespace OpenSim.Region.Framework.Scenes
1746 /// <returns></returns> 1746 /// <returns></returns>
1747 public SceneObjectGroup Copy(bool userExposed) 1747 public SceneObjectGroup Copy(bool userExposed)
1748 { 1748 {
1749 SceneObjectGroup dupe; 1749 SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone();
1750 try 1750 dupe.m_isBackedUp = false;
1751 { 1751 dupe.m_parts = new MapAndArray<OpenMetaverse.UUID, SceneObjectPart>();
1752 m_dupeInProgress = true;
1753 dupe = (SceneObjectGroup)MemberwiseClone();
1754 dupe.m_isBackedUp = false;
1755 dupe.m_parts = new MapAndArray<OpenMetaverse.UUID, SceneObjectPart>();
1756 1752
1757 // Warning, The following code related to previousAttachmentStatus is needed so that clones of 1753 // Warning, The following code related to previousAttachmentStatus is needed so that clones of
1758 // attachments do not bordercross while they're being duplicated. This is hacktastic! 1754 // attachments do not bordercross while they're being duplicated. This is hacktastic!
1759 // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! 1755 // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region!
1760 // unless IsAttachment is true!, so to prevent border crossing, we save it's attachment state 1756 // unless IsAttachment is true!, so to prevent border crossing, we save it's attachment state
1761 // (which should be false anyway) set it as an Attachment and then set it's Absolute Position, 1757 // (which should be false anyway) set it as an Attachment and then set it's Absolute Position,
1762 // then restore it's attachment state 1758 // then restore it's attachment state
1763 1759
1764 // This is only necessary when userExposed is false! 1760 // This is only necessary when userExposed is false!
1765 1761
1766 bool previousAttachmentStatus = dupe.IsAttachment; 1762 bool previousAttachmentStatus = dupe.IsAttachment;
1767
1768 if (!userExposed)
1769 dupe.IsAttachment = true;
1770 1763
1771 if (!userExposed) 1764 if (!userExposed)
1772 dupe.RootPart.IsAttachment = true; 1765 dupe.IsAttachment = true;
1773 1766
1774 dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); 1767 dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z);
1775 if (!userExposed)
1776 {
1777 dupe.IsAttachment = previousAttachmentStatus;
1778 }
1779 1768
1780 if (!userExposed) 1769 if (!userExposed)
1781 { 1770 {
1782 dupe.RootPart.IsAttachment = previousAttachmentStatus; 1771 dupe.IsAttachment = previousAttachmentStatus;
1783 } 1772 }
1784 1773
1785 dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); 1774 dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed);
1786 dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; 1775 dupe.m_rootPart.LinkNum = m_rootPart.LinkNum;
1787 1776
1788 if (userExposed) 1777 if (userExposed)
1789 dupe.m_rootPart.TrimPermissions(); 1778 dupe.m_rootPart.TrimPermissions();
1790 1779
1791 List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.GetArray()); 1780 List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.GetArray());
1792 1781
1793 partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) 1782 partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2)
1794 { 1783 {
1795 return p1.LinkNum.CompareTo(p2.LinkNum); 1784 return p1.LinkNum.CompareTo(p2.LinkNum);
1796 } 1785 }
1797 ); 1786 );
1798 1787
1799 foreach (SceneObjectPart part in partList) 1788 foreach (SceneObjectPart part in partList)
1789 {
1790 SceneObjectPart newPart;
1791 if (part.UUID != m_rootPart.UUID)
1800 { 1792 {
1801 if (part.UUID != m_rootPart.UUID) 1793 newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed);
1802 { 1794 newPart.LinkNum = part.LinkNum;
1803 SceneObjectPart newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed);
1804
1805 newPart.LinkNum = part.LinkNum;
1806 }
1807
1808 // Need to duplicate the physics actor as well
1809 if (part.PhysActor != null && userExposed)
1810 {
1811 PrimitiveBaseShape pbs = part.Shape;
1812
1813 part.PhysActor
1814 = m_scene.PhysicsScene.AddPrimShape(
1815 string.Format("{0}/{1}", part.Name, part.UUID),
1816 pbs,
1817 part.AbsolutePosition,
1818 part.Scale,
1819 part.RotationOffset,
1820 part.PhysActor.IsPhysical,
1821 m_localId);
1822 part.PhysActor.SetMaterial((int)part.Material);
1823
1824 part.PhysActor.LocalID = part.LocalId;
1825 part.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true);
1826 }
1827 } 1795 }
1828 if (userExposed) 1796 else
1829 { 1797 {
1830 dupe.UpdateParentIDs(); 1798 newPart = dupe.m_rootPart;
1831 dupe.HasGroupChanged = true;
1832 dupe.AttachToBackup();
1833 } 1799 }
1834 ScheduleGroupForFullUpdate(); 1800
1835 // Need to duplicate the physics actor as well 1801 // Need to duplicate the physics actor as well
1836 if (part.PhysActor != null && userExposed) 1802 if (part.PhysActor != null && userExposed)
1837 { 1803 {
1838 PrimitiveBaseShape pbs = newPart.Shape; 1804 PrimitiveBaseShape pbs = newPart.Shape;
1839 1805
1840 newPart.PhysActor 1806 newPart.PhysActor
1841 = m_scene.PhysicsScene.AddPrimShape( 1807 = m_scene.PhysicsScene.AddPrimShape(
1842 string.Format("{0}/{1}", newPart.Name, newPart.UUID), 1808 string.Format("{0}/{1}", newPart.Name, newPart.UUID),
@@ -1846,14 +1812,20 @@ namespace OpenSim.Region.Framework.Scenes
1846 newPart.RotationOffset, 1812 newPart.RotationOffset,
1847 part.PhysActor.IsPhysical, 1813 part.PhysActor.IsPhysical,
1848 newPart.LocalId); 1814 newPart.LocalId);
1849 1815
1850 newPart.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true); 1816 newPart.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true);
1851 } 1817 }
1852 } 1818 }
1853 finally 1819
1820 if (userExposed)
1854 { 1821 {
1855 m_dupeInProgress = false; 1822 dupe.UpdateParentIDs();
1823 dupe.HasGroupChanged = true;
1824 dupe.AttachToBackup();
1825
1826 ScheduleGroupForFullUpdate();
1856 } 1827 }
1828
1857 return dupe; 1829 return dupe;
1858 } 1830 }
1859 1831
@@ -1983,22 +1955,8 @@ namespace OpenSim.Region.Framework.Scenes
1983 1955
1984 public void stopMoveToTarget() 1956 public void stopMoveToTarget()
1985 { 1957 {
1986 SceneObjectPart rootpart = m_rootPart; 1958 if (RootPart.PhysActor != null)
1987 if (rootpart != null) 1959 RootPart.PhysActor.PIDActive = false;
1988 {
1989 if (IsAttachment)
1990 {
1991 ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar);
1992 if (avatar != null) avatar.StopMoveToPosition();
1993 }
1994 else
1995 {
1996 if (rootpart.PhysActor != null)
1997 {
1998 rootpart.PhysActor.PIDActive = false;
1999 }
2000 }
2001 }
2002 } 1960 }
2003 1961
2004 public void rotLookAt(Quaternion target, float strength, float damping) 1962 public void rotLookAt(Quaternion target, float strength, float damping)
@@ -3087,8 +3045,6 @@ namespace OpenSim.Region.Framework.Scenes
3087 prevScale.X *= x; 3045 prevScale.X *= x;
3088 prevScale.Y *= y; 3046 prevScale.Y *= y;
3089 prevScale.Z *= z; 3047 prevScale.Z *= z;
3090 part.IgnoreUndoUpdate = false;
3091
3092// RootPart.IgnoreUndoUpdate = true; 3048// RootPart.IgnoreUndoUpdate = true;
3093 RootPart.Resize(prevScale); 3049 RootPart.Resize(prevScale);
3094// RootPart.IgnoreUndoUpdate = false; 3050// RootPart.IgnoreUndoUpdate = false;