diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 42a18c56fc..93920b03ad 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 if (changed && m_scene.AvatarFactory != null) m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); - so.DetachToGround(); + presence.RemoveAttachment(so); + DetachSceneObjectToGround(so, presence); List uuids = new List(); uuids.Add(inventoryID); @@ -482,6 +483,33 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments m_scene.EventManager.TriggerOnAttach(so.LocalId, sceneObjectID, UUID.Zero); } + + /// + /// Detach the given scene objet to the ground. + /// + /// + /// The caller has to take care of all the other work in updating avatar appearance, inventory, etc. + /// + /// The scene object to detach. + /// The scene presence from which the scene object is being detached. + private void DetachSceneObjectToGround(SceneObjectGroup so, ScenePresence sp) + { + SceneObjectPart rootPart = so.RootPart; + + rootPart.FromItemID = UUID.Zero; + so.AbsolutePosition = sp.AbsolutePosition; + so.ForEachPart(part => part.AttachedAvatar = UUID.Zero); + rootPart.SetParentLocalId(0); + so.ClearPartAttachmentData(); + rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive, m_scene.m_physicalPrim); + so.HasGroupChanged = true; + rootPart.Rezzed = DateTime.Now; + rootPart.RemFlag(PrimFlags.TemporaryOnRez); + so.AttachToBackup(); + m_scene.EventManager.TriggerParcelPrimCountTainted(); + rootPart.ScheduleFullUpdate(); + rootPart.ClearUndoState(); + } // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. // 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 00e3363a0a..e3b8fc8163 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -979,45 +979,18 @@ namespace OpenSim.Region.Framework.Scenes return m_rootPart.Shape.State; } + public void SetAttachmentPoint(byte point) + { + SceneObjectPart[] parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) + parts[i].SetAttachmentPoint(point); + } + public void ClearPartAttachmentData() { SetAttachmentPoint((Byte)0); } - public void DetachToGround() - { - ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.AttachedAvatar); - if (avatar == null) - return; - - avatar.RemoveAttachment(this); - - Vector3 detachedpos = new Vector3(127f,127f,127f); - if (avatar == null) - return; - - detachedpos = avatar.AbsolutePosition; - RootPart.FromItemID = UUID.Zero; - - AbsolutePosition = detachedpos; - m_rootPart.AttachedAvatar = UUID.Zero; - - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - parts[i].AttachedAvatar = UUID.Zero; - - m_rootPart.SetParentLocalId(0); - SetAttachmentPoint((byte)0); - m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_scene.m_physicalPrim); - HasGroupChanged = true; - RootPart.Rezzed = DateTime.Now; - RootPart.RemFlag(PrimFlags.TemporaryOnRez); - AttachToBackup(); - m_scene.EventManager.TriggerParcelPrimCountTainted(); - m_rootPart.ScheduleFullUpdate(); - m_rootPart.ClearUndoState(); - } - /// /// /// @@ -3349,13 +3322,6 @@ namespace OpenSim.Region.Framework.Scenes return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); } - public void SetAttachmentPoint(byte point) - { - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - parts[i].SetAttachmentPoint(point); - } - #region ISceneObject public virtual ISceneObject CloneForNewScene()