From 627efc172bda961f888dd3191fd8e1c4885f46e3 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 6 Apr 2012 20:32:39 +0100 Subject: Make llGetMass() return total mass of object when called on root prim. As per http://lslwiki.net/lslwiki/wakka.php?wakka=llGetMass Aims to resolve http://opensimulator.org/mantis/view.php?id=5954 --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 8d25a62..43b66f4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2907,7 +2907,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float llGetMass() { m_host.AddScriptLPS(1); - return m_host.GetMass(); + if (m_host.IsRoot) + return m_host.ParentGroup.GetMass(); + else + return m_host.GetMass(); } public void llCollisionFilter(string name, string id, int accept) -- cgit v1.1 From c3a8c00ce0e60b0988fc0d62712e896e5c3e1ac8 Mon Sep 17 00:00:00 2001 From: Talun Date: Fri, 6 Apr 2012 19:11:09 +0100 Subject: Addition of missing constants for llGetObjectDetails including for Mantis 5502 Signed-off-by: nebadon --- .../Shared/Api/Implementation/LSL_Api.cs | 72 ++++++++++++++++++++++ 1 file changed, 72 insertions(+) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 43b66f4..a046f29 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -10333,6 +10333,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case ScriptBaseClass.OBJECT_CREATOR: ret.Add(new LSL_String(UUID.Zero.ToString())); break; + // For the following 8 see the Object version below + case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: + ret.Add(new LSL_Integer(0)); + break; + case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: + ret.Add(new LSL_Integer(0)); + break; + case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: + ret.Add(new LSL_Integer(0)); + break; + case ScriptBaseClass.OBJECT_SCRIPT_TIME: + ret.Add(new LSL_Float(0)); + break; + case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: + ret.Add(new LSL_Integer(0)); + break; + case ScriptBaseClass.OBJECT_SERVER_COST: + ret.Add(new LSL_Float(0)); + break; + case ScriptBaseClass.OBJECT_STREAMING_COST: + ret.Add(new LSL_Float(0)); + break; + case ScriptBaseClass.OBJECT_PHYSICS_COST: + ret.Add(new LSL_Float(0)); + break; + default: + // Invalid or unhandled constant. + ret.Add(new LSL_Integer(ScriptBaseClass.OBJECT_UNKNOWN_DETAIL)); + break; } } @@ -10370,6 +10399,49 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case ScriptBaseClass.OBJECT_CREATOR: ret.Add(new LSL_String(obj.CreatorID.ToString())); break; + // The following 8 I have intentionaly coded to return zero. They are part of + // "Land Impact" calculations. These calculations are probably not applicable + // to OpenSim, required figures (cpu/memory usage) are not currently tracked + // I have intentionally left these all at zero rather than return possibly + // missleading numbers + case ScriptBaseClass.OBJECT_RUNNING_SCRIPT_COUNT: + // in SL this currently includes crashed scripts + ret.Add(new LSL_Integer(0)); + break; + case ScriptBaseClass.OBJECT_TOTAL_SCRIPT_COUNT: + ret.Add(new LSL_Integer(0)); + break; + case ScriptBaseClass.OBJECT_SCRIPT_MEMORY: + // The value returned in SL for mono scripts is 65536 * number of active scripts + ret.Add(new LSL_Integer(0)); + break; + case ScriptBaseClass.OBJECT_SCRIPT_TIME: + // Average cpu time per simulator frame expended on all scripts in the objetc + ret.Add(new LSL_Float(0)); + break; + case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE: + // according to the SL wiki A prim or linkset will have prim + // equivalent of the number of prims in a linkset if it does not + // contain a mesh anywhere in the link set or is not a normal prim + // The value returned in SL for normal prims is prim count + ret.Add(new LSL_Integer(0)); + break; + case ScriptBaseClass.OBJECT_SERVER_COST: + // The value returned in SL for normal prims is prim count + ret.Add(new LSL_Float(0)); + break; + case ScriptBaseClass.OBJECT_STREAMING_COST: + // The value returned in SL for normal prims is prim count * 0.06 + ret.Add(new LSL_Float(0)); + break; + case ScriptBaseClass.OBJECT_PHYSICS_COST: + // The value returned in SL for normal prims is prim count + ret.Add(new LSL_Float(0)); + break; + default: + // Invalid or unhandled constant. + ret.Add(new LSL_Integer(ScriptBaseClass.OBJECT_UNKNOWN_DETAIL)); + break; } } -- cgit v1.1 From f2903db39009c7e62f6a07c545183b9588bff775 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 6 Apr 2012 21:14:19 +0100 Subject: For llGetMass(), return the mass of the avatar is the object is attached. As per http://lslwiki.net/lslwiki/wakka.php?wakka=llGetMass This is the mass as used by the physics engine (ODE or Bullet). --- .../Shared/Api/Implementation/LSL_Api.cs | 27 +++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 43b66f4..17f5a64 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2907,10 +2907,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float llGetMass() { m_host.AddScriptLPS(1); - if (m_host.IsRoot) - return m_host.ParentGroup.GetMass(); + + if (m_host.ParentGroup.IsAttachment) + { + ScenePresence attachedAvatar = World.GetScenePresence(m_host.ParentGroup.AttachedAvatar); + + if (attachedAvatar != null) + { + return attachedAvatar.GetMass(); + } + else + { + return 0; + } + } else - return m_host.GetMass(); + { + if (m_host.IsRoot) + { + return m_host.ParentGroup.GetMass(); + } + else + { + return m_host.GetMass(); + } + } } public void llCollisionFilter(string name, string id, int accept) -- cgit v1.1 From 3af1cd65f91db87778096196bfd985dc48c72d87 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 6 Apr 2012 22:41:35 +0100 Subject: Fix llGetLinkPrimParams for PRIM_POS_LOCAL for child prims whether in scene or attachments. Return relative position to root prim rather than 0,0,0. Should fix same issue with llGetLocalPos() http://opensimulator.org/mantis/view.php?id=5951 --- .../Shared/Api/Implementation/LSL_Api.cs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index a85a36e..ad73f47 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2022,27 +2022,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api protected LSL_Vector GetPartLocalPos(SceneObjectPart part) { m_host.AddScriptLPS(1); + + Vector3 pos; + if (part.ParentID == 0) { - return new LSL_Vector(part.AbsolutePosition.X, - part.AbsolutePosition.Y, - part.AbsolutePosition.Z); + pos = part.AbsolutePosition; } else { - if (m_host.IsRoot) + if (part.IsRoot) { - return new LSL_Vector(m_host.AttachedPos.X, - m_host.AttachedPos.Y, - m_host.AttachedPos.Z); + pos = part.AttachedPos; } else { - return new LSL_Vector(part.OffsetPosition.X, - part.OffsetPosition.Y, - part.OffsetPosition.Z); + pos = part.OffsetPosition; } } + +// m_log.DebugFormat("[LSL API]: Returning {0} in GetPartLocalPos()", pos); + + return new LSL_Vector(pos.X, pos.Y, pos.Z); } public void llSetRot(LSL_Rotation rot) -- cgit v1.1 From 4a58d4c5a4e7e405448113a0efd5c34349eed7b5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 6 Apr 2012 23:36:13 +0100 Subject: refactor: Use clearer part.ParentGroup.IsAttachment in LSL_Api.GetPartLocalPos() --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index ad73f47..021b352 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2025,19 +2025,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Vector3 pos; - if (part.ParentID == 0) + if (!part.IsRoot) { - pos = part.AbsolutePosition; + pos = part.OffsetPosition; } else { - if (part.IsRoot) + if (part.ParentGroup.IsAttachment) { pos = part.AttachedPos; } else { - pos = part.OffsetPosition; + pos = part.AbsolutePosition; } } -- cgit v1.1 From 33e91f1088ce055fa52f34cabc2d211fcc587b5f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 6 Apr 2012 23:43:03 +0100 Subject: Implement PRIM_POS_LOCAL on llSetPrimitiveParams() and other prim params LSL functions. This is the same as PRIM_POSITION --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 021b352..8223d95 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7171,6 +7171,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api switch (code) { case (int)ScriptBaseClass.PRIM_POSITION: + case (int)ScriptBaseClass.PRIM_POS_LOCAL: if (remain < 1) return; -- cgit v1.1 From 7d8bb33c5b2420d4e744269f67a25dd2b9746a35 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 7 Apr 2012 00:33:02 +0100 Subject: Store FromItemID for attachments once on SOG instead of on every SOP and only ever using the root part entry. This eliminates some pointless memory use. --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 8223d95..291f52e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3080,7 +3080,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api SceneObjectPart host = (SceneObjectPart)o; SceneObjectGroup grp = host.ParentGroup; - UUID itemID = grp.GetFromItemID(); + UUID itemID = grp.FromItemID; ScenePresence presence = World.GetScenePresence(host.OwnerID); IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; -- cgit v1.1