diff options
author | Justin Clark-Casey (justincc) | 2012-04-06 21:14:19 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-04-06 21:14:19 +0100 |
commit | f2903db39009c7e62f6a07c545183b9588bff775 (patch) | |
tree | 7960717836df2d7011e5bb1d05386bd330827910 | |
parent | Make llGetMass() return total mass of object when called on root prim. (diff) | |
download | opensim-SC-f2903db39009c7e62f6a07c545183b9588bff775.zip opensim-SC-f2903db39009c7e62f6a07c545183b9588bff775.tar.gz opensim-SC-f2903db39009c7e62f6a07c545183b9588bff775.tar.bz2 opensim-SC-f2903db39009c7e62f6a07c545183b9588bff775.tar.xz |
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).
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 16 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 27 |
2 files changed, 40 insertions, 3 deletions
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 | |||
3514 | }); | 3514 | }); |
3515 | } | 3515 | } |
3516 | 3516 | ||
3517 | /// <summary> | ||
3518 | /// Gets the mass. | ||
3519 | /// </summary> | ||
3520 | /// <returns> | ||
3521 | /// The mass. | ||
3522 | /// </returns> | ||
3523 | public float GetMass() | ||
3524 | { | ||
3525 | PhysicsActor pa = PhysicsActor; | ||
3526 | |||
3527 | if (pa != null) | ||
3528 | return pa.Mass; | ||
3529 | else | ||
3530 | return 0; | ||
3531 | } | ||
3532 | |||
3517 | internal void PushForce(Vector3 impulse) | 3533 | internal void PushForce(Vector3 impulse) |
3518 | { | 3534 | { |
3519 | if (PhysicsActor != null) | 3535 | 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 | |||
2907 | public LSL_Float llGetMass() | 2907 | public LSL_Float llGetMass() |
2908 | { | 2908 | { |
2909 | m_host.AddScriptLPS(1); | 2909 | m_host.AddScriptLPS(1); |
2910 | if (m_host.IsRoot) | 2910 | |
2911 | return m_host.ParentGroup.GetMass(); | 2911 | if (m_host.ParentGroup.IsAttachment) |
2912 | { | ||
2913 | ScenePresence attachedAvatar = World.GetScenePresence(m_host.ParentGroup.AttachedAvatar); | ||
2914 | |||
2915 | if (attachedAvatar != null) | ||
2916 | { | ||
2917 | return attachedAvatar.GetMass(); | ||
2918 | } | ||
2919 | else | ||
2920 | { | ||
2921 | return 0; | ||
2922 | } | ||
2923 | } | ||
2912 | else | 2924 | else |
2913 | return m_host.GetMass(); | 2925 | { |
2926 | if (m_host.IsRoot) | ||
2927 | { | ||
2928 | return m_host.ParentGroup.GetMass(); | ||
2929 | } | ||
2930 | else | ||
2931 | { | ||
2932 | return m_host.GetMass(); | ||
2933 | } | ||
2934 | } | ||
2914 | } | 2935 | } |
2915 | 2936 | ||
2916 | public void llCollisionFilter(string name, string id, int accept) | 2937 | public void llCollisionFilter(string name, string id, int accept) |