Replace Matrix3 with System.Numerics.Matrix3x2 (#27443)

Replace Matrix3 with Matrix3x2
This commit is contained in:
eoineoineoin
2024-06-02 05:07:41 +01:00
committed by GitHub
parent 21d0b1fd55
commit b44b159431
58 changed files with 236 additions and 215 deletions

View File

@@ -25,7 +25,7 @@ public sealed class ExplosionDebugOverlay : Overlay
public override OverlaySpace Space => OverlaySpace.WorldSpace | OverlaySpace.ScreenSpace;
public Matrix3 SpaceMatrix;
public Matrix3x2 SpaceMatrix;
public MapId Map;
private readonly Font _font;
@@ -78,7 +78,8 @@ public sealed class ExplosionDebugOverlay : Overlay
if (SpaceTiles == null)
return;
gridBounds = Matrix3.Invert(SpaceMatrix).TransformBox(args.WorldBounds);
Matrix3x2.Invert(SpaceMatrix, out var invSpace);
gridBounds = invSpace.TransformBox(args.WorldBounds);
DrawText(handle, gridBounds, SpaceMatrix, SpaceTiles, SpaceTileSize);
}
@@ -86,7 +87,7 @@ public sealed class ExplosionDebugOverlay : Overlay
private void DrawText(
DrawingHandleScreen handle,
Box2 gridBounds,
Matrix3 transform,
Matrix3x2 transform,
Dictionary<int, List<Vector2i>> tileSets,
ushort tileSize)
{
@@ -103,7 +104,7 @@ public sealed class ExplosionDebugOverlay : Overlay
if (!gridBounds.Contains(centre))
continue;
var worldCenter = transform.Transform(centre);
var worldCenter = Vector2.Transform(centre, transform);
var screenCenter = _eyeManager.WorldToScreen(worldCenter);
@@ -119,7 +120,7 @@ public sealed class ExplosionDebugOverlay : Overlay
if (tileSets.TryGetValue(0, out var set))
{
var epicenter = set.First();
var worldCenter = transform.Transform((epicenter + Vector2Helpers.Half) * tileSize);
var worldCenter = Vector2.Transform((epicenter + Vector2Helpers.Half) * tileSize, transform);
var screenCenter = _eyeManager.WorldToScreen(worldCenter) + new Vector2(-24, -24);
var text = $"{Intensity[0]:F2}\nΣ={TotalIntensity:F1}\nΔ={Slope:F1}";
handle.DrawString(_font, screenCenter, text);
@@ -148,11 +149,12 @@ public sealed class ExplosionDebugOverlay : Overlay
if (SpaceTiles == null)
return;
gridBounds = Matrix3.Invert(SpaceMatrix).TransformBox(args.WorldBounds).Enlarged(2);
Matrix3x2.Invert(SpaceMatrix, out var invSpace);
gridBounds = invSpace.TransformBox(args.WorldBounds).Enlarged(2);
handle.SetTransform(SpaceMatrix);
DrawTiles(handle, gridBounds, SpaceTiles, SpaceTileSize);
handle.SetTransform(Matrix3.Identity);
handle.SetTransform(Matrix3x2.Identity);
}
private void DrawTiles(