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). --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 16 +++++++++++++ .../Shared/Api/Implementation/LSL_Api.cs | 27 +++++++++++++++++++--- 2 files changed, 40 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 19dab32..a21c66f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3514,6 +3514,22 @@ namespace OpenSim.Region.Framework.Scenes }); } + /// + /// Gets the mass. + /// + /// + /// The mass. + /// + public float GetMass() + { + PhysicsActor pa = PhysicsActor; + + if (pa != null) + return pa.Mass; + else + return 0; + } + internal void PushForce(Vector3 impulse) { if (PhysicsActor != null) 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