diff options
5 files changed, 72 insertions, 1 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 7494b88..ebd281e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -5554,5 +5554,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5554 | DateTime time = TimeZoneInfo.ConvertTime(DateTime.UtcNow, PSTTimeZone); | 5554 | DateTime time = TimeZoneInfo.ConvertTime(DateTime.UtcNow, PSTTimeZone); |
5555 | return time.TimeOfDay.TotalSeconds; | 5555 | return time.TimeOfDay.TotalSeconds; |
5556 | } | 5556 | } |
5557 | |||
5558 | public LSL_Rotation osSlerp(LSL_Rotation a, LSL_Rotation b, LSL_Float amount) | ||
5559 | { | ||
5560 | if(amount < 0) | ||
5561 | amount= 0; | ||
5562 | else if(amount > 1.0) | ||
5563 | amount = 1.0; | ||
5564 | a.Normalize(); | ||
5565 | b.Normalize(); | ||
5566 | |||
5567 | return LSL_Rotation.Slerp(a, b, amount); | ||
5568 | } | ||
5557 | } | 5569 | } |
5558 | } \ No newline at end of file | 5570 | } \ No newline at end of file |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 1bd6e08..369b361 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -36,6 +36,7 @@ using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | |||
36 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | 36 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; |
37 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | 37 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; |
38 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | 38 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; |
39 | using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
39 | using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | 40 | using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; |
40 | 41 | ||
41 | 42 | ||
@@ -554,5 +555,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
554 | LSL_String osGetInventoryDesc(LSL_String itemNameOrId); | 555 | LSL_String osGetInventoryDesc(LSL_String itemNameOrId); |
555 | LSL_Key osGetLastChangedEventKey(); | 556 | LSL_Key osGetLastChangedEventKey(); |
556 | LSL_Float osGetPSTWallclock(); | 557 | LSL_Float osGetPSTWallclock(); |
558 | LSL_Rotation osSlerp(LSL_Rotation a, LSL_Rotation b, LSL_Float amount); | ||
557 | } | 559 | } |
558 | } | 560 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 3f880e4..7edda58 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | |||
@@ -35,7 +35,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
35 | public partial class ScriptBaseClass | 35 | public partial class ScriptBaseClass |
36 | { | 36 | { |
37 | // SCRIPTS CONSTANTS | 37 | // SCRIPTS CONSTANTS |
38 | public static readonly LSLInteger OS_APIVERSION = 7; | 38 | public static readonly LSLInteger OS_APIVERSION = 8; |
39 | 39 | ||
40 | public static readonly LSLInteger TRUE = 1; | 40 | public static readonly LSLInteger TRUE = 1; |
41 | public static readonly LSLInteger FALSE = 0; | 41 | public static readonly LSLInteger FALSE = 0; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 549047c..866a955 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | |||
@@ -1407,5 +1407,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
1407 | return m_OSSL_Functions.osGetPSTWallclock(); | 1407 | return m_OSSL_Functions.osGetPSTWallclock(); |
1408 | } | 1408 | } |
1409 | 1409 | ||
1410 | public rotation osSlerp(rotation a, rotation b, LSL_Float amount) | ||
1411 | { | ||
1412 | return m_OSSL_Functions.osSlerp(a, b, amount); | ||
1413 | } | ||
1414 | |||
1410 | } | 1415 | } |
1411 | } | 1416 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index b52f767..40e8204 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | |||
@@ -434,6 +434,58 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
434 | 434 | ||
435 | return this; | 435 | return this; |
436 | } | 436 | } |
437 | |||
438 | public static Quaternion Slerp(Quaternion q1, Quaternion q2, double amount) | ||
439 | { | ||
440 | double angle = (q1.x * q2.x) + (q1.y * q2.y) + (q1.z * q2.z) + (q1.s * q2.s); | ||
441 | |||
442 | if (angle < 0f) | ||
443 | { | ||
444 | q1.x = -q1.x; | ||
445 | q1.y = -q1.y; | ||
446 | q1.z = -q1.z; | ||
447 | q1.s = -q1.s; | ||
448 | angle *= -1.0; | ||
449 | } | ||
450 | |||
451 | double scale; | ||
452 | double invscale; | ||
453 | |||
454 | if ((angle + 1f) > 0.05f) | ||
455 | { | ||
456 | if ((1f - angle) >= 0.05f) | ||
457 | { | ||
458 | // slerp | ||
459 | double theta = Math.Acos(angle); | ||
460 | double invsintheta = 1.0 / Math.Sin(theta); | ||
461 | scale = Math.Sin(theta * (1.0 - amount)) * invsintheta; | ||
462 | invscale = Math.Sin(theta * amount) * invsintheta; | ||
463 | } | ||
464 | else | ||
465 | { | ||
466 | // lerp | ||
467 | scale = 1.0 - amount; | ||
468 | invscale = amount; | ||
469 | } | ||
470 | } | ||
471 | else | ||
472 | { | ||
473 | q2.x = -q1.y; | ||
474 | q2.y = q1.x; | ||
475 | q2.z = -q1.s; | ||
476 | q2.s = q1.z; | ||
477 | |||
478 | scale = Math.Sin(Math.PI * (0.5 - amount)); | ||
479 | invscale = Math.Sin(Math.PI * amount); | ||
480 | } | ||
481 | |||
482 | return new Quaternion( | ||
483 | q1.x * scale + q2.x * invscale, | ||
484 | q1.y * scale + q2.y * invscale, | ||
485 | q1.z * scale + q2.z * invscale, | ||
486 | q1.s * scale + q2.s * invscale | ||
487 | ); | ||
488 | } | ||
437 | #endregion | 489 | #endregion |
438 | 490 | ||
439 | #region Overriders | 491 | #region Overriders |