diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs | 16 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 16 |
2 files changed, 30 insertions, 2 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index b53f6c0..3ae1f3a 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs | |||
@@ -430,7 +430,21 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
430 | public LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r) | 430 | public LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r) |
431 | { | 431 | { |
432 | m_host.AddScriptLPS(1); | 432 | m_host.AddScriptLPS(1); |
433 | return (new LSL_Types.Vector3(1,0,0) * r); | 433 | double x,y,z,m; |
434 | m = Math.Sqrt(r.x*r.x+r.y*r.y+r.z*r.z+r.s*r.s); | ||
435 | // m is always greater than zero | ||
436 | if (m!=1) // if m is not equal to 1 then Rotation needs to be normalized | ||
437 | { | ||
438 | r.x/=m; | ||
439 | r.y/=m; | ||
440 | r.z/=m; | ||
441 | r.s/=m; | ||
442 | } | ||
443 | // Fast Algebric Calculations instead of Vectors & Quaternions Product | ||
444 | x = r.x*r.x-r.y*r.y-r.z*r.z+r.s*r.s; | ||
445 | y = 2*(r.x*r.y+r.z*r.s); | ||
446 | z = 2*(r.x*r.z-r.y*r.s); | ||
447 | return (new LSL_Types.Vector3(x,y,z)); | ||
434 | } | 448 | } |
435 | 449 | ||
436 | public LSL_Types.Vector3 llRot2Left(LSL_Types.Quaternion r) | 450 | public LSL_Types.Vector3 llRot2Left(LSL_Types.Quaternion r) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 260457b..e7313e1 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -417,7 +417,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
417 | public LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r) | 417 | public LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r) |
418 | { | 418 | { |
419 | m_host.AddScriptLPS(1); | 419 | m_host.AddScriptLPS(1); |
420 | return (new LSL_Types.Vector3(1,0,0) * r); | 420 | double x,y,z,m; |
421 | m = Math.Sqrt(r.x*r.x+r.y*r.y+r.z*r.z+r.s*r.s); | ||
422 | // m is always greater than zero | ||
423 | if (m!=1) // if m is not equal to 1 then Rotation needs to be normalized | ||
424 | { | ||
425 | r.x/=m; | ||
426 | r.y/=m; | ||
427 | r.z/=m; | ||
428 | r.s/=m; | ||
429 | } | ||
430 | // Fast Algebric Calculations instead of Vectors & Quaternions Product | ||
431 | x = r.x*r.x-r.y*r.y-r.z*r.z+r.s*r.s; | ||
432 | y = 2*(r.x*r.y+r.z*r.s); | ||
433 | z = 2*(r.x*r.z-r.y*r.s); | ||
434 | return (new LSL_Types.Vector3(x,y,z)); | ||
421 | } | 435 | } |
422 | 436 | ||
423 | public LSL_Types.Vector3 llRot2Left(LSL_Types.Quaternion r) | 437 | public LSL_Types.Vector3 llRot2Left(LSL_Types.Quaternion r) |