use matrix CreateTransform (#8687)

This commit is contained in:
Leon Friedrich
2022-06-07 14:14:22 +12:00
committed by GitHub
parent c3e23394ae
commit 22aaf801be

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using Robust.Client.Graphics;
using Robust.Client.Input;
@@ -276,14 +276,11 @@ namespace Content.Client.Viewport
var drawBox = GetDrawBox();
var scaleFactor = drawBox.Size / (Vector2) _viewport!.Size;
if (scaleFactor == (0, 0))
if (scaleFactor.X == 0 || scaleFactor.Y == 0)
// Basically a nonsense scenario, at least make sure to return something that can be inverted.
return Matrix3.Identity;
var scale = Matrix3.CreateScale(scaleFactor);
var translate = Matrix3.CreateTranslation(GlobalPixelPosition + drawBox.TopLeft);
return scale * translate;
return Matrix3.CreateTransform(GlobalPixelPosition + drawBox.TopLeft, 0, scaleFactor);
}
private void EnsureViewportCreated()