From a3b26255dd1f44f69b2b0bfb3ad5904c492f9b3e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 6 Jan 2021 16:32:51 +0000 Subject: [PATCH] add vector variant of osSlerp; update script syntax --- .../Shared/Api/Implementation/OSSL_Api.cs | 10 +++ .../Shared/Api/Interface/IOSSL_Api.cs | 1 + .../Shared/Api/Runtime/LSL_Constants.cs | 2 +- .../Shared/Api/Runtime/OSSL_Stub.cs | 5 ++ .../Region/ScriptEngine/Shared/LSL_Types.cs | 24 +++++ bin/ScriptSyntax.xml | 89 ++++++++++--------- 6 files changed, 90 insertions(+), 41 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index cf82a071d5..a1c6352832 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -5647,6 +5647,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return LSL_Rotation.Slerp(a, b, amount); } + public LSL_Vector osSlerp(LSL_Vector a, LSL_Vector b, LSL_Float amount) + { + if (amount < 0) + amount = 0; + else if (amount > 1.0) + amount = 1.0; + + return LSL_Vector.Slerp(a, b, amount); + } + public void osResetAllScripts(LSL_Integer linkset) { UUID me = m_item.ItemID; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 5e7bb9a659..3534508b95 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -561,6 +561,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_Key osGetLastChangedEventKey(); LSL_Float osGetPSTWallclock(); LSL_Rotation osSlerp(LSL_Rotation a, LSL_Rotation b, LSL_Float amount); + vector osSlerp(vector a, vector b, LSL_Float amount); void osResetAllScripts(LSL_Integer AllLinkset); LSL_Integer osIsNotValidNumber(LSL_Float v); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 7eb061c937..4a81a88a59 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 public partial class ScriptBaseClass { // SCRIPTS CONSTANTS - public static readonly LSLInteger OS_APIVERSION = 15; + public static readonly LSLInteger OS_APIVERSION = 16; public static readonly LSLInteger TRUE = 1; 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 48c207d28e..088e890143 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -1432,6 +1432,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osSlerp(a, b, amount); } + public vector osSlerp(vector a, vector b, LSL_Float amount) + { + return m_OSSL_Functions.osSlerp(a, b, amount); + } + public void osResetAllScripts(LSL_Integer allLinkSet) { m_OSSL_Functions.osResetAllScripts(allLinkSet); diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index b04a32c4da..fdf9da3cd1 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs @@ -366,6 +366,30 @@ namespace OpenSim.Region.ScriptEngine.Shared return new Vector3(0, 0, 0); } + public static Vector3 Slerp(Vector3 v1, Vector3 v2, double amount) + { + double angle = (v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z); + double scale; + double invscale; + + if (angle < 0.999f) + { + angle = Math.Acos(angle); + invscale = 1.0f / Math.Sin(angle); + scale = Math.Sin((1.0f - amount) * angle) * invscale; + invscale *= Math.Sin((amount * angle)); + } + else + { + scale = 1.0f - amount; + invscale = amount; + } + return new Vector3( + v1.x * scale + v2.x * invscale, + v1.y * scale + v2.y * invscale, + v1.z * scale + v2.z * invscale + ); + } #endregion } diff --git a/bin/ScriptSyntax.xml b/bin/ScriptSyntax.xml index ae497c0b55..ffbbe67658 100644 --- a/bin/ScriptSyntax.xml +++ b/bin/ScriptSyntax.xml @@ -1,4 +1,4 @@ -0ca3945b-ad46-5155-6d66-6b6c74370dd2 +cd5e081a-b88a-07b6-21a5-612aab0b3398 llsd-lsl-syntax-version2 controls @@ -1111,6 +1111,10 @@ typeinteger value10 + INVENTORY_SETTING + typeinteger + value56 + INVENTORY_SOUND typeinteger value1 @@ -1577,7 +1581,7 @@ OS_APIVERSION typeinteger - value15 + value16 OS_ATTACH_MSG_ALL typeinteger @@ -6225,6 +6229,14 @@ offsettypevector + llXorBase64 + + returnstring + arguments + str1typestring + str2typestring + + llXorBase64Strings returnstring @@ -7143,6 +7155,7 @@ nametypestring positiontypevector notecardtypestring + optionstypeinteger osNpcCreate @@ -7153,7 +7166,6 @@ nametypestring positiontypevector notecardtypestring - optionstypeinteger osNpcGetOwner @@ -7330,7 +7342,6 @@ returnkey arguments notecardtypestring - includeHudstypeinteger osOwnerSaveAppearance @@ -7338,6 +7349,7 @@ returnkey arguments notecardtypestring + includeHudstypeinteger osParcelJoin @@ -7410,6 +7422,7 @@ returninteger arguments secondstypefloat + msgtypestring osRegionRestart @@ -7417,7 +7430,6 @@ returninteger arguments secondstypefloat - msgtypestring osReplaceAgentEnvironment @@ -7437,19 +7449,6 @@ daycycletypestring - osReplaceRegionEnvironment - - returninteger - arguments - transitiontypeinteger - daycycletypestring - daylentypefloat - dayoffsettypefloat - altitude1typefloat - altitude2typefloat - altitude3typefloat - - osReplaceString returnstring @@ -7703,6 +7702,17 @@ osSetProjectionParams + + arguments + primtypekey + projectiontypeinteger + texturetypekey + fovtypefloat + focustypefloat + ambtypefloat + + + osSetProjectionParams arguments projectiontypeinteger @@ -7723,17 +7733,6 @@ ambtypefloat - osSetProjectionParams - - arguments - primtypekey - projectiontypeinteger - texturetypekey - fovtypefloat - focustypefloat - ambtypefloat - - osSetRegionSunSettings arguments @@ -7774,12 +7773,6 @@ vtypevector - osSetStateEvents - - arguments - eventstypeinteger - - osSetSunParam arguments @@ -7819,6 +7812,22 @@ valuetypefloat + osSHA256 + + returnstring + arguments + inputtypestring + + + osSlerp + + returnvector + arguments + atypevector + btypevector + amounttypefloat + + osSlerp returnrotation @@ -7953,8 +7962,7 @@ arguments agenttypestring - regionXtypeinteger - regionYtypeinteger + regionNametypestring positiontypevector lookattypevector @@ -7963,7 +7971,8 @@ arguments agenttypestring - regionNametypestring + regionXtypeinteger + regionYtypeinteger positiontypevector lookattypevector @@ -7981,8 +7990,6 @@ osTeleportOwner arguments - regionXtypeinteger - regionYtypeinteger positiontypevector lookattypevector @@ -7990,6 +7997,8 @@ osTeleportOwner arguments + regionXtypeinteger + regionYtypeinteger positiontypevector lookattypevector