From 95c53ecae708c8f915e02c4f872c931efdd6c29a Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 21 Jan 2013 15:55:54 -0800 Subject: [PATCH] Have SOP and LSL_Api call the proper GetCenterOfMass and GetGeometricCenter routines on the physics engine. Won't make a difference for any existing scripts since ODE always returned Vector3.Zero. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 10 ++++++++++ .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 44e8fdf7c9..e0ea344d2e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1951,6 +1951,16 @@ namespace OpenSim.Region.Framework.Scenes { PhysicsActor pa = PhysActor; + if (pa != null) + return new Vector3(pa.GeometricCenter.X, pa.GeometricCenter.Y, pa.GeometricCenter.Z); + else + return new Vector3(0, 0, 0); + } + + public Vector3 GetCenterOfMass() + { + PhysicsActor pa = PhysActor; + if (pa != null) return new Vector3(pa.CenterOfMass.X, pa.CenterOfMass.Y, pa.CenterOfMass.Z); else diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index db5add19e6..507c3997f5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4923,7 +4923,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llGetCenterOfMass() { m_host.AddScriptLPS(1); - Vector3 center = m_host.GetGeometricCenter(); + Vector3 center = m_host.GetCenterOfMass(); return new LSL_Vector(center.X,center.Y,center.Z); }