aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
authorDiva Canto2013-06-11 15:36:52 -0700
committerDiva Canto2013-06-11 15:36:52 -0700
commita0fed03e1012f76195ac6fd02912bf5979b9a27f (patch)
tree898336047dd123c2603a69d56666c50f18a2b01c /OpenSim/Region/ScriptEngine
parentReally bad idea to lock m_UserCache for so long in UserManagementModule. Adde... (diff)
parentPut the "script saved" and "notecard saved" messages back into the bottom (diff)
downloadopensim-SC-a0fed03e1012f76195ac6fd02912bf5979b9a27f.zip
opensim-SC-a0fed03e1012f76195ac6fd02912bf5979b9a27f.tar.gz
opensim-SC-a0fed03e1012f76195ac6fd02912bf5979b9a27f.tar.bz2
opensim-SC-a0fed03e1012f76195ac6fd02912bf5979b9a27f.tar.xz
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs41
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs25
2 files changed, 36 insertions, 30 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index ec5aa49..e1630b3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -4665,35 +4665,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4665 public LSL_Vector llRot2Axis(LSL_Rotation rot) 4665 public LSL_Vector llRot2Axis(LSL_Rotation rot)
4666 { 4666 {
4667 m_host.AddScriptLPS(1); 4667 m_host.AddScriptLPS(1);
4668 double x,y,z; 4668 double x, y, z;
4669 4669
4670 if (rot.s > 1) // normalization needed 4670 if (Math.Abs(rot.s) > 1) // normalization needed
4671 { 4671 rot.Normalize();
4672 double length = Math.Sqrt(rot.x * rot.x + rot.y * rot.y +
4673 rot.z * rot.z + rot.s * rot.s);
4674
4675 rot.x /= length;
4676 rot.y /= length;
4677 rot.z /= length;
4678 rot.s /= length;
4679
4680 }
4681 4672
4682 // double angle = 2 * Math.Acos(rot.s);
4683 double s = Math.Sqrt(1 - rot.s * rot.s); 4673 double s = Math.Sqrt(1 - rot.s * rot.s);
4684 if (s < 0.001) 4674 if (s < 0.001)
4685 { 4675 {
4686 x = 1; 4676 return new LSL_Vector(1, 0, 0);
4687 y = z = 0;
4688 } 4677 }
4689 else 4678 else
4690 { 4679 {
4691 x = rot.x / s; // normalise axis 4680 double invS = 1.0 / s;
4692 y = rot.y / s; 4681 if (rot.s < 0) invS = -invS;
4693 z = rot.z / s; 4682 return new LSL_Vector(rot.x * invS, rot.y * invS, rot.z * invS);
4694 } 4683 }
4695
4696 return new LSL_Vector(x,y,z);
4697 } 4684 }
4698 4685
4699 4686
@@ -4702,18 +4689,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4702 { 4689 {
4703 m_host.AddScriptLPS(1); 4690 m_host.AddScriptLPS(1);
4704 4691
4705 if (rot.s > 1) // normalization needed 4692 if (Math.Abs(rot.s) > 1) // normalization needed
4706 { 4693 rot.Normalize();
4707 double length = Math.Sqrt(rot.x * rot.x + rot.y * rot.y +
4708 rot.z * rot.z + rot.s * rot.s);
4709
4710 rot.x /= length;
4711 rot.y /= length;
4712 rot.z /= length;
4713 rot.s /= length;
4714 }
4715 4694
4716 double angle = 2 * Math.Acos(rot.s); 4695 double angle = 2 * Math.Acos(rot.s);
4696 if (angle > Math.PI)
4697 angle = 2 * Math.PI - angle;
4717 4698
4718 return angle; 4699 return angle;
4719 } 4700 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index 9ca5ca9..50f9377 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -371,6 +371,31 @@ namespace OpenSim.Region.ScriptEngine.Shared
371 371
372 #endregion 372 #endregion
373 373
374 #region Methods
375 public Quaternion Normalize()
376 {
377 double length = Math.Sqrt(x * x + y * y + z * z + s * s);
378 if (length < float.Epsilon)
379 {
380 x = 0;
381 y = 0;
382 z = 0;
383 s = 1;
384 }
385 else
386 {
387
388 double invLength = 1.0 / length;
389 x *= invLength;
390 y *= invLength;
391 z *= invLength;
392 s *= invLength;
393 }
394
395 return this;
396 }
397 #endregion
398
374 #region Overriders 399 #region Overriders
375 400
376 public override int GetHashCode() 401 public override int GetHashCode()