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.cs796
1 files changed, 532 insertions, 264 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 6c47645..b1b76dd 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -209,25 +209,87 @@ namespace OpenSim.Region.Framework.Scenes
209 return true; 209 return true;
210 return false; 210 return false;
211 } 211 }
212 212
213 /// <value> 213 /// <summary>
214 /// Is this scene object acting as an attachment? 214 /// Is this scene object acting as an attachment?
215 /// 215 /// </summary>
216 /// We return false if the group has already been deleted. 216 public bool IsAttachment { get; set; }
217 /// 217
218 /// TODO: At the moment set must be done on the part itself. There may be a case for doing it here since I 218 /// <summary>
219 /// presume either all or no parts in a linkset can be part of an attachment (in which 219 /// The avatar to which this scene object is attached.
220 /// case the value would get proprogated down into all the descendent parts). 220 /// </summary>
221 /// </value> 221 /// <remarks>
222 public bool IsAttachment 222 /// If we're not attached to an avatar then this is UUID.Zero
223 /// </remarks>
224 public UUID AttachedAvatar { get; set; }
225
226 /// <summary>
227 /// Attachment point of this scene object to an avatar.
228 /// </summary>
229 /// <remarks>
230 /// 0 if we're not attached to anything
231 /// </remarks>
232 public uint AttachmentPoint
223 { 233 {
224 get 234 get
225 { 235 {
226 if (!IsDeleted) 236 return m_rootPart.Shape.State;
227 return m_rootPart.IsAttachment;
228
229 return false;
230 } 237 }
238
239 set
240 {
241 IsAttachment = value != 0;
242 m_rootPart.Shape.State = (byte)value;
243 }
244 }
245
246 public void ClearPartAttachmentData()
247 {
248 AttachmentPoint = 0;
249
250 // Even though we don't use child part state parameters for attachments any more, we still need to set
251 // these to zero since having them non-zero in rezzed scene objects will crash some clients. Even if
252 // we store them correctly, scene objects that we receive from elsewhere might not.
253 foreach (SceneObjectPart part in Parts)
254 part.Shape.State = 0;
255 }
256
257 /// <summary>
258 /// Is this scene object phantom?
259 /// </summary>
260 /// <remarks>
261 /// Updating must currently take place through UpdatePrimFlags()
262 /// </remarks>
263 public bool IsPhantom
264 {
265 get { return (RootPart.Flags & PrimFlags.Phantom) != 0; }
266 }
267
268 /// <summary>
269 /// Does this scene object use physics?
270 /// </summary>
271 /// <remarks>
272 /// Updating must currently take place through UpdatePrimFlags()
273 /// </remarks>
274 public bool UsesPhysics
275 {
276 get { return (RootPart.Flags & PrimFlags.TemporaryOnRez) != 0; }
277 }
278
279 /// <summary>
280 /// Is this scene object temporary?
281 /// </summary>
282 /// <remarks>
283 /// Updating must currently take place through UpdatePrimFlags()
284 /// </remarks>
285 public bool IsTemporary
286 {
287 get { return (RootPart.Flags & PrimFlags.TemporaryOnRez) != 0; }
288 }
289
290 public bool IsVolumeDetect
291 {
292 get { return RootPart.VolumeDetectActive; }
231 } 293 }
232 294
233 public float scriptScore; 295 public float scriptScore;
@@ -261,11 +323,7 @@ namespace OpenSim.Region.Framework.Scenes
261 /// </summary> 323 /// </summary>
262 public override string Name 324 public override string Name
263 { 325 {
264 get { 326 get { return RootPart.Name; }
265 if (RootPart == null)
266 return String.Empty;
267 return RootPart.Name;
268 }
269 set { RootPart.Name = value; } 327 set { RootPart.Name = value; }
270 } 328 }
271 329
@@ -305,6 +363,38 @@ namespace OpenSim.Region.Framework.Scenes
305 get { return m_rootPart.RotationOffset; } 363 get { return m_rootPart.RotationOffset; }
306 } 364 }
307 365
366 public Vector3 GroupScale
367 {
368 get
369 {
370 Vector3 minScale = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionSize);
371 Vector3 maxScale = Vector3.Zero;
372 Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f);
373
374 SceneObjectPart[] parts = m_parts.GetArray();
375 for (int i = 0; i < parts.Length; i++)
376 {
377 SceneObjectPart part = parts[i];
378 Vector3 partscale = part.Scale;
379 Vector3 partoffset = part.OffsetPosition;
380
381 minScale.X = (partscale.X + partoffset.X < minScale.X) ? partscale.X + partoffset.X : minScale.X;
382 minScale.Y = (partscale.Y + partoffset.Y < minScale.Y) ? partscale.Y + partoffset.Y : minScale.Y;
383 minScale.Z = (partscale.Z + partoffset.Z < minScale.Z) ? partscale.Z + partoffset.Z : minScale.Z;
384
385 maxScale.X = (partscale.X + partoffset.X > maxScale.X) ? partscale.X + partoffset.X : maxScale.X;
386 maxScale.Y = (partscale.Y + partoffset.Y > maxScale.Y) ? partscale.Y + partoffset.Y : maxScale.Y;
387 maxScale.Z = (partscale.Z + partoffset.Z > maxScale.Z) ? partscale.Z + partoffset.Z : maxScale.Z;
388 }
389
390 finalScale.X = (minScale.X > maxScale.X) ? minScale.X : maxScale.X;
391 finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y;
392 finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z;
393
394 return finalScale;
395 }
396 }
397
308 public UUID GroupID 398 public UUID GroupID
309 { 399 {
310 get { return m_rootPart.GroupID; } 400 get { return m_rootPart.GroupID; }
@@ -344,11 +434,13 @@ namespace OpenSim.Region.Framework.Scenes
344 /// <summary> 434 /// <summary>
345 /// Check both the attachment property and the relevant properties of the underlying root part. 435 /// Check both the attachment property and the relevant properties of the underlying root part.
346 /// </summary> 436 /// </summary>
437 /// <remarks>
347 /// This is necessary in some cases, particularly when a scene object has just crossed into a region and doesn't 438 /// This is necessary in some cases, particularly when a scene object has just crossed into a region and doesn't
348 /// have the IsAttachment property yet checked. 439 /// have the IsAttachment property yet checked.
349 /// 440 ///
350 /// FIXME: However, this should be fixed so that this property 441 /// FIXME: However, this should be fixed so that this property
351 /// propertly reflects the underlying status. 442 /// propertly reflects the underlying status.
443 /// </remarks>
352 /// <returns></returns> 444 /// <returns></returns>
353 public bool IsAttachmentCheckFull() 445 public bool IsAttachmentCheckFull()
354 { 446 {
@@ -682,7 +774,7 @@ namespace OpenSim.Region.Framework.Scenes
682 part.ParentID = m_rootPart.LocalId; 774 part.ParentID = m_rootPart.LocalId;
683 //m_log.DebugFormat("[SCENE]: Given local id {0} to part {1}, linknum {2}, parent {3} {4}", part.LocalId, part.UUID, part.LinkNum, part.ParentID, part.ParentUUID); 775 //m_log.DebugFormat("[SCENE]: Given local id {0} to part {1}, linknum {2}, parent {3} {4}", part.LocalId, part.UUID, part.LinkNum, part.ParentID, part.ParentUUID);
684 } 776 }
685 777
686 ApplyPhysics(m_scene.m_physicalPrim); 778 ApplyPhysics(m_scene.m_physicalPrim);
687 779
688 if (RootPart.PhysActor != null) 780 if (RootPart.PhysActor != null)
@@ -693,34 +785,6 @@ namespace OpenSim.Region.Framework.Scenes
693 //ScheduleGroupForFullUpdate(); 785 //ScheduleGroupForFullUpdate();
694 } 786 }
695 787
696 public Vector3 GroupScale()
697 {
698 Vector3 minScale = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionSize);
699 Vector3 maxScale = Vector3.Zero;
700 Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f);
701
702 SceneObjectPart[] parts = m_parts.GetArray();
703 for (int i = 0; i < parts.Length; i++)
704 {
705 SceneObjectPart part = parts[i];
706 Vector3 partscale = part.Scale;
707 Vector3 partoffset = part.OffsetPosition;
708
709 minScale.X = (partscale.X + partoffset.X < minScale.X) ? partscale.X + partoffset.X : minScale.X;
710 minScale.Y = (partscale.Y + partoffset.Y < minScale.Y) ? partscale.Y + partoffset.Y : minScale.Y;
711 minScale.Z = (partscale.Z + partoffset.Z < minScale.Z) ? partscale.Z + partoffset.Z : minScale.Z;
712
713 maxScale.X = (partscale.X + partoffset.X > maxScale.X) ? partscale.X + partoffset.X : maxScale.X;
714 maxScale.Y = (partscale.Y + partoffset.Y > maxScale.Y) ? partscale.Y + partoffset.Y : maxScale.Y;
715 maxScale.Z = (partscale.Z + partoffset.Z > maxScale.Z) ? partscale.Z + partoffset.Z : maxScale.Z;
716 }
717
718 finalScale.X = (minScale.X > maxScale.X) ? minScale.X : maxScale.X;
719 finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y;
720 finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z;
721 return finalScale;
722
723 }
724 public EntityIntersection TestIntersection(Ray hRay, bool frontFacesOnly, bool faceCenters) 788 public EntityIntersection TestIntersection(Ray hRay, bool frontFacesOnly, bool faceCenters)
725 { 789 {
726 // We got a request from the inner_scene to raytrace along the Ray hRay 790 // We got a request from the inner_scene to raytrace along the Ray hRay
@@ -1082,6 +1146,7 @@ namespace OpenSim.Region.Framework.Scenes
1082 } 1146 }
1083 } 1147 }
1084 1148
1149<<<<<<< HEAD
1085 /// <summary> 1150 /// <summary>
1086 /// Add the avatar to this linkset (avatar is sat). 1151 /// Add the avatar to this linkset (avatar is sat).
1087 /// </summary> 1152 /// </summary>
@@ -1263,6 +1328,8 @@ namespace OpenSim.Region.Framework.Scenes
1263 //m_rootPart.ScheduleFullUpdate(); 1328 //m_rootPart.ScheduleFullUpdate();
1264 } 1329 }
1265 1330
1331=======
1332>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
1266 /// <summary> 1333 /// <summary>
1267 /// 1334 ///
1268 /// </summary> 1335 /// </summary>
@@ -1320,11 +1387,16 @@ namespace OpenSim.Region.Framework.Scenes
1320 public void AddPart(SceneObjectPart part) 1387 public void AddPart(SceneObjectPart part)
1321 { 1388 {
1322 part.SetParent(this); 1389 part.SetParent(this);
1390<<<<<<< HEAD
1323 m_parts.Add(part.UUID, part); 1391 m_parts.Add(part.UUID, part);
1324 1392
1325 part.LinkNum = m_parts.Count; 1393 part.LinkNum = m_parts.Count;
1326 1394
1327 if (part.LinkNum == 2 && RootPart != null) 1395 if (part.LinkNum == 2 && RootPart != null)
1396=======
1397 part.LinkNum = m_parts.Add(part.UUID, part);
1398 if (part.LinkNum == 2)
1399>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
1328 RootPart.LinkNum = 1; 1400 RootPart.LinkNum = 1;
1329 } 1401 }
1330 1402
@@ -1407,7 +1479,15 @@ namespace OpenSim.Region.Framework.Scenes
1407 1479
1408 public virtual void OnGrabPart(SceneObjectPart part, Vector3 offsetPos, IClientAPI remoteClient) 1480 public virtual void OnGrabPart(SceneObjectPart part, Vector3 offsetPos, IClientAPI remoteClient)
1409 { 1481 {
1482<<<<<<< HEAD
1410 part.StoreUndoState(UndoType.STATE_PRIM_ALL); 1483 part.StoreUndoState(UndoType.STATE_PRIM_ALL);
1484=======
1485// m_log.DebugFormat(
1486// "[SCENE OBJECT GROUP]: Processing OnGrabPart for {0} on {1} {2}, offsetPos {3}",
1487// remoteClient.Name, part.Name, part.LocalId, offsetPos);
1488
1489 part.StoreUndoState();
1490>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
1411 part.OnGrab(offsetPos, remoteClient); 1491 part.OnGrab(offsetPos, remoteClient);
1412 } 1492 }
1413 1493
@@ -1711,16 +1791,30 @@ namespace OpenSim.Region.Framework.Scenes
1711 dupe.m_isBackedUp = false; 1791 dupe.m_isBackedUp = false;
1712 dupe.m_parts = new MapAndArray<OpenMetaverse.UUID, SceneObjectPart>(); 1792 dupe.m_parts = new MapAndArray<OpenMetaverse.UUID, SceneObjectPart>();
1713 1793
1794<<<<<<< HEAD
1714 // Warning, The following code related to previousAttachmentStatus is needed so that clones of 1795 // Warning, The following code related to previousAttachmentStatus is needed so that clones of
1715 // attachments do not bordercross while they're being duplicated. This is hacktastic! 1796 // attachments do not bordercross while they're being duplicated. This is hacktastic!
1716 // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! 1797 // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region!
1717 // unless IsAttachment is true!, so to prevent border crossing, we save it's attachment state 1798 // unless IsAttachment is true!, so to prevent border crossing, we save it's attachment state
1718 // (which should be false anyway) set it as an Attachment and then set it's Absolute Position, 1799 // (which should be false anyway) set it as an Attachment and then set it's Absolute Position,
1719 // then restore it's attachment state 1800 // then restore it's attachment state
1801=======
1802 bool previousAttachmentStatus = dupe.IsAttachment;
1803
1804 if (!userExposed)
1805 dupe.IsAttachment = true;
1806>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
1720 1807
1721 // This is only necessary when userExposed is false! 1808 // This is only necessary when userExposed is false!
1722 1809
1810<<<<<<< HEAD
1723 bool previousAttachmentStatus = dupe.RootPart.IsAttachment; 1811 bool previousAttachmentStatus = dupe.RootPart.IsAttachment;
1812=======
1813 if (!userExposed)
1814 {
1815 dupe.IsAttachment = previousAttachmentStatus;
1816 }
1817>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
1724 1818
1725 if (!userExposed) 1819 if (!userExposed)
1726 dupe.RootPart.IsAttachment = true; 1820 dupe.RootPart.IsAttachment = true;
@@ -1781,7 +1875,26 @@ namespace OpenSim.Region.Framework.Scenes
1781 dupe.HasGroupChanged = true; 1875 dupe.HasGroupChanged = true;
1782 dupe.AttachToBackup(); 1876 dupe.AttachToBackup();
1783 1877
1878<<<<<<< HEAD
1784 ScheduleGroupForFullUpdate(); 1879 ScheduleGroupForFullUpdate();
1880=======
1881 // Need to duplicate the physics actor as well
1882 if (part.PhysActor != null && userExposed)
1883 {
1884 PrimitiveBaseShape pbs = newPart.Shape;
1885
1886 newPart.PhysActor
1887 = m_scene.PhysicsScene.AddPrimShape(
1888 string.Format("{0}/{1}", newPart.Name, newPart.UUID),
1889 pbs,
1890 newPart.AbsolutePosition,
1891 newPart.Scale,
1892 newPart.RotationOffset,
1893 part.PhysActor.IsPhysical,
1894 newPart.LocalId);
1895
1896 newPart.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true);
1897>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
1785 } 1898 }
1786 } 1899 }
1787 finally 1900 finally
@@ -1802,36 +1915,24 @@ namespace OpenSim.Region.Framework.Scenes
1802 SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed)); 1915 SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed));
1803 } 1916 }
1804 1917
1805 public void ScriptSetPhysicsStatus(bool UsePhysics) 1918 public void ScriptSetPhysicsStatus(bool usePhysics)
1806 { 1919 {
1807 bool IsTemporary = ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0); 1920 UpdatePrimFlags(RootPart.LocalId, usePhysics, IsTemporary, IsPhantom, IsVolumeDetect);
1808 bool IsPhantom = ((RootPart.Flags & PrimFlags.Phantom) != 0);
1809 bool IsVolumeDetect = RootPart.VolumeDetectActive;
1810 UpdatePrimFlags(RootPart.LocalId, UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect);
1811 } 1921 }
1812 1922
1813 public void ScriptSetTemporaryStatus(bool TemporaryStatus) 1923 public void ScriptSetTemporaryStatus(bool makeTemporary)
1814 { 1924 {
1815 bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); 1925 UpdatePrimFlags(RootPart.LocalId, UsesPhysics, makeTemporary, IsPhantom, IsVolumeDetect);
1816 bool IsPhantom = ((RootPart.Flags & PrimFlags.Phantom) != 0);
1817 bool IsVolumeDetect = RootPart.VolumeDetectActive;
1818 UpdatePrimFlags(RootPart.LocalId, UsePhysics, TemporaryStatus, IsPhantom, IsVolumeDetect);
1819 } 1926 }
1820 1927
1821 public void ScriptSetPhantomStatus(bool PhantomStatus) 1928 public void ScriptSetPhantomStatus(bool makePhantom)
1822 { 1929 {
1823 bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); 1930 UpdatePrimFlags(RootPart.LocalId, UsesPhysics, IsTemporary, makePhantom, IsVolumeDetect);
1824 bool IsTemporary = ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0);
1825 bool IsVolumeDetect = RootPart.VolumeDetectActive;
1826 UpdatePrimFlags(RootPart.LocalId, UsePhysics, IsTemporary, PhantomStatus, IsVolumeDetect);
1827 } 1931 }
1828 1932
1829 public void ScriptSetVolumeDetect(bool VDStatus) 1933 public void ScriptSetVolumeDetect(bool makeVolumeDetect)
1830 { 1934 {
1831 bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); 1935 UpdatePrimFlags(RootPart.LocalId, UsesPhysics, IsTemporary, IsPhantom, makeVolumeDetect);
1832 bool IsTemporary = ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0);
1833 bool IsPhantom = ((RootPart.Flags & PrimFlags.Phantom) != 0);
1834 UpdatePrimFlags(RootPart.LocalId, UsePhysics, IsTemporary, IsPhantom, VDStatus);
1835 1936
1836 /* 1937 /*
1837 ScriptSetPhantomStatus(false); // What ever it was before, now it's not phantom anymore 1938 ScriptSetPhantomStatus(false); // What ever it was before, now it's not phantom anymore
@@ -1849,126 +1950,87 @@ namespace OpenSim.Region.Framework.Scenes
1849 1950
1850 public void applyImpulse(Vector3 impulse) 1951 public void applyImpulse(Vector3 impulse)
1851 { 1952 {
1852 // We check if rootpart is null here because scripts don't delete if you delete the host. 1953 if (IsAttachment)
1853 // This means that unfortunately, we can pass a null physics actor to Simulate!
1854 // Make sure we don't do that!
1855 SceneObjectPart rootpart = m_rootPart;
1856 if (rootpart != null)
1857 { 1954 {
1858 if (IsAttachment) 1955 ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar);
1956 if (avatar != null)
1859 { 1957 {
1860 ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); 1958 avatar.PushForce(impulse);
1861 if (avatar != null)
1862 {
1863 avatar.PushForce(impulse);
1864 }
1865 } 1959 }
1866 else 1960 }
1961 else
1962 {
1963 if (RootPart.PhysActor != null)
1867 { 1964 {
1868 if (rootpart.PhysActor != null) 1965 RootPart.PhysActor.AddForce(impulse, true);
1869 { 1966 m_scene.PhysicsScene.AddPhysicsActorTaint(RootPart.PhysActor);
1870 rootpart.PhysActor.AddForce(impulse, true);
1871 m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor);
1872 }
1873 } 1967 }
1874 } 1968 }
1875 } 1969 }
1876 1970
1877 public void applyAngularImpulse(Vector3 impulse) 1971 public void applyAngularImpulse(Vector3 impulse)
1878 { 1972 {
1879 // We check if rootpart is null here because scripts don't delete if you delete the host. 1973 if (RootPart.PhysActor != null)
1880 // This means that unfortunately, we can pass a null physics actor to Simulate!
1881 // Make sure we don't do that!
1882 SceneObjectPart rootpart = m_rootPart;
1883 if (rootpart != null)
1884 { 1974 {
1885 if (rootpart.PhysActor != null) 1975 if (!IsAttachment)
1886 { 1976 {
1887 if (!IsAttachment) 1977 RootPart.PhysActor.AddAngularForce(impulse, true);
1888 { 1978 m_scene.PhysicsScene.AddPhysicsActorTaint(RootPart.PhysActor);
1889 rootpart.PhysActor.AddAngularForce(impulse, true);
1890 m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor);
1891 }
1892 } 1979 }
1893 } 1980 }
1894 } 1981 }
1895 1982
1896 public void setAngularImpulse(Vector3 impulse) 1983 public void setAngularImpulse(Vector3 impulse)
1897 { 1984 {
1898 // We check if rootpart is null here because scripts don't delete if you delete the host. 1985 if (RootPart.PhysActor != null)
1899 // This means that unfortunately, we can pass a null physics actor to Simulate!
1900 // Make sure we don't do that!
1901 SceneObjectPart rootpart = m_rootPart;
1902 if (rootpart != null)
1903 { 1986 {
1904 if (rootpart.PhysActor != null) 1987 if (!IsAttachment)
1905 { 1988 {
1906 if (!IsAttachment) 1989 RootPart.PhysActor.Torque = impulse;
1907 { 1990 m_scene.PhysicsScene.AddPhysicsActorTaint(RootPart.PhysActor);
1908 rootpart.PhysActor.Torque = impulse;
1909 m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor);
1910 }
1911 } 1991 }
1912 } 1992 }
1913 } 1993 }
1914 1994
1915 public Vector3 GetTorque() 1995 public Vector3 GetTorque()
1916 { 1996 {
1917 // We check if rootpart is null here because scripts don't delete if you delete the host. 1997 if (RootPart.PhysActor != null)
1918 // This means that unfortunately, we can pass a null physics actor to Simulate!
1919 // Make sure we don't do that!
1920 SceneObjectPart rootpart = m_rootPart;
1921 if (rootpart != null)
1922 { 1998 {
1923 if (rootpart.PhysActor != null) 1999 if (!IsAttachment)
1924 { 2000 {
1925 if (!IsAttachment) 2001 Vector3 torque = RootPart.PhysActor.Torque;
1926 { 2002 return torque;
1927 Vector3 torque = rootpart.PhysActor.Torque;
1928 return torque;
1929 }
1930 } 2003 }
1931 } 2004 }
2005
1932 return Vector3.Zero; 2006 return Vector3.Zero;
1933 } 2007 }
1934 2008
1935 // This is used by both Double-Click Auto-Pilot and llMoveToTarget() in an attached object 2009 // This is used by both Double-Click Auto-Pilot and llMoveToTarget() in an attached object
1936 public void moveToTarget(Vector3 target, float tau) 2010 public void moveToTarget(Vector3 target, float tau)
1937 { 2011 {
1938 SceneObjectPart rootpart = m_rootPart; 2012 if (IsAttachment)
1939 if (rootpart != null)
1940 { 2013 {
1941 if (IsAttachment) 2014 ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar);
2015 if (avatar != null)
1942 { 2016 {
1943 ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); 2017 avatar.MoveToTarget(target, false);
1944 if (avatar != null)
1945 {
1946 List<string> coords = new List<string>();
1947 uint regionX = 0;
1948 uint regionY = 0;
1949 Utils.LongToUInts(Scene.RegionInfo.RegionHandle, out regionX, out regionY);
1950 target.X += regionX;
1951 target.Y += regionY;
1952 coords.Add(target.X.ToString());
1953 coords.Add(target.Y.ToString());
1954 coords.Add(target.Z.ToString());
1955 avatar.DoMoveToPosition(avatar, "", coords);
1956 }
1957 } 2018 }
1958 else 2019 }
2020 else
2021 {
2022 if (RootPart.PhysActor != null)
1959 { 2023 {
1960 if (rootpart.PhysActor != null) 2024 RootPart.PhysActor.PIDTarget = target;
1961 { 2025 RootPart.PhysActor.PIDTau = tau;
1962 rootpart.PhysActor.PIDTarget = target; 2026 RootPart.PhysActor.PIDActive = true;
1963 rootpart.PhysActor.PIDTau = tau;
1964 rootpart.PhysActor.PIDActive = true;
1965 }
1966 } 2027 }
1967 } 2028 }
1968 } 2029 }
1969 2030
1970 public void stopMoveToTarget() 2031 public void stopMoveToTarget()
1971 { 2032 {
2033<<<<<<< HEAD
1972 SceneObjectPart rootpart = m_rootPart; 2034 SceneObjectPart rootpart = m_rootPart;
1973 if (rootpart != null) 2035 if (rootpart != null)
1974 { 2036 {
@@ -1985,6 +2047,10 @@ namespace OpenSim.Region.Framework.Scenes
1985 } 2047 }
1986 } 2048 }
1987 } 2049 }
2050=======
2051 if (RootPart.PhysActor != null)
2052 RootPart.PhysActor.PIDActive = false;
2053>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
1988 } 2054 }
1989 2055
1990 public void rotLookAt(Quaternion target, float strength, float damping) 2056 public void rotLookAt(Quaternion target, float strength, float damping)
@@ -2016,6 +2082,7 @@ namespace OpenSim.Region.Framework.Scenes
2016 2082
2017 public void stopLookAt() 2083 public void stopLookAt()
2018 { 2084 {
2085<<<<<<< HEAD
2019 SceneObjectPart rootpart = m_rootPart; 2086 SceneObjectPart rootpart = m_rootPart;
2020 if (rootpart != null) 2087 if (rootpart != null)
2021 { 2088 {
@@ -2025,6 +2092,10 @@ namespace OpenSim.Region.Framework.Scenes
2025 } 2092 }
2026 } 2093 }
2027 2094
2095=======
2096 if (RootPart.PhysActor != null)
2097 RootPart.PhysActor.APIDActive = false;
2098>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
2028 } 2099 }
2029 2100
2030 /// <summary> 2101 /// <summary>
@@ -2035,22 +2106,18 @@ namespace OpenSim.Region.Framework.Scenes
2035 /// <param name="tau">Number of seconds over which to reach target</param> 2106 /// <param name="tau">Number of seconds over which to reach target</param>
2036 public void SetHoverHeight(float height, PIDHoverType hoverType, float tau) 2107 public void SetHoverHeight(float height, PIDHoverType hoverType, float tau)
2037 { 2108 {
2038 SceneObjectPart rootpart = m_rootPart; 2109 if (RootPart.PhysActor != null)
2039 if (rootpart != null)
2040 { 2110 {
2041 if (rootpart.PhysActor != null) 2111 if (height != 0f)
2042 { 2112 {
2043 if (height != 0f) 2113 RootPart.PhysActor.PIDHoverHeight = height;
2044 { 2114 RootPart.PhysActor.PIDHoverType = hoverType;
2045 rootpart.PhysActor.PIDHoverHeight = height; 2115 RootPart.PhysActor.PIDTau = tau;
2046 rootpart.PhysActor.PIDHoverType = hoverType; 2116 RootPart.PhysActor.PIDHoverActive = true;
2047 rootpart.PhysActor.PIDTau = tau; 2117 }
2048 rootpart.PhysActor.PIDHoverActive = true; 2118 else
2049 } 2119 {
2050 else 2120 RootPart.PhysActor.PIDHoverActive = false;
2051 {
2052 rootpart.PhysActor.PIDHoverActive = false;
2053 }
2054 } 2121 }
2055 } 2122 }
2056 } 2123 }
@@ -2145,7 +2212,7 @@ namespace OpenSim.Region.Framework.Scenes
2145 // an object has been deleted from a scene before update was processed. 2212 // an object has been deleted from a scene before update was processed.
2146 // A more fundamental overhaul of the update mechanism is required to eliminate all 2213 // A more fundamental overhaul of the update mechanism is required to eliminate all
2147 // the race conditions. 2214 // the race conditions.
2148 if (m_isDeleted) 2215 if (IsDeleted)
2149 return; 2216 return;
2150 2217
2151 // Even temporary objects take part in physics (e.g. temp-on-rez bullets) 2218 // Even temporary objects take part in physics (e.g. temp-on-rez bullets)
@@ -2458,7 +2525,7 @@ namespace OpenSim.Region.Framework.Scenes
2458 } 2525 }
2459 2526
2460 m_scene.UnlinkSceneObject(objectGroup, true); 2527 m_scene.UnlinkSceneObject(objectGroup, true);
2461 objectGroup.m_isDeleted = true; 2528 objectGroup.IsDeleted = true;
2462 2529
2463 objectGroup.m_parts.Clear(); 2530 objectGroup.m_parts.Clear();
2464 2531
@@ -2595,9 +2662,13 @@ namespace OpenSim.Region.Framework.Scenes
2595 /// <param name="objectGroup"></param> 2662 /// <param name="objectGroup"></param>
2596 public virtual void DetachFromBackup() 2663 public virtual void DetachFromBackup()
2597 { 2664 {
2665<<<<<<< HEAD
2598 m_scene.SceneGraph.FireDetachFromBackup(this); 2666 m_scene.SceneGraph.FireDetachFromBackup(this);
2599 2667
2600 if (m_isBackedUp) 2668 if (m_isBackedUp)
2669=======
2670 if (m_isBackedUp && Scene != null)
2671>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
2601 m_scene.EventManager.OnBackup -= ProcessBackup; 2672 m_scene.EventManager.OnBackup -= ProcessBackup;
2602 2673
2603 m_isBackedUp = false; 2674 m_isBackedUp = false;
@@ -2857,14 +2928,15 @@ namespace OpenSim.Region.Framework.Scenes
2857 /// Update prim flags for this group. 2928 /// Update prim flags for this group.
2858 /// </summary> 2929 /// </summary>
2859 /// <param name="localID"></param> 2930 /// <param name="localID"></param>
2860 /// <param name="type"></param> 2931 /// <param name="UsePhysics"></param>
2861 /// <param name="inUse"></param> 2932 /// <param name="SetTemporary"></param>
2862 /// <param name="data"></param> 2933 /// <param name="SetPhantom"></param>
2863 public void UpdatePrimFlags(uint localID, bool UsePhysics, bool IsTemporary, bool IsPhantom, bool IsVolumeDetect) 2934 /// <param name="SetVolumeDetect"></param>
2935 public void UpdatePrimFlags(uint localID, bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVolumeDetect)
2864 { 2936 {
2865 SceneObjectPart selectionPart = GetChildPart(localID); 2937 SceneObjectPart selectionPart = GetChildPart(localID);
2866 2938
2867 if (IsTemporary) 2939 if (SetTemporary && Scene != null)
2868 { 2940 {
2869 DetachFromBackup(); 2941 DetachFromBackup();
2870 // Remove from database and parcel prim count 2942 // Remove from database and parcel prim count
@@ -2876,24 +2948,32 @@ namespace OpenSim.Region.Framework.Scenes
2876 if (selectionPart != null) 2948 if (selectionPart != null)
2877 { 2949 {
2878 SceneObjectPart[] parts = m_parts.GetArray(); 2950 SceneObjectPart[] parts = m_parts.GetArray();
2879 for (int i = 0; i < parts.Length; i++) 2951
2952 if (Scene != null)
2880 { 2953 {
2881 SceneObjectPart part = parts[i]; 2954 for (int i = 0; i < parts.Length; i++)
2882 if (part.Scale.X > m_scene.RegionInfo.PhysPrimMax ||
2883 part.Scale.Y > m_scene.RegionInfo.PhysPrimMax ||
2884 part.Scale.Z > m_scene.RegionInfo.PhysPrimMax)
2885 { 2955 {
2886 UsePhysics = false; // Reset physics 2956 SceneObjectPart part = parts[i];
2887 break; 2957 if (part.Scale.X > m_scene.RegionInfo.PhysPrimMax ||
2958 part.Scale.Y > m_scene.RegionInfo.PhysPrimMax ||
2959 part.Scale.Z > m_scene.RegionInfo.PhysPrimMax)
2960 {
2961 UsePhysics = false; // Reset physics
2962 break;
2963 }
2888 } 2964 }
2889 } 2965 }
2890 2966
2891 RootPart.UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect); 2967 RootPart.UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect);
2892 for (int i = 0; i < parts.Length; i++) 2968 for (int i = 0; i < parts.Length; i++)
2969<<<<<<< HEAD
2893 { 2970 {
2894 if (parts[i] != RootPart) 2971 if (parts[i] != RootPart)
2895 parts[i].UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect); 2972 parts[i].UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect);
2896 } 2973 }
2974=======
2975 parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect);
2976>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
2897 } 2977 }
2898 } 2978 }
2899 2979
@@ -2966,12 +3046,12 @@ namespace OpenSim.Region.Framework.Scenes
2966 #region Resize 3046 #region Resize
2967 3047
2968 /// <summary> 3048 /// <summary>
2969 /// Resize the given part 3049 /// Resize the entire group of prims.
2970 /// </summary> 3050 /// </summary>
2971 /// <param name="scale"></param> 3051 /// <param name="scale"></param>
2972 /// <param name="localID"></param> 3052 public void GroupResize(Vector3 scale)
2973 public void Resize(Vector3 scale, uint localID)
2974 { 3053 {
3054<<<<<<< HEAD
2975 if (scale.X > m_scene.m_maxNonphys) 3055 if (scale.X > m_scene.m_maxNonphys)
2976 scale.X = m_scene.m_maxNonphys; 3056 scale.X = m_scene.m_maxNonphys;
2977 if (scale.Y > m_scene.m_maxNonphys) 3057 if (scale.Y > m_scene.m_maxNonphys)
@@ -2996,23 +3076,25 @@ namespace OpenSim.Region.Framework.Scenes
2996 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); 3076 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor);
2997 } 3077 }
2998 part.Resize(scale); 3078 part.Resize(scale);
3079=======
3080// m_log.DebugFormat(
3081// "[SCENE OBJECT GROUP]: Group resizing {0} {1} from {2} to {3}", Name, LocalId, RootPart.Scale, scale);
2999 3082
3000 HasGroupChanged = true; 3083 RootPart.StoreUndoState(true);
3001 part.TriggerScriptChangedEvent(Changed.SCALE); 3084>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
3002 ScheduleGroupForFullUpdate();
3003 3085
3004 //if (part.UUID == m_rootPart.UUID) 3086 scale.X = Math.Min(scale.X, Scene.m_maxNonphys);
3005 //{ 3087 scale.Y = Math.Min(scale.Y, Scene.m_maxNonphys);
3006 //if (m_rootPart.PhysActor != null) 3088 scale.Z = Math.Min(scale.Z, Scene.m_maxNonphys);
3007 //{ 3089
3008 //m_rootPart.PhysActor.Size = 3090 if (RootPart.PhysActor != null && RootPart.PhysActor.IsPhysical)
3009 //new PhysicsVector(m_rootPart.Scale.X, m_rootPart.Scale.Y, m_rootPart.Scale.Z); 3091 {
3010 //m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); 3092 scale.X = Math.Min(scale.X, Scene.m_maxPhys);
3011 //} 3093 scale.Y = Math.Min(scale.Y, Scene.m_maxPhys);
3012 //} 3094 scale.Z = Math.Min(scale.Z, Scene.m_maxPhys);
3013 } 3095 }
3014 }
3015 3096
3097<<<<<<< HEAD
3016 public void GroupResize(Vector3 scale, uint localID) 3098 public void GroupResize(Vector3 scale, uint localID)
3017 { 3099 {
3018 SceneObjectPart part = GetChildPart(localID); 3100 SceneObjectPart part = GetChildPart(localID);
@@ -3036,24 +3118,50 @@ namespace OpenSim.Region.Framework.Scenes
3036 float x = (scale.X / part.Scale.X); 3118 float x = (scale.X / part.Scale.X);
3037 float y = (scale.Y / part.Scale.Y); 3119 float y = (scale.Y / part.Scale.Y);
3038 float z = (scale.Z / part.Scale.Z); 3120 float z = (scale.Z / part.Scale.Z);
3121=======
3122 float x = (scale.X / RootPart.Scale.X);
3123 float y = (scale.Y / RootPart.Scale.Y);
3124 float z = (scale.Z / RootPart.Scale.Z);
3125>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
3039 3126
3040 SceneObjectPart[] parts; 3127 SceneObjectPart[] parts;
3041 if (x > 1.0f || y > 1.0f || z > 1.0f) 3128 if (x > 1.0f || y > 1.0f || z > 1.0f)
3129 {
3130 parts = m_parts.GetArray();
3131 for (int i = 0; i < parts.Length; i++)
3042 { 3132 {
3043 parts = m_parts.GetArray(); 3133 SceneObjectPart obPart = parts[i];
3044 for (int i = 0; i < parts.Length; i++) 3134 if (obPart.UUID != m_rootPart.UUID)
3045 { 3135 {
3046 SceneObjectPart obPart = parts[i]; 3136// obPart.IgnoreUndoUpdate = true;
3047 if (obPart.UUID != m_rootPart.UUID) 3137 Vector3 oldSize = new Vector3(obPart.Scale);
3138
3139 float f = 1.0f;
3140 float a = 1.0f;
3141
3142 if (RootPart.PhysActor != null && RootPart.PhysActor.IsPhysical)
3048 { 3143 {
3049 obPart.IgnoreUndoUpdate = true; 3144 if (oldSize.X * x > m_scene.m_maxPhys)
3050 Vector3 oldSize = new Vector3(obPart.Scale); 3145 {
3146 f = m_scene.m_maxPhys / oldSize.X;
3147 a = f / x;
3148 x *= a;
3149 y *= a;
3150 z *= a;
3151 }
3051 3152
3052 float f = 1.0f; 3153 if (oldSize.Y * y > m_scene.m_maxPhys)
3053 float a = 1.0f; 3154 {
3155 f = m_scene.m_maxPhys / oldSize.Y;
3156 a = f / y;
3157 x *= a;
3158 y *= a;
3159 z *= a;
3160 }
3054 3161
3055 if (part.PhysActor != null && part.PhysActor.IsPhysical) 3162 if (oldSize.Z * z > m_scene.m_maxPhys)
3056 { 3163 {
3164<<<<<<< HEAD
3057 if (oldSize.X*x > m_scene.m_maxPhys) 3165 if (oldSize.X*x > m_scene.m_maxPhys)
3058 { 3166 {
3059 f = m_scene.m_maxPhys / oldSize.X; 3167 f = m_scene.m_maxPhys / oldSize.X;
@@ -3078,9 +3186,20 @@ namespace OpenSim.Region.Framework.Scenes
3078 y *= a; 3186 y *= a;
3079 z *= a; 3187 z *= a;
3080 } 3188 }
3189=======
3190 f = m_scene.m_maxPhys / oldSize.Z;
3191 a = f / z;
3192 x *= a;
3193 y *= a;
3194 z *= a;
3195>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
3081 } 3196 }
3082 else 3197 }
3198 else
3199 {
3200 if (oldSize.X * x > m_scene.m_maxNonphys)
3083 { 3201 {
3202<<<<<<< HEAD
3084 if (oldSize.X*x > m_scene.m_maxNonphys) 3203 if (oldSize.X*x > m_scene.m_maxNonphys)
3085 { 3204 {
3086 f = m_scene.m_maxNonphys / oldSize.X; 3205 f = m_scene.m_maxNonphys / oldSize.X;
@@ -3107,10 +3226,40 @@ namespace OpenSim.Region.Framework.Scenes
3107 } 3226 }
3108 } 3227 }
3109 obPart.IgnoreUndoUpdate = false; 3228 obPart.IgnoreUndoUpdate = false;
3229=======
3230 f = m_scene.m_maxNonphys / oldSize.X;
3231 a = f / x;
3232 x *= a;
3233 y *= a;
3234 z *= a;
3235 }
3236
3237 if (oldSize.Y * y > m_scene.m_maxNonphys)
3238 {
3239 f = m_scene.m_maxNonphys / oldSize.Y;
3240 a = f / y;
3241 x *= a;
3242 y *= a;
3243 z *= a;
3244 }
3245
3246 if (oldSize.Z * z > m_scene.m_maxNonphys)
3247 {
3248 f = m_scene.m_maxNonphys / oldSize.Z;
3249 a = f / z;
3250 x *= a;
3251 y *= a;
3252 z *= a;
3253 }
3254>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
3110 } 3255 }
3256
3257// obPart.IgnoreUndoUpdate = false;
3111 } 3258 }
3112 } 3259 }
3260 }
3113 3261
3262<<<<<<< HEAD
3114 Vector3 prevScale = part.Scale; 3263 Vector3 prevScale = part.Scale;
3115 prevScale.X *= x; 3264 prevScale.X *= x;
3116 prevScale.Y *= y; 3265 prevScale.Y *= y;
@@ -3121,12 +3270,26 @@ namespace OpenSim.Region.Framework.Scenes
3121 part.IgnoreUndoUpdate = true; 3270 part.IgnoreUndoUpdate = true;
3122 part.Resize(prevScale); 3271 part.Resize(prevScale);
3123 part.IgnoreUndoUpdate = false; 3272 part.IgnoreUndoUpdate = false;
3273=======
3274 Vector3 prevScale = RootPart.Scale;
3275 prevScale.X *= x;
3276 prevScale.Y *= y;
3277 prevScale.Z *= z;
3278>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
3124 3279
3125 parts = m_parts.GetArray(); 3280// RootPart.IgnoreUndoUpdate = true;
3126 for (int i = 0; i < parts.Length; i++) 3281 RootPart.Resize(prevScale);
3282// RootPart.IgnoreUndoUpdate = false;
3283
3284 parts = m_parts.GetArray();
3285 for (int i = 0; i < parts.Length; i++)
3286 {
3287 SceneObjectPart obPart = parts[i];
3288
3289 if (obPart.UUID != m_rootPart.UUID)
3127 { 3290 {
3128 SceneObjectPart obPart = parts[i];
3129 obPart.IgnoreUndoUpdate = true; 3291 obPart.IgnoreUndoUpdate = true;
3292<<<<<<< HEAD
3130 if (obPart.UUID != m_rootPart.UUID) 3293 if (obPart.UUID != m_rootPart.UUID)
3131 { 3294 {
3132 if (obPart.UUID != m_rootPart.UUID) 3295 if (obPart.UUID != m_rootPart.UUID)
@@ -3150,18 +3313,38 @@ namespace OpenSim.Region.Framework.Scenes
3150 } 3313 }
3151 obPart.IgnoreUndoUpdate = false; 3314 obPart.IgnoreUndoUpdate = false;
3152 } 3315 }
3316=======
3317>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
3153 3318
3154 if (part.PhysActor != null) 3319 Vector3 currentpos = new Vector3(obPart.OffsetPosition);
3155 { 3320 currentpos.X *= x;
3156 part.PhysActor.Size = prevScale; 3321 currentpos.Y *= y;
3157 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); 3322 currentpos.Z *= z;
3323
3324 Vector3 newSize = new Vector3(obPart.Scale);
3325 newSize.X *= x;
3326 newSize.Y *= y;
3327 newSize.Z *= z;
3328
3329 obPart.Resize(newSize);
3330 obPart.UpdateOffSet(currentpos);
3331
3332 obPart.IgnoreUndoUpdate = false;
3158 } 3333 }
3159 3334
3335<<<<<<< HEAD
3160 part.IgnoreUndoUpdate = false; 3336 part.IgnoreUndoUpdate = false;
3161 HasGroupChanged = true; 3337 HasGroupChanged = true;
3162 m_rootPart.TriggerScriptChangedEvent(Changed.SCALE); 3338 m_rootPart.TriggerScriptChangedEvent(Changed.SCALE);
3163 ScheduleGroupForTerseUpdate(); 3339 ScheduleGroupForTerseUpdate();
3340=======
3341// obPart.IgnoreUndoUpdate = false;
3342// obPart.StoreUndoState();
3343>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
3164 } 3344 }
3345
3346// m_log.DebugFormat(
3347// "[SCENE OBJECT GROUP]: Finished group resizing {0} {1} to {2}", Name, LocalId, RootPart.Scale);
3165 } 3348 }
3166 3349
3167 #endregion 3350 #endregion
@@ -3174,6 +3357,17 @@ namespace OpenSim.Region.Framework.Scenes
3174 /// <param name="pos"></param> 3357 /// <param name="pos"></param>
3175 public void UpdateGroupPosition(Vector3 pos) 3358 public void UpdateGroupPosition(Vector3 pos)
3176 { 3359 {
3360<<<<<<< HEAD
3361=======
3362// m_log.DebugFormat("[SCENE OBJECT GROUP]: Updating group position on {0} {1} to {2}", Name, LocalId, pos);
3363
3364 RootPart.StoreUndoState(true);
3365
3366// SceneObjectPart[] parts = m_parts.GetArray();
3367// for (int i = 0; i < parts.Length; i++)
3368// parts[i].StoreUndoState();
3369
3370>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
3177 if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) 3371 if (m_scene.EventManager.TriggerGroupMove(UUID, pos))
3178 { 3372 {
3179 if (IsAttachment) 3373 if (IsAttachment)
@@ -3210,12 +3404,24 @@ namespace OpenSim.Region.Framework.Scenes
3210 { 3404 {
3211 SceneObjectPart part = GetChildPart(localID); 3405 SceneObjectPart part = GetChildPart(localID);
3212 3406
3407<<<<<<< HEAD
3213 SceneObjectPart[] parts = m_parts.GetArray(); 3408 SceneObjectPart[] parts = m_parts.GetArray();
3214 for (int i = 0; i < parts.Length; i++) 3409 for (int i = 0; i < parts.Length; i++)
3215 parts[i].StoreUndoState(UndoType.STATE_PRIM_POSITION); 3410 parts[i].StoreUndoState(UndoType.STATE_PRIM_POSITION);
3411=======
3412// SceneObjectPart[] parts = m_parts.GetArray();
3413// for (int i = 0; i < parts.Length; i++)
3414// parts[i].StoreUndoState();
3415>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
3216 3416
3217 if (part != null) 3417 if (part != null)
3218 { 3418 {
3419// m_log.DebugFormat(
3420// "[SCENE OBJECT GROUP]: Updating single position of {0} {1} to {2}", part.Name, part.LocalId, pos);
3421
3422 part.StoreUndoState(false);
3423 part.IgnoreUndoUpdate = true;
3424
3219 if (part.UUID == m_rootPart.UUID) 3425 if (part.UUID == m_rootPart.UUID)
3220 { 3426 {
3221 UpdateRootPosition(pos); 3427 UpdateRootPosition(pos);
@@ -3226,18 +3432,28 @@ namespace OpenSim.Region.Framework.Scenes
3226 } 3432 }
3227 3433
3228 HasGroupChanged = true; 3434 HasGroupChanged = true;
3435 part.IgnoreUndoUpdate = false;
3229 } 3436 }
3230 } 3437 }
3231 3438
3232 /// <summary> 3439 /// <summary>
3233 /// 3440 /// Update just the root prim position in a linkset
3234 /// </summary> 3441 /// </summary>
3235 /// <param name="pos"></param> 3442 /// <param name="pos"></param>
3236 private void UpdateRootPosition(Vector3 pos) 3443 public void UpdateRootPosition(Vector3 pos)
3237 { 3444 {
3445<<<<<<< HEAD
3238 SceneObjectPart[] parts = m_parts.GetArray(); 3446 SceneObjectPart[] parts = m_parts.GetArray();
3239 for (int i = 0; i < parts.Length; i++) 3447 for (int i = 0; i < parts.Length; i++)
3240 parts[i].StoreUndoState(UndoType.STATE_PRIM_POSITION); 3448 parts[i].StoreUndoState(UndoType.STATE_PRIM_POSITION);
3449=======
3450// m_log.DebugFormat(
3451// "[SCENE OBJECT GROUP]: Updating root position of {0} {1} to {2}", Name, LocalId, pos);
3452
3453// SceneObjectPart[] parts = m_parts.GetArray();
3454// for (int i = 0; i < parts.Length; i++)
3455// parts[i].StoreUndoState();
3456>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
3241 3457
3242 Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); 3458 Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z);
3243 Vector3 oldPos = 3459 Vector3 oldPos =
@@ -3250,7 +3466,7 @@ namespace OpenSim.Region.Framework.Scenes
3250 axDiff *= Quaternion.Inverse(partRotation); 3466 axDiff *= Quaternion.Inverse(partRotation);
3251 diff = axDiff; 3467 diff = axDiff;
3252 3468
3253 parts = m_parts.GetArray(); 3469 SceneObjectPart[] parts = m_parts.GetArray();
3254 for (int i = 0; i < parts.Length; i++) 3470 for (int i = 0; i < parts.Length; i++)
3255 { 3471 {
3256 SceneObjectPart obPart = parts[i]; 3472 SceneObjectPart obPart = parts[i];
@@ -3296,9 +3512,20 @@ namespace OpenSim.Region.Framework.Scenes
3296 /// <param name="rot"></param> 3512 /// <param name="rot"></param>
3297 public void UpdateGroupRotationR(Quaternion rot) 3513 public void UpdateGroupRotationR(Quaternion rot)
3298 { 3514 {
3515<<<<<<< HEAD
3299 SceneObjectPart[] parts = m_parts.GetArray(); 3516 SceneObjectPart[] parts = m_parts.GetArray();
3300 for (int i = 0; i < parts.Length; i++) 3517 for (int i = 0; i < parts.Length; i++)
3301 parts[i].StoreUndoState(UndoType.STATE_GROUP_ROTATION); 3518 parts[i].StoreUndoState(UndoType.STATE_GROUP_ROTATION);
3519=======
3520// m_log.DebugFormat(
3521// "[SCENE OBJECT GROUP]: Updating group rotation R of {0} {1} to {2}", Name, LocalId, rot);
3522
3523// SceneObjectPart[] parts = m_parts.GetArray();
3524// for (int i = 0; i < parts.Length; i++)
3525// parts[i].StoreUndoState();
3526
3527 m_rootPart.StoreUndoState(true);
3528>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
3302 3529
3303 m_rootPart.UpdateRotation(rot); 3530 m_rootPart.UpdateRotation(rot);
3304 3531
@@ -3320,9 +3547,21 @@ namespace OpenSim.Region.Framework.Scenes
3320 /// <param name="rot"></param> 3547 /// <param name="rot"></param>
3321 public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) 3548 public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot)
3322 { 3549 {
3550<<<<<<< HEAD
3323 SceneObjectPart[] parts = m_parts.GetArray(); 3551 SceneObjectPart[] parts = m_parts.GetArray();
3324 for (int i = 0; i < parts.Length; i++) 3552 for (int i = 0; i < parts.Length; i++)
3325 parts[i].StoreUndoState(UndoType.STATE_GROUP_ROTATION); 3553 parts[i].StoreUndoState(UndoType.STATE_GROUP_ROTATION);
3554=======
3555// m_log.DebugFormat(
3556// "[SCENE OBJECT GROUP]: Updating group rotation PR of {0} {1} to {2}", Name, LocalId, rot);
3557
3558// SceneObjectPart[] parts = m_parts.GetArray();
3559// for (int i = 0; i < parts.Length; i++)
3560// parts[i].StoreUndoState();
3561
3562 RootPart.StoreUndoState(true);
3563 RootPart.IgnoreUndoUpdate = true;
3564>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
3326 3565
3327 m_rootPart.UpdateRotation(rot); 3566 m_rootPart.UpdateRotation(rot);
3328 3567
@@ -3337,6 +3576,8 @@ namespace OpenSim.Region.Framework.Scenes
3337 3576
3338 HasGroupChanged = true; 3577 HasGroupChanged = true;
3339 ScheduleGroupForTerseUpdate(); 3578 ScheduleGroupForTerseUpdate();
3579
3580 RootPart.IgnoreUndoUpdate = false;
3340 } 3581 }
3341 3582
3342 /// <summary> 3583 /// <summary>
@@ -3353,6 +3594,9 @@ namespace OpenSim.Region.Framework.Scenes
3353 3594
3354 if (part != null) 3595 if (part != null)
3355 { 3596 {
3597// m_log.DebugFormat(
3598// "[SCENE OBJECT GROUP]: Updating single rotation of {0} {1} to {2}", part.Name, part.LocalId, rot);
3599
3356 if (part.UUID == m_rootPart.UUID) 3600 if (part.UUID == m_rootPart.UUID)
3357 { 3601 {
3358 UpdateRootRotation(rot); 3602 UpdateRootRotation(rot);
@@ -3374,6 +3618,13 @@ namespace OpenSim.Region.Framework.Scenes
3374 SceneObjectPart part = GetChildPart(localID); 3618 SceneObjectPart part = GetChildPart(localID);
3375 if (part != null) 3619 if (part != null)
3376 { 3620 {
3621// m_log.DebugFormat(
3622// "[SCENE OBJECT GROUP]: Updating single position and rotation of {0} {1} to {2}",
3623// part.Name, part.LocalId, rot);
3624
3625 part.StoreUndoState();
3626 part.IgnoreUndoUpdate = true;
3627
3377 if (part.UUID == m_rootPart.UUID) 3628 if (part.UUID == m_rootPart.UUID)
3378 { 3629 {
3379 UpdateRootRotation(rot); 3630 UpdateRootRotation(rot);
@@ -3390,12 +3641,19 @@ namespace OpenSim.Region.Framework.Scenes
3390 } 3641 }
3391 else 3642 else
3392 { 3643 {
3644<<<<<<< HEAD
3393 part.StoreUndoState(UndoType.STATE_PRIM_ROTATION); 3645 part.StoreUndoState(UndoType.STATE_PRIM_ROTATION);
3394 part.IgnoreUndoUpdate = true; 3646 part.IgnoreUndoUpdate = true;
3395 part.UpdateRotation(rot); 3647 part.UpdateRotation(rot);
3396 part.OffsetPosition = pos; 3648 part.OffsetPosition = pos;
3397 part.IgnoreUndoUpdate = false; 3649 part.IgnoreUndoUpdate = false;
3650=======
3651 part.UpdateRotation(rot);
3652 part.OffsetPosition = pos;
3653>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
3398 } 3654 }
3655
3656 part.IgnoreUndoUpdate = false;
3399 } 3657 }
3400 } 3658 }
3401 3659
@@ -3403,8 +3661,12 @@ namespace OpenSim.Region.Framework.Scenes
3403 /// 3661 ///
3404 /// </summary> 3662 /// </summary>
3405 /// <param name="rot"></param> 3663 /// <param name="rot"></param>
3406 private void UpdateRootRotation(Quaternion rot) 3664 public void UpdateRootRotation(Quaternion rot)
3407 { 3665 {
3666// m_log.DebugFormat(
3667// "[SCENE OBJECT GROUP]: Updating root rotation of {0} {1} to {2}",
3668// Name, LocalId, rot);
3669
3408 Quaternion axRot = rot; 3670 Quaternion axRot = rot;
3409 Quaternion oldParentRot = m_rootPart.RotationOffset; 3671 Quaternion oldParentRot = m_rootPart.RotationOffset;
3410 3672
@@ -3436,6 +3698,7 @@ namespace OpenSim.Region.Framework.Scenes
3436 axPos *= oldParentRot; 3698 axPos *= oldParentRot;
3437 axPos *= Quaternion.Inverse(axRot); 3699 axPos *= Quaternion.Inverse(axRot);
3438 prim.OffsetPosition = axPos; 3700 prim.OffsetPosition = axPos;
3701<<<<<<< HEAD
3439 3702
3440 prim.RotationOffset *= Quaternion.Inverse(prim.GetWorldRotation()) * (oldParentRot * prim.RotationOffset); 3703 prim.RotationOffset *= Quaternion.Inverse(prim.GetWorldRotation()) * (oldParentRot * prim.RotationOffset);
3441 3704
@@ -3448,6 +3711,32 @@ namespace OpenSim.Region.Framework.Scenes
3448 } 3711 }
3449 HasGroupChanged = true; 3712 HasGroupChanged = true;
3450 ScheduleGroupForFullUpdate(); 3713 ScheduleGroupForFullUpdate();
3714=======
3715 Quaternion primsRot = prim.RotationOffset;
3716 Quaternion newRot = primsRot * oldParentRot;
3717 newRot *= Quaternion.Inverse(axRot);
3718 prim.RotationOffset = newRot;
3719 prim.ScheduleTerseUpdate();
3720 prim.IgnoreUndoUpdate = false;
3721 }
3722 }
3723
3724// for (int i = 0; i < parts.Length; i++)
3725// {
3726// SceneObjectPart childpart = parts[i];
3727// if (childpart != m_rootPart)
3728// {
3729//// childpart.IgnoreUndoUpdate = false;
3730//// childpart.StoreUndoState();
3731// }
3732// }
3733
3734 m_rootPart.ScheduleTerseUpdate();
3735
3736// m_log.DebugFormat(
3737// "[SCENE OBJECT GROUP]: Updated root rotation of {0} {1} to {2}",
3738// Name, LocalId, rot);
3739>>>>>>> 9f75eaf50e42ef6409fc272ba33a817241907ed8
3451 } 3740 }
3452 3741
3453 #endregion 3742 #endregion
@@ -3462,28 +3751,23 @@ namespace OpenSim.Region.Framework.Scenes
3462 int yaxis = 4; 3751 int yaxis = 4;
3463 int zaxis = 8; 3752 int zaxis = 8;
3464 3753
3465 if (m_rootPart != null) 3754 setX = ((axis & xaxis) != 0) ? true : false;
3466 { 3755 setY = ((axis & yaxis) != 0) ? true : false;
3467 setX = ((axis & xaxis) != 0) ? true : false; 3756 setZ = ((axis & zaxis) != 0) ? true : false;
3468 setY = ((axis & yaxis) != 0) ? true : false;
3469 setZ = ((axis & zaxis) != 0) ? true : false;
3470 3757
3471 float setval = (rotate10 > 0) ? 1f : 0f; 3758 float setval = (rotate10 > 0) ? 1f : 0f;
3472 3759
3473 if (setX) 3760 if (setX)
3474 m_rootPart.RotationAxis.X = setval; 3761 RootPart.RotationAxis.X = setval;
3475 if (setY) 3762 if (setY)
3476 m_rootPart.RotationAxis.Y = setval; 3763 RootPart.RotationAxis.Y = setval;
3477 if (setZ) 3764 if (setZ)
3478 m_rootPart.RotationAxis.Z = setval; 3765 RootPart.RotationAxis.Z = setval;
3479 3766
3480 if (setX || setY || setZ) 3767 if (setX || setY || setZ)
3481 { 3768 RootPart.SetPhysicsAxisRotation();
3482 m_rootPart.SetPhysicsAxisRotation();
3483 }
3484
3485 }
3486 } 3769 }
3770
3487 public int registerRotTargetWaypoint(Quaternion target, float tolerance) 3771 public int registerRotTargetWaypoint(Quaternion target, float tolerance)
3488 { 3772 {
3489 scriptRotTarget waypoint = new scriptRotTarget(); 3773 scriptRotTarget waypoint = new scriptRotTarget();
@@ -3611,7 +3895,13 @@ namespace OpenSim.Region.Framework.Scenes
3611 foreach (uint idx in m_rotTargets.Keys) 3895 foreach (uint idx in m_rotTargets.Keys)
3612 { 3896 {
3613 scriptRotTarget target = m_rotTargets[idx]; 3897 scriptRotTarget target = m_rotTargets[idx];
3614 double angle = Math.Acos(target.targetRot.X * m_rootPart.RotationOffset.X + target.targetRot.Y * m_rootPart.RotationOffset.Y + target.targetRot.Z * m_rootPart.RotationOffset.Z + target.targetRot.W * m_rootPart.RotationOffset.W) * 2; 3898 double angle
3899 = Math.Acos(
3900 target.targetRot.X * m_rootPart.RotationOffset.X
3901 + target.targetRot.Y * m_rootPart.RotationOffset.Y
3902 + target.targetRot.Z * m_rootPart.RotationOffset.Z
3903 + target.targetRot.W * m_rootPart.RotationOffset.W)
3904 * 2;
3615 if (angle < 0) angle = -angle; 3905 if (angle < 0) angle = -angle;
3616 if (angle > Math.PI) angle = (Math.PI * 2 - angle); 3906 if (angle > Math.PI) angle = (Math.PI * 2 - angle);
3617 if (angle <= target.tolerance) 3907 if (angle <= target.tolerance)
@@ -3676,43 +3966,28 @@ namespace OpenSim.Region.Framework.Scenes
3676 3966
3677 return retmass; 3967 return retmass;
3678 } 3968 }
3679 3969
3970 /// <summary>
3971 /// If the object is a sculpt/mesh, retrieve the mesh data for each part and reinsert it into each shape so that
3972 /// the physics engine can use it.
3973 /// </summary>
3974 /// <remarks>
3975 /// When the physics engine has finished with it, the sculpt data is discarded to save memory.
3976 /// </remarks>
3680 public void CheckSculptAndLoad() 3977 public void CheckSculptAndLoad()
3681 { 3978 {
3682 if (IsDeleted) 3979 if (IsDeleted)
3683 return; 3980 return;
3981
3684 if ((RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.Phantom) != 0) 3982 if ((RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.Phantom) != 0)
3685 return; 3983 return;
3686 3984
3687 SceneObjectPart[] parts = m_parts.GetArray(); 3985// m_log.Debug("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId);
3688 for (int i = 0; i < parts.Length; i++)
3689 {
3690 SceneObjectPart part = parts[i];
3691 if (part.Shape.SculptEntry && part.Shape.SculptTexture != UUID.Zero)
3692 {
3693 // check if a previously decoded sculpt map has been cached
3694 if (File.Exists(System.IO.Path.Combine("j2kDecodeCache", "smap_" + part.Shape.SculptTexture.ToString())))
3695 {
3696 part.SculptTextureCallback(part.Shape.SculptTexture, null);
3697 }
3698 else
3699 {
3700 m_scene.AssetService.Get(
3701 part.Shape.SculptTexture.ToString(), part, AssetReceived);
3702 }
3703 }
3704 }
3705 }
3706 3986
3707 protected void AssetReceived(string id, Object sender, AssetBase asset) 3987 SceneObjectPart[] parts = m_parts.GetArray();
3708 {
3709 SceneObjectPart sop = (SceneObjectPart)sender;
3710 3988
3711 if (sop != null) 3989 for (int i = 0; i < parts.Length; i++)
3712 { 3990 parts[i].CheckSculptAndLoad();
3713 if (asset != null)
3714 sop.SculptTextureCallback(asset.FullID, asset);
3715 }
3716 } 3991 }
3717 3992
3718 /// <summary> 3993 /// <summary>
@@ -3747,19 +4022,12 @@ namespace OpenSim.Region.Framework.Scenes
3747 return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); 4022 return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition);
3748 } 4023 }
3749 4024
3750 public void SetAttachmentPoint(byte point)
3751 {
3752 SceneObjectPart[] parts = m_parts.GetArray();
3753 for (int i = 0; i < parts.Length; i++)
3754 parts[i].SetAttachmentPoint(point);
3755 }
3756
3757 #region ISceneObject 4025 #region ISceneObject
3758 4026
3759 public virtual ISceneObject CloneForNewScene() 4027 public virtual ISceneObject CloneForNewScene()
3760 { 4028 {
3761 SceneObjectGroup sog = Copy(false); 4029 SceneObjectGroup sog = Copy(false);
3762 sog.m_isDeleted = false; 4030 sog.IsDeleted = false;
3763 return sog; 4031 return sog;
3764 } 4032 }
3765 4033