aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorUbitUmarov2018-04-19 19:21:08 +0100
committerUbitUmarov2018-04-19 19:21:08 +0100
commit037e5d8031c715c2e765a7cfd67afcf442aeeaa0 (patch)
tree1cede0152c8827470a8ba824ced6b3b5bd29e22e /OpenSim/Region
parentreduce debug logs (diff)
downloadopensim-SC-037e5d8031c715c2e765a7cfd67afcf442aeeaa0.zip
opensim-SC-037e5d8031c715c2e765a7cfd67afcf442aeeaa0.tar.gz
opensim-SC-037e5d8031c715c2e765a7cfd67afcf442aeeaa0.tar.bz2
opensim-SC-037e5d8031c715c2e765a7cfd67afcf442aeeaa0.tar.xz
save a few ns
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs10
1 files changed, 6 insertions, 4 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index 0c17a90..e9ee937 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -392,8 +392,8 @@ namespace OpenSim.Region.ScriptEngine.Shared
392 #region Methods 392 #region Methods
393 public Quaternion Normalize() 393 public Quaternion Normalize()
394 { 394 {
395 double length = Math.Sqrt(x * x + y * y + z * z + s * s); 395 double lengthsq = x * x + y * y + z * z + s * s;
396 if (length < float.Epsilon) 396 if (lengthsq < float.Epsilon)
397 { 397 {
398 x = 0; 398 x = 0;
399 y = 0; 399 y = 0;
@@ -403,7 +403,7 @@ namespace OpenSim.Region.ScriptEngine.Shared
403 else 403 else
404 { 404 {
405 405
406 double invLength = 1.0 / length; 406 double invLength = 1.0 / Math.Sqrt(lengthsq);
407 x *= invLength; 407 x *= invLength;
408 y *= invLength; 408 y *= invLength;
409 z *= invLength; 409 z *= invLength;
@@ -474,7 +474,8 @@ namespace OpenSim.Region.ScriptEngine.Shared
474 { 474 {
475 // LSL quaternions can normalize to 0, normal Quaternions can't. 475 // LSL quaternions can normalize to 0, normal Quaternions can't.
476 if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0) 476 if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0)
477 rot.z = 1; // ZERO_ROTATION = 0,0,0,1 477 return OMV_Quaternion.Identity; // ZERO_ROTATION = 0,0,0,1
478
478 OMV_Quaternion omvrot = new OMV_Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); 479 OMV_Quaternion omvrot = new OMV_Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s);
479 omvrot.Normalize(); 480 omvrot.Normalize();
480 return omvrot; 481 return omvrot;
@@ -510,6 +511,7 @@ namespace OpenSim.Region.ScriptEngine.Shared
510 511
511 public static Quaternion operator /(Quaternion a, Quaternion b) 512 public static Quaternion operator /(Quaternion a, Quaternion b)
512 { 513 {
514 // assuming normalized
513 b.s = -b.s; 515 b.s = -b.s;
514 return a * b; 516 return a * b;
515 } 517 }