diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index f806da496c..965e68eacc 100755 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -648,6 +648,9 @@ namespace OpenSim.Framework { Vector3 StartPos { get; set; } float StartFar { get; set; } + float FOV { get; set; } + int viewHeight { get; set; } + int viewWidth { get; set; } UUID AgentId { get; } diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 2e5fdc3926..9742de1a38 100755 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -385,7 +385,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP protected Dictionary m_groupPowers = new(); protected int m_terrainCheckerCount; protected uint m_agentFOVCounter; - + protected IAssetService m_assetService; protected bool m_supportViewerCache = false; @@ -405,6 +405,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP set { m_startpos = value; } } public float StartFar { get; set; } + public float FOV { get; set; } = 1.25f; + public int viewHeight { get; set; } = 480; + public int viewWidth { get; set; } = 640; + public UUID AgentId { get { return m_agentId; } } public UUID ScopeId { get { return m_scopeId; } } @@ -11595,7 +11599,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (genCounter == 0 || genCounter > m_agentFOVCounter) { m_agentFOVCounter = genCounter; - OnAgentFOV?.Invoke(this, fovPacket.FOVBlock.VerticalAngle); + FOV = fovPacket.FOVBlock.VerticalAngle; + OnAgentFOV?.Invoke(this, FOV); } } @@ -11751,6 +11756,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP private void HandleAgentHeightWidth(Packet Pack) { + AgentHeightWidthPacket hwPacket = (AgentHeightWidthPacket)Pack; + if (hwPacket.AgentData.AgentID.NotEqual(m_agentId) || hwPacket.AgentData.SessionID.NotEqual(m_sessionId)) + return; + + viewHeight = hwPacket.HeightWidthBlock.Height; + viewWidth = hwPacket.HeightWidthBlock.Width; } diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 6ab9d43e95..dcb366e233 100755 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -525,7 +525,9 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server } public float StartFar { get; set; } - + public float FOV { get; set; } = 1.25f; + public int viewHeight { get; set; } = 480; + public int viewWidth { get; set; } = 640; public bool TryGet(out T iface) { iface = default(T); diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 22efe75039..068e28530c 100755 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -567,6 +567,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC } public float StartFar { get; set; } + public float FOV { get; set; } = 1.25f; + public int viewHeight { get; set; } = 480; + public int viewWidth { get; set; } = 640; public virtual UUID AgentId { diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index b305802228..0b3134a7f6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -13339,6 +13339,45 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return LSL_Rotation.Identity; } + public LSL_Float llGetCameraFOV() + { + if (m_item.PermsGranter.IsZero()) + return LSL_Float.Zero; + + if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) + { + Error("llGetCameraAspect", "No permissions to track the camera"); + return LSL_Float.Zero; + } + + ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); + if (presence is not null && presence.ControllingClient is not null) + { + return new LSL_Float(presence.ControllingClient.FOV); + } + return 1.4f; + } + + public LSL_Float llGetCameraAspect() + { + if (m_item.PermsGranter.IsZero()) + return 1f; + + if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) + { + Error("llGetCameraAspect", "No permissions to track the camera"); + return 1f; + } + + ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); + if (presence is not null && presence.ControllingClient is not null) + { + int h = presence.ControllingClient.viewHeight; + return new LSL_Float(h > 0 ? (float)presence.ControllingClient.viewWidth / h : 1.0f); + } + return 1f; + } + public void llSetPrimURL(string url) { Deprecated("llSetPrimURL", "Use llSetPrimMediaParams instead"); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index dbe822a5d0..fb6f2c58ff 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs @@ -129,6 +129,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_Integer llGetAttached(); LSL_List llGetAttachedList(LSL_Key id); LSL_List llGetBoundingBox(string obj); + LSL_Float llGetCameraAspect(); + LSL_Float llGetCameraFOV(); LSL_Vector llGetCameraPos(); LSL_Rotation llGetCameraRot(); LSL_Vector llGetCenterOfMass(); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index ed392758b5..ccda2911f4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs @@ -512,6 +512,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_LSL_Functions.llGetBoundingBox(obj); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public LSL_Float llGetCameraAspect() + { + return m_LSL_Functions.llGetCameraAspect(); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public LSL_Float llGetCameraFOV() + { + return m_LSL_Functions.llGetCameraFOV(); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public LSL_Vector llGetCameraPos() { diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 307117638b..4284c5304a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs @@ -1398,6 +1398,10 @@ namespace OpenSim.Region.ScriptEngine.Shared LSLString r = (LSLString)right; ret = string.CompareOrdinal(lsl.m_string, r.m_string); } + else if (left is string ssl) + { + ret = string.CompareOrdinal(ssl, right as string); + } else if (left is LSLFloat fl) { LSLFloat r = (LSLFloat)right; @@ -1418,10 +1422,7 @@ namespace OpenSim.Region.ScriptEngine.Shared return 0; } - if (ascending) - return ret; - - return -ret; + return ascending ? ret : -ret; } class HomogeneousComparer : IComparer @@ -1449,6 +1450,10 @@ namespace OpenSim.Region.ScriptEngine.Shared LSLString r = (LSLString)right; ret = string.CompareOrdinal(lsl.m_string, r.m_string); } + else if (left is string ssl) + { + ret = string.CompareOrdinal(ssl, right as string); + } else if (left is LSLFloat fl) { LSLFloat r = (LSLFloat)right; @@ -1491,6 +1496,10 @@ namespace OpenSim.Region.ScriptEngine.Shared LSLString r = (LSLString)right; return string.CompareOrdinal(lsl.m_string, r.m_string) > 0; } + else if (left is string ssl) + { + return string.CompareOrdinal(ssl, right as string) > 0; + } if (left is LSLFloat lf) { LSLFloat r = (LSLFloat)right; @@ -1524,6 +1533,11 @@ namespace OpenSim.Region.ScriptEngine.Shared LSLString r = (LSLString)right; return string.CompareOrdinal(lsl.m_string, r.m_string) < 0; } + else if (left is string ssl) + { + string sr = right as string; + return string.CompareOrdinal(ssl, sr) < 0; + } if (left is LSLFloat lf) { LSLFloat r = (LSLFloat)right; diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRDelegateCommon.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRDelegateCommon.cs index 041d11ab92..bdbd259513 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRDelegateCommon.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRDelegateCommon.cs @@ -97,7 +97,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine { Name = "CustomDelegateAssembly" }; - AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(assembly, AssemblyBuilderAccess.Run); + AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(assembly, AssemblyBuilderAccess.RunAndCollect); delegateModuleBuilder = assemblyBuilder.DefineDynamicModule("CustomDelegateModule"); } diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptObjCode.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptObjCode.cs index bbdec99e18..b72806f138 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptObjCode.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptObjCode.cs @@ -163,8 +163,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } finally { - if(objectTokens != null) - objectTokens.Close(); + objectTokens?.Close(); } // We enter all script event handler methods in the ScriptEventHandler table. diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptObjWriter.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptObjWriter.cs index de214e5997..0fda5338a0 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptObjWriter.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptObjWriter.cs @@ -64,11 +64,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine private static readonly Dictionary string2Type = PopulateS2T(); private static readonly Dictionary type2String = PopulateT2S(); - private static readonly MethodInfo monoGetCurrentOffset = typeof(ILGenerator).GetMethod("Mono_GetCurrentOffset", - BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, - new Type[] { typeof(ILGenerator) }, null); - - private static readonly OpCode[] opCodesLdcI4M1P8 = new OpCode[] { + private static readonly OpCode[] opCodesLdcI4M1P8 = new OpCode[] + { OpCodes.Ldc_I4_M1, OpCodes.Ldc_I4_0, OpCodes.Ldc_I4_1, OpCodes.Ldc_I4_2, OpCodes.Ldc_I4_3, OpCodes.Ldc_I4_4, OpCodes.Ldc_I4_5, OpCodes.Ldc_I4_6, OpCodes.Ldc_I4_7, OpCodes.Ldc_I4_8 }; @@ -394,11 +391,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine while(true) { // Get IL instruction offset at beginning of instruction. - offset = 0; - if((ilGen != null) && (monoGetCurrentOffset != null)) - { - offset = (int)monoGetCurrentOffset.Invoke(null, ilGenArg); - } + offset = ilGen is null ? 0 : ilGen.ILOffset; // Read and decode next internal format code from input file (.xmrobj file). ScriptObjWriterCode code = (ScriptObjWriterCode)objReader.ReadByte();