]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix singularity overlay mouse position correction when zooming (#30509)
authorslarticodefast <161409025+slarticodefast@users.noreply.github.com>
Wed, 31 Jul 2024 00:14:49 +0000 (02:14 +0200)
committerGitHub <noreply@github.com>
Wed, 31 Jul 2024 00:14:49 +0000 (10:14 +1000)
fix singularity overlay mouse position correction when zooming

Content.Client/Singularity/SingularityOverlay.cs

index c7c6aa2b5b4f4c4d3c59f24c496caa1f6838f491..e71b6e96b8506df168a3f2f69237634245588379 100644 (file)
@@ -100,6 +100,8 @@ namespace Content.Client.Singularity
         /// </summary>
         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]);