diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 58b3930..2fcfcbe 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -10087,9 +10087,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10087 | return prim; | 10087 | return prim; |
10088 | } | 10088 | } |
10089 | 10089 | ||
10090 | /// <summary> | ||
10091 | /// Implementation of llGetGeometricCenter according to SL 2015-04-30. | ||
10092 | /// http://wiki.secondlife.com/wiki/LlGetGeometricCenter | ||
10093 | /// Returns the average position offset of all linked parts, | ||
10094 | /// including the root prim and seated avatars, | ||
10095 | /// relative to the root prim in local coordinates. | ||
10096 | /// </summary> | ||
10090 | public LSL_Vector llGetGeometricCenter() | 10097 | public LSL_Vector llGetGeometricCenter() |
10091 | { | 10098 | { |
10092 | return new LSL_Vector(m_host.GetGeometricCenter()); | 10099 | // Subtract whatever position the root prim has to make it zero |
10100 | Vector3 offset = m_host.ParentGroup.RootPart.OffsetPosition * -1.0f; | ||
10101 | |||
10102 | // Add all prim/part position offsets | ||
10103 | foreach (SceneObjectPart part in m_host.ParentGroup.Parts) | ||
10104 | offset = offset + part.OffsetPosition; | ||
10105 | // Add all avatar/scene presence position offsets | ||
10106 | foreach (ScenePresence sp in m_host.ParentGroup.GetSittingAvatars()) | ||
10107 | offset = offset + sp.OffsetPosition; | ||
10108 | |||
10109 | // Calculate and return the average offset | ||
10110 | offset = offset / (float)(m_host.ParentGroup.PrimCount + m_host.ParentGroup.GetSittingAvatarsCount()); | ||
10111 | return new LSL_Vector(offset); | ||
10093 | } | 10112 | } |
10094 | 10113 | ||
10095 | public LSL_List GetEntityParams(ISceneEntity entity, LSL_List rules) | 10114 | public LSL_List GetEntityParams(ISceneEntity entity, LSL_List rules) |