From 218160494eab224ba1ac83491ff133154cfdb8b4 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 16 Aug 2017 23:44:34 +0100 Subject: fix llRot2Axis(ZERO_ROTATION) and non normalized inputs, same for llRot2Angle() --- .../Shared/Api/Implementation/LSL_Api.cs | 23 +++++++++------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 75b6b0e..b810ffb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -5527,20 +5527,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - if (Math.Abs(rot.s) > 1) // normalization needed - rot.Normalize(); + rot.Normalize(); double s = Math.Sqrt(1 - rot.s * rot.s); - if (s < 0.001) - { - return new LSL_Vector(1, 0, 0); - } - else - { - double invS = 1.0 / s; - if (rot.s < 0) invS = -invS; - return new LSL_Vector(rot.x * invS, rot.y * invS, rot.z * invS); - } + if (s < 1e-8) + return new LSL_Vector(0, 0, 0); + + double invS = 1.0 / s; + if (rot.s < 0) + invS = -invS; + return new LSL_Vector(rot.x * invS, rot.y * invS, rot.z * invS); } @@ -5549,8 +5545,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - if (Math.Abs(rot.s) > 1) // normalization needed - rot.Normalize(); + rot.Normalize(); double angle = 2 * Math.Acos(rot.s); if (angle > Math.PI) -- cgit v1.1