diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-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 c5226ba..f3f7269 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: |
@@ -5874,6 +5860,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5874 | PSYS_PART_MAX_AGE = 7, | 5860 | PSYS_PART_MAX_AGE = 7, |
5875 | PSYS_SRC_ACCEL = 8, | 5861 | PSYS_SRC_ACCEL = 8, |
5876 | PSYS_SRC_PATTERN = 9, | 5862 | PSYS_SRC_PATTERN = 9, |
5863 | PSYS_SRC_INNERANGLE = 10, | ||
5864 | PSYS_SRC_OUTERANGLE = 11, | ||
5877 | PSYS_SRC_TEXTURE = 12, | 5865 | PSYS_SRC_TEXTURE = 12, |
5878 | PSYS_SRC_BURST_RATE = 13, | 5866 | PSYS_SRC_BURST_RATE = 13, |
5879 | PSYS_SRC_BURST_PART_COUNT = 15, | 5867 | PSYS_SRC_BURST_PART_COUNT = 15, |
@@ -6006,6 +5994,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6006 | prules.Pattern = (Primitive.ParticleSystem.SourcePattern)tmpi; | 5994 | prules.Pattern = (Primitive.ParticleSystem.SourcePattern)tmpi; |
6007 | break; | 5995 | break; |
6008 | 5996 | ||
5997 | // PSYS_SRC_INNERANGLE and PSYS_SRC_ANGLE_BEGIN use the same variables. The | ||
5998 | // PSYS_SRC_OUTERANGLE and PSYS_SRC_ANGLE_END also use the same variable. The | ||
5999 | // client tells the difference between the two by looking at the 0x02 bit in | ||
6000 | // the PartFlags variable. | ||
6001 | case (int)ScriptBaseClass.PSYS_SRC_INNERANGLE: | ||
6002 | tempf = (float)rules.GetLSLFloatItem(i + 1); | ||
6003 | prules.InnerAngle = (float)tempf; | ||
6004 | prules.PartFlags &= 0xFFFFFFFD; // Make sure new angle format is off. | ||
6005 | break; | ||
6006 | |||
6007 | case (int)ScriptBaseClass.PSYS_SRC_OUTERANGLE: | ||
6008 | tempf = (float)rules.GetLSLFloatItem(i + 1); | ||
6009 | prules.OuterAngle = (float)tempf; | ||
6010 | prules.PartFlags &= 0xFFFFFFFD; // Make sure new angle format is off. | ||
6011 | break; | ||
6012 | |||
6009 | case (int)ScriptBaseClass.PSYS_SRC_TEXTURE: | 6013 | case (int)ScriptBaseClass.PSYS_SRC_TEXTURE: |
6010 | prules.Texture = KeyOrName(rules.GetLSLStringItem(i + 1)); | 6014 | prules.Texture = KeyOrName(rules.GetLSLStringItem(i + 1)); |
6011 | break; | 6015 | break; |
@@ -6062,11 +6066,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6062 | case (int)ScriptBaseClass.PSYS_SRC_ANGLE_BEGIN: | 6066 | case (int)ScriptBaseClass.PSYS_SRC_ANGLE_BEGIN: |
6063 | tempf = (float)rules.GetLSLFloatItem(i + 1); | 6067 | tempf = (float)rules.GetLSLFloatItem(i + 1); |
6064 | prules.InnerAngle = (float)tempf; | 6068 | prules.InnerAngle = (float)tempf; |
6069 | prules.PartFlags |= 0x02; // Set new angle format. | ||
6065 | break; | 6070 | break; |
6066 | 6071 | ||
6067 | case (int)ScriptBaseClass.PSYS_SRC_ANGLE_END: | 6072 | case (int)ScriptBaseClass.PSYS_SRC_ANGLE_END: |
6068 | tempf = (float)rules.GetLSLFloatItem(i + 1); | 6073 | tempf = (float)rules.GetLSLFloatItem(i + 1); |
6069 | prules.OuterAngle = (float)tempf; | 6074 | prules.OuterAngle = (float)tempf; |
6075 | prules.PartFlags |= 0x02; // Set new angle format. | ||
6070 | break; | 6076 | break; |
6071 | } | 6077 | } |
6072 | 6078 | ||