From e5a50b6a3b112bee131e6cfdfbfed5c203240bff Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Tue, 7 Oct 2008 11:41:43 +0000 Subject: From: chris yeoh The attached patch fixes mantis bug 2312 (llGetPos() returns incorrect values for child prims where the root prim is rotated). Regression tests still pass. Incidentally AbsolutePosition which was used before looks a little suspicious to me as its always going to return the wrong value if the root prim is rotated. GetWorldPosition does take the rotation into account, but AbsolutePosition is used in a lot of places. Though i don't understand why there is both GetWorldPosition as well as AbsolutePosition so I've left the latter alone. [i also cleaned up some indent problems, --- dr scofield] --- .../Shared/Api/Implementation/LSL_Api.cs | 29 ++++++++++------------ 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index ccc483c..def8fbe 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -91,9 +91,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api config.AddConfig("XEngine"); m_ScriptDelayFactor = config.Configs["XEngine"]. - GetFloat("ScriptDelayFactor", 1.0f); + GetFloat("ScriptDelayFactor", 1.0f); m_ScriptDistanceFactor = config.Configs["XEngine"]. - GetFloat("ScriptDistanceLimitFactor", 1.0f); + GetFloat("ScriptDistanceLimitFactor", 1.0f); AsyncCommands = new AsyncCommandManager(ScriptEngine); } @@ -937,7 +937,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Float llGround(LSL_Vector offset) { m_host.AddScriptLPS(1); - Vector3 pos = m_host.GetWorldPosition(); + Vector3 pos = m_host.GetWorldPosition(); int x = (int)(pos.X + offset.x); int y = (int)(pos.Y + offset.y); return World.GetLandHeight(x, y); @@ -1719,9 +1719,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Vector llGetPos() { m_host.AddScriptLPS(1); - return new LSL_Vector(m_host.AbsolutePosition.X, - m_host.AbsolutePosition.Y, - m_host.AbsolutePosition.Z); + Vector3 pos = m_host.GetWorldPosition(); + return new LSL_Vector(pos.X, pos.Y, pos.Z); } public LSL_Vector llGetLocalPos() @@ -4845,21 +4844,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Vector3 p0 = new Vector3(pos.X, pos.Y, (float)llGround( - new LSL_Vector(pos.X, pos.Y, pos.Z) - )); + new LSL_Vector(pos.X, pos.Y, pos.Z) + )); Vector3 p1 = new Vector3(pos.X + 1, pos.Y, (float)llGround( - new LSL_Vector(pos.X + 1, pos.Y, pos.Z) - )); + new LSL_Vector(pos.X + 1, pos.Y, pos.Z) + )); Vector3 p2 = new Vector3(pos.X, pos.Y + 1, (float)llGround( - new LSL_Vector(pos.X, pos.Y + 1, pos.Z) - )); + new LSL_Vector(pos.X, pos.Y + 1, pos.Z) + )); - Vector3 v0 = new Vector3( - p1.X - p0.X, p1.Y - p0.Y, p1.Z - p0.Z); - Vector3 v1 = new Vector3( - p2.X - p1.X, p2.Y - p1.Y, p2.Z - p1.Z); + Vector3 v0 = new Vector3(p1.X - p0.X, p1.Y - p0.Y, p1.Z - p0.Z); + Vector3 v1 = new Vector3(p2.X - p1.X, p2.Y - p1.Y, p2.Z - p1.Z); v0.Normalize(); v1.Normalize(); -- cgit v1.1