aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
diff options
context:
space:
mode:
authorMic Bowman2011-08-26 15:23:46 -0700
committerMic Bowman2011-08-26 15:23:46 -0700
commit23f10f1d22d5ecf542119e39503230994c521bf0 (patch)
tree2498e8cccf2ed398052dfa53e9a1faf6e998d039 /OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
parentMerge branch 'master' into bulletsim (diff)
parentrefactor: simplify SOP.AttachedAvatar into SOG.AttachedAvatar (diff)
downloadopensim-SC_OLD-23f10f1d22d5ecf542119e39503230994c521bf0.zip
opensim-SC_OLD-23f10f1d22d5ecf542119e39503230994c521bf0.tar.gz
opensim-SC_OLD-23f10f1d22d5ecf542119e39503230994c521bf0.tar.bz2
opensim-SC_OLD-23f10f1d22d5ecf542119e39503230994c521bf0.tar.xz
Merge branch 'master' into bulletsim
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs158
1 files changed, 67 insertions, 91 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index fe96152..fada688 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -147,15 +147,16 @@ namespace OpenSim.Region.Framework.Scenes
147 return false; 147 return false;
148 } 148 }
149 149
150 /// <value> 150 /// <summary>
151 /// Is this scene object acting as an attachment? 151 /// Is this scene object acting as an attachment?
152 /// 152 /// </summary>
153 /// <remarks>
153 /// We return false if the group has already been deleted. 154 /// We return false if the group has already been deleted.
154 /// 155 ///
155 /// TODO: At the moment set must be done on the part itself. There may be a case for doing it here since I 156 /// TODO: At the moment set must be done on the part itself. There may be a case for doing it here since I
156 /// presume either all or no parts in a linkset can be part of an attachment (in which 157 /// presume either all or no parts in a linkset can be part of an attachment (in which
157 /// case the value would get proprogated down into all the descendent parts). 158 /// case the value would get proprogated down into all the descendent parts).
158 /// </value> 159 /// </remarks>
159 public bool IsAttachment 160 public bool IsAttachment
160 { 161 {
161 get 162 get
@@ -167,6 +168,52 @@ namespace OpenSim.Region.Framework.Scenes
167 } 168 }
168 } 169 }
169 170
171 /// <summary>
172 /// The avatar to which this scene object is attached.
173 /// </summary>
174 /// <remarks>
175 /// If we're not attached to an avatar then this is UUID.Zero
176 /// </remarks>
177 public UUID AttachedAvatar { get; set; }
178
179 /// <summary>
180 /// Is this scene object phantom?
181 /// </summary>
182 /// <remarks>
183 /// Updating must currently take place through UpdatePrimFlags()
184 /// </remarks>
185 public bool IsPhantom
186 {
187 get { return (RootPart.Flags & PrimFlags.Phantom) != 0; }
188 }
189
190 /// <summary>
191 /// Does this scene object use physics?
192 /// </summary>
193 /// <remarks>
194 /// Updating must currently take place through UpdatePrimFlags()
195 /// </remarks>
196 public bool UsesPhysics
197 {
198 get { return (RootPart.Flags & PrimFlags.TemporaryOnRez) != 0; }
199 }
200
201 /// <summary>
202 /// Is this scene object temporary?
203 /// </summary>
204 /// <remarks>
205 /// Updating must currently take place through UpdatePrimFlags()
206 /// </remarks>
207 public bool IsTemporary
208 {
209 get { return (RootPart.Flags & PrimFlags.TemporaryOnRez) != 0; }
210 }
211
212 public bool IsVolumeDetect
213 {
214 get { return RootPart.VolumeDetectActive; }
215 }
216
170 public float scriptScore; 217 public float scriptScore;
171 218
172 private Vector3 lastPhysGroupPos; 219 private Vector3 lastPhysGroupPos;
@@ -940,68 +987,16 @@ namespace OpenSim.Region.Framework.Scenes
940 return m_rootPart.Shape.State; 987 return m_rootPart.Shape.State;
941 } 988 }
942 989
943 public void ClearPartAttachmentData() 990 public void SetAttachmentPoint(byte point)
944 {
945 SetAttachmentPoint((Byte)0);
946 }
947
948 public void DetachToGround()
949 { 991 {
950 ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.AttachedAvatar);
951 if (avatar == null)
952 return;
953
954 avatar.RemoveAttachment(this);
955
956 Vector3 detachedpos = new Vector3(127f,127f,127f);
957 if (avatar == null)
958 return;
959
960 detachedpos = avatar.AbsolutePosition;
961 RootPart.FromItemID = UUID.Zero;
962
963 AbsolutePosition = detachedpos;
964 m_rootPart.AttachedAvatar = UUID.Zero;
965
966 SceneObjectPart[] parts = m_parts.GetArray(); 992 SceneObjectPart[] parts = m_parts.GetArray();
967 for (int i = 0; i < parts.Length; i++) 993 for (int i = 0; i < parts.Length; i++)
968 parts[i].AttachedAvatar = UUID.Zero; 994 parts[i].SetAttachmentPoint(point);
969
970 m_rootPart.SetParentLocalId(0);
971 SetAttachmentPoint((byte)0);
972 m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_scene.m_physicalPrim);
973 HasGroupChanged = true;
974 RootPart.Rezzed = DateTime.Now;
975 RootPart.RemFlag(PrimFlags.TemporaryOnRez);
976 AttachToBackup();
977 m_scene.EventManager.TriggerParcelPrimCountTainted();
978 m_rootPart.ScheduleFullUpdate();
979 m_rootPart.ClearUndoState();
980 } 995 }
981 996
982 public void DetachToInventoryPrep() 997 public void ClearPartAttachmentData()
983 { 998 {
984 ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.AttachedAvatar); 999 SetAttachmentPoint((Byte)0);
985 //Vector3 detachedpos = new Vector3(127f, 127f, 127f);
986 if (avatar != null)
987 {
988 //detachedpos = avatar.AbsolutePosition;
989 avatar.RemoveAttachment(this);
990 }
991
992 m_rootPart.AttachedAvatar = UUID.Zero;
993
994 SceneObjectPart[] parts = m_parts.GetArray();
995 for (int i = 0; i < parts.Length; i++)
996 parts[i].AttachedAvatar = UUID.Zero;
997
998 m_rootPart.SetParentLocalId(0);
999 //m_rootPart.SetAttachmentPoint((byte)0);
1000 m_rootPart.IsAttachment = false;
1001 AbsolutePosition = m_rootPart.AttachedPos;
1002 //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim);
1003 //AttachToBackup();
1004 //m_rootPart.ScheduleFullUpdate();
1005 } 1000 }
1006 1001
1007 /// <summary> 1002 /// <summary>
@@ -1510,36 +1505,24 @@ namespace OpenSim.Region.Framework.Scenes
1510 SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed)); 1505 SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed));
1511 } 1506 }
1512 1507
1513 public void ScriptSetPhysicsStatus(bool UsePhysics) 1508 public void ScriptSetPhysicsStatus(bool usePhysics)
1514 { 1509 {
1515 bool IsTemporary = ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0); 1510 UpdatePrimFlags(RootPart.LocalId, usePhysics, IsTemporary, IsPhantom, IsVolumeDetect);
1516 bool IsPhantom = ((RootPart.Flags & PrimFlags.Phantom) != 0);
1517 bool IsVolumeDetect = RootPart.VolumeDetectActive;
1518 UpdatePrimFlags(RootPart.LocalId, UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect);
1519 } 1511 }
1520 1512
1521 public void ScriptSetTemporaryStatus(bool TemporaryStatus) 1513 public void ScriptSetTemporaryStatus(bool makeTemporary)
1522 { 1514 {
1523 bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); 1515 UpdatePrimFlags(RootPart.LocalId, UsesPhysics, makeTemporary, IsPhantom, IsVolumeDetect);
1524 bool IsPhantom = ((RootPart.Flags & PrimFlags.Phantom) != 0);
1525 bool IsVolumeDetect = RootPart.VolumeDetectActive;
1526 UpdatePrimFlags(RootPart.LocalId, UsePhysics, TemporaryStatus, IsPhantom, IsVolumeDetect);
1527 } 1516 }
1528 1517
1529 public void ScriptSetPhantomStatus(bool PhantomStatus) 1518 public void ScriptSetPhantomStatus(bool makePhantom)
1530 { 1519 {
1531 bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); 1520 UpdatePrimFlags(RootPart.LocalId, UsesPhysics, IsTemporary, makePhantom, IsVolumeDetect);
1532 bool IsTemporary = ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0);
1533 bool IsVolumeDetect = RootPart.VolumeDetectActive;
1534 UpdatePrimFlags(RootPart.LocalId, UsePhysics, IsTemporary, PhantomStatus, IsVolumeDetect);
1535 } 1521 }
1536 1522
1537 public void ScriptSetVolumeDetect(bool VDStatus) 1523 public void ScriptSetVolumeDetect(bool makeVolumeDetect)
1538 { 1524 {
1539 bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); 1525 UpdatePrimFlags(RootPart.LocalId, UsesPhysics, IsTemporary, IsPhantom, makeVolumeDetect);
1540 bool IsTemporary = ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0);
1541 bool IsPhantom = ((RootPart.Flags & PrimFlags.Phantom) != 0);
1542 UpdatePrimFlags(RootPart.LocalId, UsePhysics, IsTemporary, IsPhantom, VDStatus);
1543 1526
1544 /* 1527 /*
1545 ScriptSetPhantomStatus(false); // What ever it was before, now it's not phantom anymore 1528 ScriptSetPhantomStatus(false); // What ever it was before, now it's not phantom anymore
@@ -1565,7 +1548,7 @@ namespace OpenSim.Region.Framework.Scenes
1565 { 1548 {
1566 if (IsAttachment) 1549 if (IsAttachment)
1567 { 1550 {
1568 ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); 1551 ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar);
1569 if (avatar != null) 1552 if (avatar != null)
1570 { 1553 {
1571 avatar.PushForce(impulse); 1554 avatar.PushForce(impulse);
@@ -1647,7 +1630,7 @@ namespace OpenSim.Region.Framework.Scenes
1647 { 1630 {
1648 if (IsAttachment) 1631 if (IsAttachment)
1649 { 1632 {
1650 ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); 1633 ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar);
1651 if (avatar != null) 1634 if (avatar != null)
1652 { 1635 {
1653 avatar.MoveToTarget(target, false); 1636 avatar.MoveToTarget(target, false);
@@ -1806,7 +1789,7 @@ namespace OpenSim.Region.Framework.Scenes
1806 // an object has been deleted from a scene before update was processed. 1789 // an object has been deleted from a scene before update was processed.
1807 // A more fundamental overhaul of the update mechanism is required to eliminate all 1790 // A more fundamental overhaul of the update mechanism is required to eliminate all
1808 // the race conditions. 1791 // the race conditions.
1809 if (m_isDeleted) 1792 if (IsDeleted)
1810 return; 1793 return;
1811 1794
1812 // Even temporary objects take part in physics (e.g. temp-on-rez bullets) 1795 // Even temporary objects take part in physics (e.g. temp-on-rez bullets)
@@ -2116,7 +2099,7 @@ namespace OpenSim.Region.Framework.Scenes
2116 } 2099 }
2117 2100
2118 m_scene.UnlinkSceneObject(objectGroup, true); 2101 m_scene.UnlinkSceneObject(objectGroup, true);
2119 objectGroup.m_isDeleted = true; 2102 objectGroup.IsDeleted = true;
2120 2103
2121 objectGroup.m_parts.Clear(); 2104 objectGroup.m_parts.Clear();
2122 2105
@@ -3347,19 +3330,12 @@ namespace OpenSim.Region.Framework.Scenes
3347 return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); 3330 return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition);
3348 } 3331 }
3349 3332
3350 public void SetAttachmentPoint(byte point)
3351 {
3352 SceneObjectPart[] parts = m_parts.GetArray();
3353 for (int i = 0; i < parts.Length; i++)
3354 parts[i].SetAttachmentPoint(point);
3355 }
3356
3357 #region ISceneObject 3333 #region ISceneObject
3358 3334
3359 public virtual ISceneObject CloneForNewScene() 3335 public virtual ISceneObject CloneForNewScene()
3360 { 3336 {
3361 SceneObjectGroup sog = Copy(false); 3337 SceneObjectGroup sog = Copy(false);
3362 sog.m_isDeleted = false; 3338 sog.IsDeleted = false;
3363 return sog; 3339 return sog;
3364 } 3340 }
3365 3341