diff options
author | Justin Clark-Casey (justincc) | 2011-08-26 22:49:11 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-08-26 22:49:11 +0100 |
commit | 5f3ffc195f60ac54492ccb389843f292b0be7511 (patch) | |
tree | 37ac2512d76923f91e9f4715bee3dd8cbca7d0a1 /OpenSim/Region | |
parent | refactor: simplify DetachSingleAttachmentToGround() by retrieving the scene o... (diff) | |
download | opensim-SC-5f3ffc195f60ac54492ccb389843f292b0be7511.zip opensim-SC-5f3ffc195f60ac54492ccb389843f292b0be7511.tar.gz opensim-SC-5f3ffc195f60ac54492ccb389843f292b0be7511.tar.bz2 opensim-SC-5f3ffc195f60ac54492ccb389843f292b0be7511.tar.xz |
refactor: move SOG.DetachToGround() to AttachmentsModule.DetachSceneObjectToGround() and remove redundant code
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 30 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 46 |
2 files changed, 35 insertions, 41 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 42a18c5..93920b0 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -472,7 +472,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
472 | if (changed && m_scene.AvatarFactory != null) | 472 | if (changed && m_scene.AvatarFactory != null) |
473 | m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); | 473 | m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); |
474 | 474 | ||
475 | so.DetachToGround(); | 475 | presence.RemoveAttachment(so); |
476 | DetachSceneObjectToGround(so, presence); | ||
476 | 477 | ||
477 | List<UUID> uuids = new List<UUID>(); | 478 | List<UUID> uuids = new List<UUID>(); |
478 | uuids.Add(inventoryID); | 479 | uuids.Add(inventoryID); |
@@ -482,6 +483,33 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
482 | 483 | ||
483 | m_scene.EventManager.TriggerOnAttach(so.LocalId, sceneObjectID, UUID.Zero); | 484 | m_scene.EventManager.TriggerOnAttach(so.LocalId, sceneObjectID, UUID.Zero); |
484 | } | 485 | } |
486 | |||
487 | /// <summary> | ||
488 | /// Detach the given scene objet to the ground. | ||
489 | /// </summary> | ||
490 | /// <remarks> | ||
491 | /// The caller has to take care of all the other work in updating avatar appearance, inventory, etc. | ||
492 | /// </remarks> | ||
493 | /// <param name="so">The scene object to detach.</param> | ||
494 | /// <param name="sp">The scene presence from which the scene object is being detached.</param> | ||
495 | private void DetachSceneObjectToGround(SceneObjectGroup so, ScenePresence sp) | ||
496 | { | ||
497 | SceneObjectPart rootPart = so.RootPart; | ||
498 | |||
499 | rootPart.FromItemID = UUID.Zero; | ||
500 | so.AbsolutePosition = sp.AbsolutePosition; | ||
501 | so.ForEachPart(part => part.AttachedAvatar = UUID.Zero); | ||
502 | rootPart.SetParentLocalId(0); | ||
503 | so.ClearPartAttachmentData(); | ||
504 | rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive, m_scene.m_physicalPrim); | ||
505 | so.HasGroupChanged = true; | ||
506 | rootPart.Rezzed = DateTime.Now; | ||
507 | rootPart.RemFlag(PrimFlags.TemporaryOnRez); | ||
508 | so.AttachToBackup(); | ||
509 | m_scene.EventManager.TriggerParcelPrimCountTainted(); | ||
510 | rootPart.ScheduleFullUpdate(); | ||
511 | rootPart.ClearUndoState(); | ||
512 | } | ||
485 | 513 | ||
486 | // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. | 514 | // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. |
487 | // To LocalId or UUID, *THAT* is the question. How now Brown UUID?? | 515 | // To LocalId or UUID, *THAT* is the question. How now Brown UUID?? |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 00e3363..e3b8fc8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -979,43 +979,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
979 | return m_rootPart.Shape.State; | 979 | return m_rootPart.Shape.State; |
980 | } | 980 | } |
981 | 981 | ||
982 | public void ClearPartAttachmentData() | 982 | public void SetAttachmentPoint(byte point) |
983 | { | ||
984 | SetAttachmentPoint((Byte)0); | ||
985 | } | ||
986 | |||
987 | public void DetachToGround() | ||
988 | { | 983 | { |
989 | ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.AttachedAvatar); | ||
990 | if (avatar == null) | ||
991 | return; | ||
992 | |||
993 | avatar.RemoveAttachment(this); | ||
994 | |||
995 | Vector3 detachedpos = new Vector3(127f,127f,127f); | ||
996 | if (avatar == null) | ||
997 | return; | ||
998 | |||
999 | detachedpos = avatar.AbsolutePosition; | ||
1000 | RootPart.FromItemID = UUID.Zero; | ||
1001 | |||
1002 | AbsolutePosition = detachedpos; | ||
1003 | m_rootPart.AttachedAvatar = UUID.Zero; | ||
1004 | |||
1005 | SceneObjectPart[] parts = m_parts.GetArray(); | 984 | SceneObjectPart[] parts = m_parts.GetArray(); |
1006 | for (int i = 0; i < parts.Length; i++) | 985 | for (int i = 0; i < parts.Length; i++) |
1007 | parts[i].AttachedAvatar = UUID.Zero; | 986 | parts[i].SetAttachmentPoint(point); |
987 | } | ||
1008 | 988 | ||
1009 | m_rootPart.SetParentLocalId(0); | 989 | public void ClearPartAttachmentData() |
1010 | SetAttachmentPoint((byte)0); | 990 | { |
1011 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_scene.m_physicalPrim); | 991 | SetAttachmentPoint((Byte)0); |
1012 | HasGroupChanged = true; | ||
1013 | RootPart.Rezzed = DateTime.Now; | ||
1014 | RootPart.RemFlag(PrimFlags.TemporaryOnRez); | ||
1015 | AttachToBackup(); | ||
1016 | m_scene.EventManager.TriggerParcelPrimCountTainted(); | ||
1017 | m_rootPart.ScheduleFullUpdate(); | ||
1018 | m_rootPart.ClearUndoState(); | ||
1019 | } | 992 | } |
1020 | 993 | ||
1021 | /// <summary> | 994 | /// <summary> |
@@ -3349,13 +3322,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3349 | return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); | 3322 | return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); |
3350 | } | 3323 | } |
3351 | 3324 | ||
3352 | public void SetAttachmentPoint(byte point) | ||
3353 | { | ||
3354 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
3355 | for (int i = 0; i < parts.Length; i++) | ||
3356 | parts[i].SetAttachmentPoint(point); | ||
3357 | } | ||
3358 | |||
3359 | #region ISceneObject | 3325 | #region ISceneObject |
3360 | 3326 | ||
3361 | public virtual ISceneObject CloneForNewScene() | 3327 | public virtual ISceneObject CloneForNewScene() |