From 35b7c80e0ba876649c606d5d047fcb59754372ea Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Tue, 31 Jul 2012 14:45:23 +0100
Subject: implementing osDropAttachment & osDropAttachmentAt
---
.../Avatar/Attachments/AttachmentsModule.cs | 11 +++++++-
.../Framework/Interfaces/IAttachmentsModule.cs | 9 ++++++
.../Shared/Api/Implementation/OSSL_Api.cs | 33 ++++++++++++++++++++--
.../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 12 ++++++++
.../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 10 +++++++
5 files changed, 72 insertions(+), 3 deletions(-)
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 130c869..2a513e9 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -407,6 +407,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
public void DetachSingleAttachmentToGround(IScenePresence sp, uint soLocalId)
{
+ DetachSingleAttachmentToGround(sp, soLocalId, sp.AbsolutePosition, Quaternion.Identity);
+ }
+
+ public void DetachSingleAttachmentToGround(IScenePresence sp, uint soLocalId, Vector3 absolutePos, Quaternion absoluteRot)
+ {
if (!Enabled)
return;
@@ -448,7 +453,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
so.FromItemID = UUID.Zero;
SceneObjectPart rootPart = so.RootPart;
- so.AbsolutePosition = sp.AbsolutePosition;
+ so.AbsolutePosition = absolutePos;
+ if (absoluteRot != Quaternion.Identity)
+ {
+ so.UpdateGroupRotationR(absoluteRot);
+ }
so.AttachedAvatar = UUID.Zero;
rootPart.SetParentLocalId(0);
so.ClearPartAttachmentData();
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
index 8155eab..620ec22 100644
--- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
@@ -109,6 +109,15 @@ namespace OpenSim.Region.Framework.Interfaces
void DetachSingleAttachmentToGround(IScenePresence sp, uint objectLocalID);
///
+ /// Detach the given item to the ground at the specified coordinates & rotation
+ ///
+ ///
+ ///
+ ///
+ ///
+ void DetachSingleAttachmentToGround(IScenePresence sp, uint objectLocalID, Vector3 absolutePos, Quaternion absoluteRot);
+
+ ///
/// Detach the given attachment so that it remains in the user's inventory.
///
/// /param>
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 8b73cd9..fec8a67 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -3549,6 +3549,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (m_UrlModule != null)
m_UrlModule.HttpContentType(new UUID(id),type);
}
-
- }
+
+ public void osDropAttachment()
+ {
+ CheckThreatLevel(ThreatLevel.Moderate, "osDropAttachment");
+ m_host.AddScriptLPS(1);
+
+ IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
+ ScenePresence sp = attachmentsModule == null ? null : m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.OwnerID);
+
+ if (attachmentsModule != null && sp != null)
+ {
+ attachmentsModule.DetachSingleAttachmentToGround(sp, m_host.ParentGroup.LocalId);
+ }
+ }
+
+ public void osDropAttachmentAt(LSL_Vector pos, LSL_Rotation rot)
+ {
+ CheckThreatLevel(ThreatLevel.Moderate, "osDropAttachment");
+ m_host.AddScriptLPS(1);
+
+ IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
+ ScenePresence sp = attachmentsModule == null ? null : m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.OwnerID);
+
+ if (attachmentsModule != null && sp != null)
+ {
+ Vector3 omvPos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z);
+ Quaternion omvRot = LSL_Api.Rot2Quaternion(rot);
+ attachmentsModule.DetachSingleAttachmentToGround(sp, m_host.ParentGroup.LocalId, omvPos, omvRot);
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 3985e66..e28473d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -394,5 +394,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
///
///
void osSetContentType(LSL_Key id, string type);
+
+ ///
+ /// Attempts to drop an attachment to the ground
+ ///
+ void osDropAttachment();
+
+ ///
+ /// Attempts to drop an attachment at the specified coordinates.
+ ///
+ ///
+ ///
+ void osDropAttachmentAt(vector pos, rotation rot);
}
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 52ca3da..bae5594 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -972,5 +972,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
{
m_OSSL_Functions.osSetContentType(id,type);
}
+
+ public void osDropAttachment()
+ {
+ m_OSSL_Functions.osDropAttachment();
+ }
+
+ public void osDropAttachmentAt(vector pos, rotation rot)
+ {
+ m_OSSL_Functions.osDropAttachmentAt(pos, rot);
+ }
}
}
--
cgit v1.1