Corrects for singularity distortion. (#13925)

This commit is contained in:
TemporalOroboros
2023-08-12 16:43:07 -07:00
committed by GitHub
parent f3c319df4b
commit 3b02d461a2
17 changed files with 96 additions and 26 deletions

View File

@@ -21,6 +21,7 @@ namespace Content.Client.Viewport
public sealed class ScalingViewport : Control, IViewportControl
{
[Dependency] private readonly IClyde _clyde = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IInputManager _inputManager = default!;
// Internal viewport creation is deferred.
@@ -252,8 +253,26 @@ namespace Content.Client.Viewport
EnsureViewportCreated();
var matrix = Matrix3.Invert(GetLocalToScreenMatrix());
coords = matrix.Transform(coords);
return _viewport!.LocalToWorld(matrix.Transform(coords));
return _viewport!.LocalToWorld(coords);
}
/// <inheritdoc/>
public MapCoordinates PixelToMap(Vector2 coords)
{
if (_eye == null)
return default;
EnsureViewportCreated();
var matrix = Matrix3.Invert(GetLocalToScreenMatrix());
coords = matrix.Transform(coords);
var ev = new PixelToMapEvent(coords, this, _viewport!);
_entityManager.EventBus.RaiseEvent(EventSource.Local, ref ev);
return _viewport!.LocalToWorld(ev.VisiblePosition);
}
public Vector2 WorldToScreen(Vector2 map)