Index: source/gui/ObjectTypes/CMiniMap.cpp =================================================================== --- source/gui/ObjectTypes/CMiniMap.cpp +++ source/gui/ObjectTypes/CMiniMap.cpp @@ -608,7 +608,7 @@ // Move the minimap to it's final location. unitMatrix.Translate(x, y, 0.0f); // Apply the gui matrix. - unitMatrix *= GetDefaultGuiMatrix(); + unitMatrix.Concatenate(GetDefaultGuiMatrix()); // Load the transform into the shader. shader->Uniform(str_transform, unitMatrix); Index: source/maths/Matrix3D.h =================================================================== --- source/maths/Matrix3D.h +++ source/maths/Matrix3D.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -126,8 +126,7 @@ // matrix multiplication/assignment CMatrix3D& operator*=(const CMatrix3D &matrix) { - Concatenate(matrix); - return *this; + return *this = *this * matrix; } // matrix scaling Index: source/maths/tests/test_Matrix3d.h =================================================================== --- source/maths/tests/test_Matrix3d.h +++ source/maths/tests/test_Matrix3d.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2011 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -50,6 +50,54 @@ } } + void test_compoundMultiplication() + { + const float EPS = 2e-4f; + float invertibleData[16] = { + 2.f, -3.f, 0.f, 1.f, + -2.f, 3.f, 0.f, 0.f, + 1.f, -2.f, 1.f, 0.f, + 1.f, -1.f, 0.f, 0.f + }; + + // Invertible matrix. + CMatrix3D a(invertibleData); + CMatrix3D n; + a.GetInverse(n); + a *= n; + CMatrix3D a2(invertibleData); + n *= a2; + + + for (int j = 0; j < 16; ++j) + TS_ASSERT_DELTA(a._data[j], n._data[j], EPS); + + // Non invertible matrix. + float nonInvertibleData[16] = { + 2.f, -3.f, 0.f, 1.f, + -2.f, 3.f, 0.f, 0.f, + 1.f, -2.f, 1.f, 0.f, + 0.f, 0.f, 0.f, 0.f + }; + + CMatrix3D b(nonInvertibleData); + b.GetInverse(n); + b *= n; + CMatrix3D b2(nonInvertibleData); + n *= b2; + + bool different = false; + for (int j = 0; j < 16; ++j) + { + if (!feq(b._data[j], n._data[j], EPS)) + { + different = true; + break; + } + } + TS_ASSERT(different); + } + void test_quats() { srand(0);