aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
authorMagnuz Binder2015-05-01 07:00:45 +0200
committerMichael Cerquoni2015-05-04 13:14:09 -0400
commit5a2440dfdf4a4ab769692330f6d4f98521e271ce (patch)
tree35fafd2c4ecc01027b966f6372222020898bbdfe /OpenSim/Region/ScriptEngine
parentPatch llCastRay fully-simplified to V2. (diff)
downloadopensim-SC_OLD-5a2440dfdf4a4ab769692330f6d4f98521e271ce.zip
opensim-SC_OLD-5a2440dfdf4a4ab769692330f6d4f98521e271ce.tar.gz
opensim-SC_OLD-5a2440dfdf4a4ab769692330f6d4f98521e271ce.tar.bz2
opensim-SC_OLD-5a2440dfdf4a4ab769692330f6d4f98521e271ce.tar.xz
Implement llGetGeometricCenter correctly.
Signed-off-by: Michael Cerquoni <nebadon2025@gmail.com>
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs21
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)