From 0ceb99df1ce435bf238f8fdbb4464e6c3b2d6446 Mon Sep 17 00:00:00 2001 From: slarticodefast <161409025+slarticodefast@users.noreply.github.com> Date: Wed, 31 Jul 2024 02:14:49 +0200 Subject: [PATCH] Fix singularity overlay mouse position correction when zooming (#30509) fix singularity overlay mouse position correction when zooming --- Content.Client/Singularity/SingularityOverlay.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Content.Client/Singularity/SingularityOverlay.cs b/Content.Client/Singularity/SingularityOverlay.cs index c7c6aa2b5b..e71b6e96b8 100644 --- a/Content.Client/Singularity/SingularityOverlay.cs +++ b/Content.Client/Singularity/SingularityOverlay.cs @@ -100,6 +100,8 @@ namespace Content.Client.Singularity /// private void OnProjectFromScreenToMap(ref PixelToMapEvent args) { // Mostly copypasta from the singularity shader. + if (args.Viewport.Eye == null) + return; var maxDistance = MaxDistance * EyeManager.PixelsPerMeter; var finalCoords = args.VisiblePosition; @@ -112,10 +114,11 @@ namespace Content.Client.Singularity // and in local space 'Y' is measured in pixels from the top of the viewport. // As a minor optimization the locations of the singularities are transformed into fragment space in BeforeDraw so the shader doesn't need to. // We need to undo that here or this will transform the cursor position as if the singularities were mirrored vertically relative to the center of the viewport. + var localPosition = _positions[i]; localPosition.Y = args.Viewport.Size.Y - localPosition.Y; var delta = args.VisiblePosition - localPosition; - var distance = (delta / args.Viewport.RenderScale).Length(); + var distance = (delta / (args.Viewport.RenderScale * args.Viewport.Eye.Scale)).Length(); var deformation = _intensities[i] / MathF.Pow(distance, _falloffPowers[i]);