From 321d0162109df01b9b94e3e44a1cfd5c44d5b02e Mon Sep 17 00:00:00 2001 From: Stefan Fiedler Date: Mon, 10 May 2021 20:48:13 +0200 Subject: [PATCH] use enum to define axis in mirror_matrix follow naming guidelines for parameters --- framework/include/math_utils.hpp | 6 ++++-- framework/src/math_utils.cpp | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/framework/include/math_utils.hpp b/framework/include/math_utils.hpp index 39b2ee114..0987e1574 100644 --- a/framework/include/math_utils.hpp +++ b/framework/include/math_utils.hpp @@ -12,9 +12,11 @@ namespace gvk /// extract the translation part out of a matrix extern glm::vec3 get_translation_from_matrix(const glm::mat4& m); - glm::mat4 cancel_translation_from_matrix(const glm::mat4& m); + glm::mat4 cancel_translation_from_matrix(const glm::mat4& aMatrix); - glm::mat4 mirror_matrix(const glm::mat4& m, const glm::length_t axis = 0); + enum principal_axis : uint32_t { x = 0u, y, z }; + + glm::mat4 mirror_matrix(const glm::mat4& aMatrix, const glm::length_t aAxis = principal_axis::x); /// /// Solve a system of equations with 3 unknowns. diff --git a/framework/src/math_utils.cpp b/framework/src/math_utils.cpp index c889e9ecc..6ad52eb99 100644 --- a/framework/src/math_utils.cpp +++ b/framework/src/math_utils.cpp @@ -25,16 +25,16 @@ namespace gvk return glm::vec3(m[3][0], m[3][1], m[3][2]); } - glm::mat4 cancel_translation_from_matrix(const glm::mat4& m) + glm::mat4 cancel_translation_from_matrix(const glm::mat4& aMatrix) { - return glm::mat4(m[0], m[1], m[2], glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)); + return glm::mat4(aMatrix[0], aMatrix[1], aMatrix[2], glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)); } - glm::mat4 mirror_matrix(const glm::mat4& m, const glm::length_t axis) + glm::mat4 mirror_matrix(const glm::mat4& aMatrix, const glm::length_t aAxis) { - assert(0 <= axis && axis <= 2); + auto axis = static_cast::type>(aAxis); - auto result(m); + auto result(aMatrix); result[axis] *= -1.0f; return result; }