From a148f3007046b5dacb057541c1f4d2fc6d7dc627 Mon Sep 17 00:00:00 2001 From: Gustas Date: Sat, 2 Sep 2023 14:27:38 +0300 Subject: [PATCH] Simplify matrix utils --- OpenRA.Game/Graphics/Util.cs | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/OpenRA.Game/Graphics/Util.cs b/OpenRA.Game/Graphics/Util.cs index 925f48b24c..7e376cce70 100644 --- a/OpenRA.Game/Graphics/Util.cs +++ b/OpenRA.Game/Graphics/Util.cs @@ -308,25 +308,35 @@ namespace OpenRA.Graphics public static float[] IdentityMatrix() { - return Exts.MakeArray(16, j => (j % 5 == 0) ? 1.0f : 0); + return new float[] + { + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1, + }; } public static float[] ScaleMatrix(float sx, float sy, float sz) { - var mtx = IdentityMatrix(); - mtx[0] = sx; - mtx[5] = sy; - mtx[10] = sz; - return mtx; + return new float[] + { + sx, 0, 0, 0, + 0, sy, 0, 0, + 0, 0, sz, 0, + 0, 0, 0, 1, + }; } public static float[] TranslationMatrix(float x, float y, float z) { - var mtx = IdentityMatrix(); - mtx[12] = x; - mtx[13] = y; - mtx[14] = z; - return mtx; + return new float[] + { + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + x, y, z, 1, + }; } public static float[] MatrixMultiply(float[] lhs, float[] rhs)