diff --git a/glm/detail/func_matrix.hpp b/glm/detail/func_matrix.hpp index 655df92d..901c196b 100644 --- a/glm/detail/func_matrix.hpp +++ b/glm/detail/func_matrix.hpp @@ -43,9 +43,79 @@ // Dependencies #include "../detail/precision.hpp" #include "../detail/setup.hpp" +#include "../detail/type_mat.hpp" +#include "../vec2.hpp" +#include "../vec3.hpp" +#include "../vec4.hpp" +#include "../mat2x2.hpp" +#include "../mat2x3.hpp" +#include "../mat2x4.hpp" +#include "../mat3x2.hpp" +#include "../mat3x3.hpp" +#include "../mat3x4.hpp" +#include "../mat4x2.hpp" +#include "../mat4x3.hpp" +#include "../mat4x4.hpp" -namespace glm +namespace glm{ +namespace detail { + template + struct outerProduct_trait + { + typedef tmat2x2 type; + }; + + template + struct outerProduct_trait + { + typedef tmat2x3 type; + }; + + template + struct outerProduct_trait + { + typedef tmat2x4 type; + }; + + template + struct outerProduct_trait + { + typedef tmat3x2 type; + }; + + template + struct outerProduct_trait + { + typedef tmat3x3 type; + }; + + template + struct outerProduct_trait + { + typedef tmat3x4 type; + }; + + template + struct outerProduct_trait + { + typedef tmat4x2 type; + }; + + template + struct outerProduct_trait + { + typedef tmat4x3 type; + }; + + template + struct outerProduct_trait + { + typedef tmat4x4 type; + }; + +}//namespace detail + /// @addtogroup core_func_matrix /// @{ @@ -70,7 +140,7 @@ namespace glm /// /// @todo Clarify the declaration to specify that matType doesn't have to be provided when used. template class vecTypeA, template class vecTypeB> - GLM_FUNC_DECL void outerProduct(vecTypeA const & c, vecTypeB const & r); + GLM_FUNC_DECL typename detail::outerProduct_trait::type outerProduct(vecTypeA const & c, vecTypeB const & r); /// Returns the transposed matrix of x /// diff --git a/glm/detail/func_matrix.inl b/glm/detail/func_matrix.inl index c6a2c025..3f2fb5ab 100644 --- a/glm/detail/func_matrix.inl +++ b/glm/detail/func_matrix.inl @@ -27,18 +27,6 @@ /////////////////////////////////////////////////////////////////////////////////// #include "../geometric.hpp" -#include "../vec2.hpp" -#include "../vec3.hpp" -#include "../vec4.hpp" -#include "type_mat2x2.hpp" -#include "type_mat2x3.hpp" -#include "type_mat2x4.hpp" -#include "type_mat3x2.hpp" -#include "type_mat3x3.hpp" -#include "type_mat3x4.hpp" -#include "type_mat4x2.hpp" -#include "type_mat4x3.hpp" -#include "type_mat4x4.hpp" #include namespace glm{ @@ -55,9 +43,7 @@ namespace detail template struct compute_outerProduct { - typedef detail::tmat2x2 return_type; - - static return_type call(detail::tvec2 const & c, detail::tvec2 const & r) + GLM_FUNC_QUALIFIER static typename detail::outerProduct_trait::type call(detail::tvec2 const & c, detail::tvec2 const & r) { detail::tmat2x2 m(detail::tmat2x2::null); m[0][0] = c[0] * r[0]; @@ -71,9 +57,7 @@ namespace detail template struct compute_outerProduct { - typedef detail::tmat3x3 return_type; - - static return_type call(detail::tvec3 const & c, detail::tvec3 const & r) + GLM_FUNC_QUALIFIER static typename detail::outerProduct_trait::type call(detail::tvec3 const & c, detail::tvec3 const & r) { detail::tmat3x3 m(detail::tmat3x3::null); for(length_t i(0); i < m.length(); ++i) @@ -85,9 +69,7 @@ namespace detail template struct compute_outerProduct { - typedef detail::tmat4x4 return_type; - - static return_type call(detail::tvec4 const & c, detail::tvec4 const & r) + GLM_FUNC_QUALIFIER static typename detail::outerProduct_trait::type call(detail::tvec4 const & c, detail::tvec4 const & r) { detail::tmat4x4 m(detail::tmat4x4::null); for(length_t i(0); i < m.length(); ++i) @@ -99,9 +81,7 @@ namespace detail template struct compute_outerProduct { - typedef detail::tmat2x3 return_type; - - static return_type call(detail::tvec3 const & c, detail::tvec2 const & r) + GLM_FUNC_QUALIFIER static typename detail::outerProduct_trait::type call(detail::tvec3 const & c, detail::tvec2 const & r) { detail::tmat2x3 m(detail::tmat2x3::null); m[0][0] = c.x * r.x; @@ -117,9 +97,7 @@ namespace detail template struct compute_outerProduct { - typedef detail::tmat3x2 return_type; - - static return_type call(detail::tvec2 const & c, detail::tvec3 const & r) + GLM_FUNC_QUALIFIER static typename detail::outerProduct_trait::type call(detail::tvec2 const & c, detail::tvec3 const & r) { detail::tmat3x2 m(detail::tmat3x2::null); m[0][0] = c.x * r.x; @@ -135,9 +113,7 @@ namespace detail template struct compute_outerProduct { - typedef detail::tmat2x4 return_type; - - static return_type call(detail::tvec4 const & c, detail::tvec2 const & r) + GLM_FUNC_QUALIFIER static typename detail::outerProduct_trait::type call(detail::tvec4 const & c, detail::tvec2 const & r) { detail::tmat2x4 m(detail::tmat2x4::null); m[0][0] = c.x * r.x; @@ -155,9 +131,7 @@ namespace detail template struct compute_outerProduct { - typedef detail::tmat4x2 return_type; - - static return_type call(detail::tvec2 const & c, detail::tvec4 const & r) + GLM_FUNC_QUALIFIER static typename detail::outerProduct_trait::type call(detail::tvec2 const & c, detail::tvec4 const & r) { detail::tmat4x2 m(detail::tmat4x2::null); m[0][0] = c.x * r.x; @@ -175,9 +149,7 @@ namespace detail template struct compute_outerProduct { - typedef detail::tmat3x4 return_type; - - static return_type call(detail::tvec4 const & c, detail::tvec3 const & r) + GLM_FUNC_QUALIFIER static typename detail::outerProduct_trait::type call(detail::tvec4 const & c, detail::tvec3 const & r) { detail::tmat3x4 m(detail::tmat3x4::null); m[0][0] = c.x * r.x; @@ -199,9 +171,7 @@ namespace detail template struct compute_outerProduct { - typedef detail::tmat4x3 return_type; - - static return_type call(detail::tvec3 const & c, detail::tvec4 const & r) + GLM_FUNC_QUALIFIER static typename detail::outerProduct_trait::type call(detail::tvec3 const & c, detail::tvec4 const & r) { detail::tmat4x3 m(detail::tmat4x3::null); m[0][0] = c.x * r.x; @@ -226,7 +196,7 @@ namespace detail template struct compute_transpose { - static detail::tmat2x2 call(detail::tmat2x2 const & m) + GLM_FUNC_QUALIFIER static detail::tmat2x2 call(detail::tmat2x2 const & m) { detail::tmat2x2 result(detail::tmat2x2::_null); result[0][0] = m[0][0]; @@ -240,7 +210,7 @@ namespace detail template struct compute_transpose { - static detail::tmat3x2 call(detail::tmat2x3 const & m) + GLM_FUNC_QUALIFIER static detail::tmat3x2 call(detail::tmat2x3 const & m) { detail::tmat3x2 result(detail::tmat3x2::_null); result[0][0] = m[0][0]; @@ -256,7 +226,7 @@ namespace detail template struct compute_transpose { - static detail::tmat4x2 call(detail::tmat2x4 const & m) + GLM_FUNC_QUALIFIER static detail::tmat4x2 call(detail::tmat2x4 const & m) { detail::tmat4x2 result(detail::tmat4x2::_null); result[0][0] = m[0][0]; @@ -274,7 +244,7 @@ namespace detail template struct compute_transpose { - static detail::tmat2x3 call(detail::tmat3x2 const & m) + GLM_FUNC_QUALIFIER static detail::tmat2x3 call(detail::tmat3x2 const & m) { detail::tmat2x3 result(detail::tmat2x3::_null); result[0][0] = m[0][0]; @@ -290,7 +260,7 @@ namespace detail template struct compute_transpose { - static detail::tmat3x3 call(detail::tmat3x3 const & m) + GLM_FUNC_QUALIFIER static detail::tmat3x3 call(detail::tmat3x3 const & m) { detail::tmat3x3 result(detail::tmat3x3::_null); result[0][0] = m[0][0]; @@ -311,7 +281,7 @@ namespace detail template struct compute_transpose { - static detail::tmat4x3 call(detail::tmat3x4 const & m) + GLM_FUNC_QUALIFIER static detail::tmat4x3 call(detail::tmat3x4 const & m) { detail::tmat4x3 result(detail::tmat4x3::_null); result[0][0] = m[0][0]; @@ -333,7 +303,7 @@ namespace detail template struct compute_transpose { - static detail::tmat2x4 call(detail::tmat4x2 const & m) + GLM_FUNC_QUALIFIER static detail::tmat2x4 call(detail::tmat4x2 const & m) { detail::tmat2x4 result(detail::tmat2x4::_null); result[0][0] = m[0][0]; @@ -351,7 +321,7 @@ namespace detail template struct compute_transpose { - static detail::tmat3x4 call(detail::tmat4x3 const & m) + GLM_FUNC_QUALIFIER static detail::tmat3x4 call(detail::tmat4x3 const & m) { detail::tmat3x4 result(detail::tmat3x4::_null); result[0][0] = m[0][0]; @@ -373,7 +343,7 @@ namespace detail template struct compute_transpose { - static detail::tmat4x4 call(detail::tmat4x4 const & m) + GLM_FUNC_QUALIFIER static detail::tmat4x4 call(detail::tmat4x4 const & m) { detail::tmat4x4 result(detail::tmat4x4::_null); result[0][0] = m[0][0]; @@ -405,7 +375,7 @@ namespace detail template struct compute_determinant { - static T call(detail::tmat2x2 const & m) + GLM_FUNC_QUALIFIER static T call(detail::tmat2x2 const & m) { return m[0][0] * m[1][1] - m[1][0] * m[0][1]; } @@ -414,7 +384,7 @@ namespace detail template struct compute_determinant { - static T call(detail::tmat3x3 const & m) + GLM_FUNC_QUALIFIER static T call(detail::tmat3x3 const & m) { return + m[0][0] * (m[1][1] * m[2][2] - m[2][1] * m[1][2]) @@ -426,7 +396,7 @@ namespace detail template struct compute_determinant { - static T call(detail::tmat4x4 const & m) + GLM_FUNC_QUALIFIER static T call(detail::tmat4x4 const & m) { T SubFactor00 = m[2][2] * m[3][3] - m[3][2] * m[2][3]; T SubFactor01 = m[2][1] * m[3][3] - m[3][1] * m[2][3]; @@ -460,7 +430,7 @@ namespace detail } template