Fix singularity overlay mouse position correction when zooming (#30509)

fix singularity overlay mouse position correction when zooming
This commit is contained in:
slarticodefast
2024-07-31 02:14:49 +02:00
committed by GitHub
parent 524dad566b
commit 0ceb99df1c

View File

@@ -100,6 +100,8 @@ namespace Content.Client.Singularity
/// </summary> /// </summary>
private void OnProjectFromScreenToMap(ref PixelToMapEvent args) private void OnProjectFromScreenToMap(ref PixelToMapEvent args)
{ // Mostly copypasta from the singularity shader. { // Mostly copypasta from the singularity shader.
if (args.Viewport.Eye == null)
return;
var maxDistance = MaxDistance * EyeManager.PixelsPerMeter; var maxDistance = MaxDistance * EyeManager.PixelsPerMeter;
var finalCoords = args.VisiblePosition; 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. // 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. // 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. // 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]; var localPosition = _positions[i];
localPosition.Y = args.Viewport.Size.Y - localPosition.Y; localPosition.Y = args.Viewport.Size.Y - localPosition.Y;
var delta = args.VisiblePosition - localPosition; 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]); var deformation = _intensities[i] / MathF.Pow(distance, _falloffPowers[i]);