diff options
Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index dbea6ef..417cef4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -465,22 +465,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
465 | 465 | ||
466 | //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke | 466 | //Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke |
467 | 467 | ||
468 | // Utility function for llRot2Euler | 468 | // Old implementation of llRot2Euler. Normalization not required as Atan2 function will |
469 | 469 | // only return values >= -PI (-180 degrees) and <= PI (180 degrees). | |
470 | // normalize an angle between -PI and PI (-180 to +180 degrees) | ||
471 | protected double NormalizeAngle(double angle) | ||
472 | { | ||
473 | if (angle > -Math.PI && angle < Math.PI) | ||
474 | return angle; | ||
475 | |||
476 | int numPis = (int)(Math.PI / angle); | ||
477 | double remainder = angle - Math.PI * numPis; | ||
478 | if (numPis % 2 == 1) | ||
479 | return Math.PI - angle; | ||
480 | return remainder; | ||
481 | } | ||
482 | |||
483 | // Old implementation of llRot2Euler, now normalized | ||
484 | 470 | ||
485 | public LSL_Vector llRot2Euler(LSL_Rotation r) | 471 | public LSL_Vector llRot2Euler(LSL_Rotation r) |
486 | { | 472 | { |
@@ -492,13 +478,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
492 | double n = 2 * (r.y * r.s + r.x * r.z); | 478 | double n = 2 * (r.y * r.s + r.x * r.z); |
493 | double p = m * m - n * n; | 479 | double p = m * m - n * n; |
494 | if (p > 0) | 480 | if (p > 0) |
495 | return new LSL_Vector(NormalizeAngle(Math.Atan2(2.0 * (r.x * r.s - r.y * r.z), (-t.x - t.y + t.z + t.s))), | 481 | return new LSL_Vector(Math.Atan2(2.0 * (r.x * r.s - r.y * r.z), (-t.x - t.y + t.z + t.s)), |
496 | NormalizeAngle(Math.Atan2(n, Math.Sqrt(p))), | 482 | Math.Atan2(n, Math.Sqrt(p)), |
497 | NormalizeAngle(Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s)))); | 483 | Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s))); |
498 | else if (n > 0) | 484 | else if (n > 0) |
499 | return new LSL_Vector(0.0, Math.PI * 0.5, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z))); | 485 | return new LSL_Vector(0.0, Math.PI * 0.5, Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z)); |
500 | else | 486 | else |
501 | return new LSL_Vector(0.0, -Math.PI * 0.5, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z))); | 487 | return new LSL_Vector(0.0, -Math.PI * 0.5, Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z)); |
502 | } | 488 | } |
503 | 489 | ||
504 | /* From wiki: | 490 | /* From wiki: |
@@ -5873,6 +5859,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5873 | PSYS_PART_MAX_AGE = 7, | 5859 | PSYS_PART_MAX_AGE = 7, |
5874 | PSYS_SRC_ACCEL = 8, | 5860 | PSYS_SRC_ACCEL = 8, |
5875 | PSYS_SRC_PATTERN = 9, | 5861 | PSYS_SRC_PATTERN = 9, |
5862 | PSYS_SRC_INNERANGLE = 10, | ||
5863 | PSYS_SRC_OUTERANGLE = 11, | ||
5876 | PSYS_SRC_TEXTURE = 12, | 5864 | PSYS_SRC_TEXTURE = 12, |
5877 | PSYS_SRC_BURST_RATE = 13, | 5865 | PSYS_SRC_BURST_RATE = 13, |
5878 | PSYS_SRC_BURST_PART_COUNT = 15, | 5866 | PSYS_SRC_BURST_PART_COUNT = 15, |
@@ -6005,6 +5993,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6005 | prules.Pattern = (Primitive.ParticleSystem.SourcePattern)tmpi; | 5993 | prules.Pattern = (Primitive.ParticleSystem.SourcePattern)tmpi; |
6006 | break; | 5994 | break; |
6007 | 5995 | ||
5996 | // PSYS_SRC_INNERANGLE and PSYS_SRC_ANGLE_BEGIN use the same variables. The | ||
5997 | // PSYS_SRC_OUTERANGLE and PSYS_SRC_ANGLE_END also use the same variable. The | ||
5998 | // client tells the difference between the two by looking at the 0x02 bit in | ||
5999 | // the PartFlags variable. | ||
6000 | case (int)ScriptBaseClass.PSYS_SRC_INNERANGLE: | ||
6001 | tempf = (float)rules.GetLSLFloatItem(i + 1); | ||
6002 | prules.InnerAngle = (float)tempf; | ||
6003 | prules.PartFlags &= 0xFFFFFFFD; // Make sure new angle format is off. | ||
6004 | break; | ||
6005 | |||
6006 | case (int)ScriptBaseClass.PSYS_SRC_OUTERANGLE: | ||
6007 | tempf = (float)rules.GetLSLFloatItem(i + 1); | ||
6008 | prules.OuterAngle = (float)tempf; | ||
6009 | prules.PartFlags &= 0xFFFFFFFD; // Make sure new angle format is off. | ||
6010 | break; | ||
6011 | |||
6008 | case (int)ScriptBaseClass.PSYS_SRC_TEXTURE: | 6012 | case (int)ScriptBaseClass.PSYS_SRC_TEXTURE: |
6009 | prules.Texture = KeyOrName(rules.GetLSLStringItem(i + 1)); | 6013 | prules.Texture = KeyOrName(rules.GetLSLStringItem(i + 1)); |
6010 | break; | 6014 | break; |
@@ -6061,11 +6065,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6061 | case (int)ScriptBaseClass.PSYS_SRC_ANGLE_BEGIN: | 6065 | case (int)ScriptBaseClass.PSYS_SRC_ANGLE_BEGIN: |
6062 | tempf = (float)rules.GetLSLFloatItem(i + 1); | 6066 | tempf = (float)rules.GetLSLFloatItem(i + 1); |
6063 | prules.InnerAngle = (float)tempf; | 6067 | prules.InnerAngle = (float)tempf; |
6068 | prules.PartFlags |= 0x02; // Set new angle format. | ||
6064 | break; | 6069 | break; |
6065 | 6070 | ||
6066 | case (int)ScriptBaseClass.PSYS_SRC_ANGLE_END: | 6071 | case (int)ScriptBaseClass.PSYS_SRC_ANGLE_END: |
6067 | tempf = (float)rules.GetLSLFloatItem(i + 1); | 6072 | tempf = (float)rules.GetLSLFloatItem(i + 1); |
6068 | prules.OuterAngle = (float)tempf; | 6073 | prules.OuterAngle = (float)tempf; |
6074 | prules.PartFlags |= 0x02; // Set new angle format. | ||
6069 | break; | 6075 | break; |
6070 | } | 6076 | } |
6071 | 6077 | ||