Corrects for singularity distortion. (#13925)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user