diff --git a/openVulkanoCpp/Math/CoordinateSystemConverter.hpp b/openVulkanoCpp/Math/CoordinateSystemConverter.hpp index 212194a..48ff2b1 100644 --- a/openVulkanoCpp/Math/CoordinateSystemConverter.hpp +++ b/openVulkanoCpp/Math/CoordinateSystemConverter.hpp @@ -13,8 +13,8 @@ namespace OpenVulkano::Math { class CoordinateSystemConverter { - inline static Math::Matrix4i ROT_XP90 = { 1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1 }; - inline static Math::Matrix4i ROT_XN90 = { 1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1 }; + inline static Matrix3i ROT_XP90 = { 1, 0, 0, 0, 0, 1, 0, -1, 0 }; + inline static Matrix3i ROT_XN90 = { 1, 0, 0, 0, 0, -1, 0, 1, 0 }; CoordinateSystem from, to; public: @@ -85,20 +85,14 @@ namespace OpenVulkano::Math [[nodiscard]] Matrix ConvertUp(const Matrix& mat) const { if (from.GetUpAxis() == to.GetUpAxis()) return mat; - Matrix4i* conv; - Matrix4i* inverse; - if (from.GetUpAxis() == CoordinateSystem::UpAxis::Y && to.GetUpAxis() == CoordinateSystem::UpAxis::Z) - { - conv = &ROT_XP90; - inverse = &ROT_XN90; - } - else if (from.GetUpAxis() == CoordinateSystem::UpAxis::Z && to.GetUpAxis() == CoordinateSystem::UpAxis::Y) - { - conv = &ROT_XN90; - inverse = &ROT_XP90; - } + Matrix<3, T, Q> conv((from.GetUpAxis() == CoordinateSystem::UpAxis::Y) ? ROT_XP90 : ROT_XN90); - return Matrix(*conv) * mat * Matrix(*inverse); + Matrix ret(conv * Matrix<3, T, Q>(mat)); + if constexpr (S == 4) + { + ret[3] = { ConvertUp(Vector<3, T, Q>(mat[3])), 1 }; + } + return ret; } }; } \ No newline at end of file