From 74f89fb22da159a940e942192d0cb59163e78987 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 4 Oct 2008 01:09:22 +0000 Subject: Add "Drop" functionality to pie menu --- OpenSim/Region/Environment/Scenes/InnerScene.cs | 21 ++++++++++++++- .../Region/Environment/Scenes/Scene.Inventory.cs | 31 ++++++++++++++++++++++ OpenSim/Region/Environment/Scenes/Scene.cs | 1 + .../Region/Environment/Scenes/SceneObjectGroup.cs | 12 ++++----- 4 files changed, 58 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Environment/Scenes') diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index 65fa544..869111c 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs @@ -358,6 +358,24 @@ namespace OpenSim.Region.Environment.Scenes m_activeScripts += number; } + protected internal void DropObject(uint objectLocalID, IClientAPI remoteClient) + { + List EntityList = GetEntities(); + + foreach (EntityBase obj in EntityList) + { + if (obj is SceneObjectGroup) + { + if (((SceneObjectGroup)obj).LocalId == objectLocalID) + { + SceneObjectGroup group = (SceneObjectGroup)obj; + + m_parentScene.DetachSingleAttachmentToGround(group.UUID,remoteClient); + } + } + } + } + protected internal void DetachObject(uint objectLocalID, IClientAPI remoteClient) { List EntityList = GetEntities(); @@ -441,10 +459,11 @@ namespace OpenSim.Region.Environment.Scenes (uint)(PermissionMask.Copy | PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer), (uint)(PermissionMask.Copy | PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer), ItemFlags, false, false, remoteClient.AgentId, true); - objatt.SetAttachmentPoint(Convert.ToByte(AttachmentPt)); if (objatt != null) { + objatt.SetAttachmentPoint(Convert.ToByte(AttachmentPt)); + AttachObject(remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition); objatt.ScheduleGroupForFullUpdate(); } diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index a7bce49..c139fd9 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -2293,6 +2293,37 @@ namespace OpenSim.Region.Environment.Scenes m_innerScene.AttachObject(controllingClient, localID, attachPoint, rot, pos); } + public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient) + { + SceneObjectPart part = GetSceneObjectPart(itemID); + if(part == null || part.ParentGroup == null) + return; + + UUID inventoryID = part.ParentGroup.GetFromAssetID(); + + ScenePresence presence; + if (TryGetAvatar(remoteClient.AgentId, out presence)) + { + if(!ExternalChecks.ExternalChecksCanRezObject(part.ParentGroup.Children.Count, remoteClient.AgentId, presence.AbsolutePosition)) + return; + + presence.Appearance.DetachAttachment(itemID); + IAvatarFactory ava = RequestModuleInterface(); + if (ava != null) + { + ava.UpdateDatabase(remoteClient.AgentId, presence.Appearance); + } + part.ParentGroup.DetachToGround(); + CachedUserInfo userInfo = + CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); + if (userInfo != null) + { + userInfo.DeleteItem(inventoryID); + remoteClient.SendRemoveInventoryItem(inventoryID); + } + } + } + public void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient) { ScenePresence presence; diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 5ab40cc..f90c6fb 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -2172,6 +2172,7 @@ namespace OpenSim.Region.Environment.Scenes client.OnDetachAttachmentIntoInv += DetachSingleAttachmentToInv; client.OnObjectAttach += m_innerScene.AttachObject; client.OnObjectDetach += m_innerScene.DetachObject; + client.OnObjectDrop += m_innerScene.DropObject; client.OnNameFromUUIDRequest += CommsManager.HandleUUIDNameRequest; client.OnObjectDescription += m_innerScene.PrimDescription; client.OnObjectName += m_innerScene.PrimName; diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 6cd0bae..18322ee 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -766,19 +766,19 @@ namespace OpenSim.Region.Environment.Scenes { ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.AttachedAvatar); Vector3 detachedpos = new Vector3(127f,127f,127f); - if (avatar != null) - { - detachedpos = avatar.AbsolutePosition; - avatar.RemoveAttachment(this); - } + if (avatar == null) + return; + + detachedpos = avatar.AbsolutePosition; + AbsolutePosition = detachedpos; m_rootPart.AttachedAvatar = UUID.Zero; m_rootPart.SetParentLocalId(0); SetAttachmentPoint((byte)0); - m_rootPart.IsAttachment = false; m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim); HasGroupChanged = true; AttachToBackup(); + m_scene.EventManager.TriggerParcelPrimCountTainted(); m_rootPart.ScheduleFullUpdate(); m_rootPart.ClearUndoState(); } -- cgit v1.1