From 15dc813fae696f75e7ef5bfb5fd63b273f8b2cec Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 17 Aug 2025 01:23:44 +0100 Subject: [PATCH] some changes to llWorldPosToHUD. May need more (ofc it is opensim) --- .../Shared/Api/Implementation/LSL_Api.cs | 68 ++++++++++--------- bin/OpenSim.ini.example | 2 +- 2 files changed, 37 insertions(+), 33 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index aed5289851..d1cda84db8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -19629,44 +19629,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if(sp is null) return LSL_Vector.Zero; + int h = sp.ControllingClient.viewHeight; + float aspect = h > 0 ?(float)sp.ControllingClient.viewWidth / h : 1f; + Vector3 totarget = (Vector3)wp - sp.CameraPosition; - totarget.Normalize(); float at = totarget.Dot(sp.CameraAtAxis); float left = totarget.Dot(sp.CameraLeftAxis); float up = totarget.Dot(sp.CameraUpAxis); - if(atp != (uint)AttachmentPoint.HUDCenter2 && atp != (uint)AttachmentPoint.HUDCenter2) + float fov = at * MathF.Tan((float)sp.ControllingClient.FOV * 0.5f); + if(fov > 0) { - int h = sp.ControllingClient.viewHeight; - if(h > 0) - { - float aspect = 0.5f * (float)sp.ControllingClient.viewWidth / h; - switch(atp) - { - case (uint)AttachmentPoint.HUDTop: - up -= 0.5f; - break; - case (uint)AttachmentPoint.HUDTopLeft: - up -= 0.5f; - left -= aspect; - break; - case (uint)AttachmentPoint.HUDTopRight: - up -= 0.5f; - left += aspect; - break; - case (uint)AttachmentPoint.HUDBottom: - up += 0.5f; - break; - case (uint)AttachmentPoint.HUDBottomLeft: - up += 0.5f; - left -= aspect; - break; - case (uint)AttachmentPoint.HUDBottomRight: - up += 0.5f; - left += aspect; - break; - } - } + fov = 0.45f / fov; + left *= fov; + up *= fov; + } + + switch(atp) + { + case (uint)AttachmentPoint.HUDTop: + up -= 0.5f; + break; + case (uint)AttachmentPoint.HUDTopLeft: + up -= 0.5f; + left -= 0.5f * aspect; + break; + case (uint)AttachmentPoint.HUDTopRight: + up -= 0.5f; + left += 0.5f * aspect; + break; + case (uint)AttachmentPoint.HUDBottom: + up += 0.5f; + break; + case (uint)AttachmentPoint.HUDBottomLeft: + up += 0.5f; + left -= 0.5f * aspect; + break; + case (uint)AttachmentPoint.HUDBottomRight: + up += 0.5f; + left += 0.5f * aspect; + break; + default: + break; } return new(at > 0 ? 1 : -1, left, up); } diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index dbf67c4724..769c163bf7 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -245,7 +245,7 @@ ;; ZeroMesher is faster but leaves the physics engine to model the mesh ;; using the basic shapes that it supports. ;; Usually this is only a box or a sphere - ;; Default is Meshmerizer + ;; Default is ubODEMeshmerizer ; meshing = Meshmerizer ; meshing = ZeroMesher ;; With ubOde physics engine you must select ubODEMeshmerizer