From f9dd517d0c08ab99b39be295d3775fcc50ad264b Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 1 Jun 2011 20:17:23 +0100 Subject: [PATCH] Added implementation of missing matrix constructor --- glm/core/type_mat2x2.inl | 14 +++++------ glm/core/type_mat2x3.inl | 44 ++++++++++++++++++++++++++++++++++- glm/core/type_mat2x4.inl | 44 ++++++++++++++++++++++++++++++++++- glm/core/type_mat3x2.inl | 50 +++++++++++++++++++++++++++++++++++++++- glm/core/type_mat3x3.inl | 46 ++++++++++++++++++++++++++++++++++++ glm/core/type_mat3x4.inl | 46 ++++++++++++++++++++++++++++++++++++ glm/core/type_mat4x2.inl | 48 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 282 insertions(+), 10 deletions(-) diff --git a/glm/core/type_mat2x2.inl b/glm/core/type_mat2x2.inl index 77638dbb..f7fced77 100644 --- a/glm/core/type_mat2x2.inl +++ b/glm/core/type_mat2x2.inl @@ -122,11 +122,11 @@ namespace detail } template - template + template GLM_FUNC_DECL tmat2x2::tmat2x2 ( - U const & x1, V const & y1, - M const & x2, N const & y2 + X1 const & x1, Y1 const & y1, + X2 const & x2, Y2 const & y2 ) { this->value[0] = col_type(value_type(x1), value_type(y1)); @@ -134,11 +134,11 @@ namespace detail } template - template + template GLM_FUNC_DECL tmat2x2::tmat2x2 ( - tvec2 const & v1, - tvec2 const & v2 + tvec2 const & v1, + tvec2 const & v2 ) { this->value[0] = col_type(v1); @@ -146,7 +146,7 @@ namespace detail } ////////////////////////////////////////////////////////////// - // mat2x2 conversions + // mat2x2 matrix conversions template template diff --git a/glm/core/type_mat2x3.inl b/glm/core/type_mat2x3.inl index 83e8b2e3..79d9c423 100644 --- a/glm/core/type_mat2x3.inl +++ b/glm/core/type_mat2x3.inl @@ -106,7 +106,49 @@ namespace detail this->value[1] = v1; } - // Conversion + ////////////////////////////////////// + // Convertion constructors + template + template + GLM_FUNC_DECL tmat2x3::tmat2x3 + ( + U const & s + ) + { + value_type const Zero(0); + this->value[0] = tvec3(value_type(s), Zero, Zero); + this->value[1] = tvec3(Zero, value_type(s), Zero); + } + + template + template < + typename X1, typename Y1, typename Z1, + typename X2, typename Y2, typename Z2> + GLM_FUNC_DECL tmat2x3::tmat2x3 + ( + X1 const & x1, Y1 const & y1, Z1 const & z1, + X2 const & x2, Y2 const & y2, Z2 const & z2 + ) + { + this->value[0] = col_type(value_type(x1), value_type(y1), value_type(z1)); + this->value[1] = col_type(value_type(x2), value_type(y2), value_type(z2)); + } + + template + template + GLM_FUNC_DECL tmat2x3::tmat2x3 + ( + tvec3 const & v1, + tvec3 const & v2 + ) + { + this->value[0] = col_type(v1); + this->value[1] = col_type(v2); + } + + ////////////////////////////////////// + // Matrix conversions + template template GLM_FUNC_QUALIFIER tmat2x3::tmat2x3 diff --git a/glm/core/type_mat2x4.inl b/glm/core/type_mat2x4.inl index b19193f6..0a644d99 100644 --- a/glm/core/type_mat2x4.inl +++ b/glm/core/type_mat2x4.inl @@ -109,7 +109,49 @@ namespace detail this->value[1] = v1; } - // Conversion + ////////////////////////////////////// + // Convertion constructors + template + template + GLM_FUNC_DECL tmat2x4::tmat2x4 + ( + U const & s + ) + { + value_type const Zero(0); + this->value[0] = tvec4(value_type(s), Zero, Zero, Zero); + this->value[1] = tvec4(Zero, value_type(s), Zero, Zero); + } + + template + template < + typename X1, typename Y1, typename Z1, typename W1 + typename X2, typename Y2, typename Z2, typename W2> + GLM_FUNC_DECL tmat2x4::tmat2x4 + ( + X1 const & x1, Y1 const & y1, Z1 const & z1, W1 const & w1, + X2 const & x2, Y2 const & y2, Z2 const & z2, W2 const & w2, + ) + { + this->value[0] = col_type(value_type(x1), value_type(y1), value_type(z1), value_type(w1)); + this->value[1] = col_type(value_type(x2), value_type(y2), value_type(z2), value_type(w2)); + } + + template + template + GLM_FUNC_DECL tmat2x4::tmat2x4 + ( + tvec4 const & v1, + tvec4 const & v2 + ) + { + this->value[0] = col_type(v1); + this->value[1] = col_type(v2); + } + + ////////////////////////////////////// + // Matrix conversions + template template GLM_FUNC_QUALIFIER tmat2x4::tmat2x4 diff --git a/glm/core/type_mat3x2.inl b/glm/core/type_mat3x2.inl index 5fddb4c1..4138208f 100644 --- a/glm/core/type_mat3x2.inl +++ b/glm/core/type_mat3x2.inl @@ -113,7 +113,55 @@ namespace detail this->value[2] = v2; } - // Conversion + ////////////////////////////////////// + // Convertion constructors + template + template + GLM_FUNC_DECL tmat3x2::tmat3x2 + ( + U const & s + ) + { + value_type const Zero(0); + this->value[0] = tvec2(value_type(s), Zero); + this->value[1] = tvec2(Zero, value_type(s)); + this->value[2] = tvec2(Zero); + } + + template + template < + typename X1, typename Y1, + typename X2, typename Y2, + typename X3, typename Y3> + GLM_FUNC_DECL tmat3x2::tmat3x2 + ( + X1 const & x1, Y1 const & y1, + X2 const & x2, Y2 const & y2, + X3 const & x3, Y3 const & y3 + ) + { + this->value[0] = col_type(value_type(x1), value_type(y1)); + this->value[1] = col_type(value_type(x2), value_type(y2)); + this->value[2] = col_type(value_type(x3), value_type(y3)); + } + + template + template + GLM_FUNC_DECL tmat3x2::tmat3x2 + ( + tvec2 const & v1, + tvec2 const & v2, + tvec2 const & v3 + ) + { + this->value[0] = col_type(v1); + this->value[1] = col_type(v2); + this->value[2] = col_type(v3); + } + + ////////////////////////////////////////////////////////////// + // mat3x2 matrix conversions + template template GLM_FUNC_QUALIFIER tmat3x2::tmat3x2 diff --git a/glm/core/type_mat3x3.inl b/glm/core/type_mat3x3.inl index 667f2235..3aeeaeb9 100644 --- a/glm/core/type_mat3x3.inl +++ b/glm/core/type_mat3x3.inl @@ -116,6 +116,52 @@ namespace detail this->value[2] = v2; } + ////////////////////////////////////// + // Convertion constructors + template + template + GLM_FUNC_DECL tmat3x3::tmat3x3 + ( + U const & s + ) + { + value_type const Zero(0); + this->value[0] = tvec3(value_type(s), Zero, Zero); + this->value[1] = tvec3(Zero, value_type(s), Zero); + this->value[2] = tvec3(Zero, Zero, value_type(s)); + } + + template + template < + typename X1, typename Y1, typename Z1, + typename X2, typename Y2, typename Z2, + typename X3, typename Y3, typename Z3> + GLM_FUNC_DECL tmat3x3::tmat3x3 + ( + X1 const & x1, Y1 const & y1, Z1 const & z1, + X2 const & x2, Y2 const & y2, Z2 const & z2, + X3 const & x3, Y3 const & y3, Z3 const & z3 + ) + { + this->value[0] = col_type(value_type(x1), value_type(y1), value_type(z1)); + this->value[1] = col_type(value_type(x2), value_type(y2), value_type(z2)); + this->value[2] = col_type(value_type(x3), value_type(y3), value_type(z3)); + } + + template + template + GLM_FUNC_DECL tmat3x3::tmat3x3 + ( + tvec3 const & v1, + tvec3 const & v2, + tvec3 const & v3 + ) + { + this->value[0] = col_type(v1); + this->value[1] = col_type(v2); + this->value[2] = col_type(v3); + } + ////////////////////////////////////////////////////////////// // Conversions diff --git a/glm/core/type_mat3x4.inl b/glm/core/type_mat3x4.inl index 1a0b8499..8502dacd 100644 --- a/glm/core/type_mat3x4.inl +++ b/glm/core/type_mat3x4.inl @@ -114,6 +114,52 @@ namespace detail this->value[2] = v2; } + ////////////////////////////////////// + // Convertion constructors + template + template + GLM_FUNC_DECL tmat3x4::tmat3x4 + ( + U const & s + ) + { + value_type const Zero(0); + this->value[0] = tvec4(value_type(s), Zero, Zero, Zero); + this->value[1] = tvec4(Zero, value_type(s), Zero, Zero); + this->value[2] = tvec4(Zero, Zero, value_type(s), Zero); + } + + template + template < + typename X1, typename Y1, typename Z1, typename W1, + typename X2, typename Y2, typename Z2, typename W2, + typename X3, typename Y3, typename Z3, typename W3> + GLM_FUNC_DECL tmat3x4::tmat3x4 + ( + X1 const & x1, Y1 const & y1, Z1 const & z1, W1 const & w1, + X2 const & x2, Y2 const & y2, Z2 const & z2, W2 const & w2, + X3 const & x3, Y3 const & y3, Z3 const & z3, W3 const & w3 + ) + { + this->value[0] = col_type(value_type(x1), value_type(y1), value_type(z1), value_type(w1)); + this->value[1] = col_type(value_type(x2), value_type(y2), value_type(z2), value_type(w2)); + this->value[2] = col_type(value_type(x3), value_type(y3), value_type(z3), value_type(w3)); + } + + template + template + GLM_FUNC_DECL tmat3x4::tmat3x4 + ( + tvec4 const & v1, + tvec4 const & v2, + tvec4 const & v3 + ) + { + this->value[0] = col_type(v1); + this->value[1] = col_type(v2); + this->value[2] = col_type(v3); + } + // Conversion template template diff --git a/glm/core/type_mat4x2.inl b/glm/core/type_mat4x2.inl index cb30a98c..60c54df9 100644 --- a/glm/core/type_mat4x2.inl +++ b/glm/core/type_mat4x2.inl @@ -123,6 +123,54 @@ namespace detail this->value[3] = v3; } + ////////////////////////////////////// + // Convertion constructors + template + template + GLM_FUNC_DECL tmat4x2::tmat4x2 + ( + U const & s + ) + { + value_type const Zero(0); + this->value[0] = tvec4(value_type(s), Zero); + this->value[1] = tvec4(Zero, value_type(s)); + this->value[2] = tvec4(Zero, Zero); + this->value[3] = tvec4(Zero, Zero); + } + + template + template < + typename X1, typename Y1, + typename X2, typename Y2, + typename X3, typename Y3, + typename X4, typename Y4> + GLM_FUNC_DECL tmat4x2::tmat4x2 + ( + X1 const & x1, Y1 const & y1, Z1 const & z1, W1 const & w1, + X2 const & x2, Y2 const & y2, Z2 const & z2, W2 const & w2, + X3 const & x3, Y3 const & y3, Z3 const & z3, W3 const & w3 + ) + { + this->value[0] = col_type(value_type(x1), value_type(y1), value_type(z1), value_type(w1)); + this->value[1] = col_type(value_type(x2), value_type(y2), value_type(z2), value_type(w2)); + this->value[2] = col_type(value_type(x3), value_type(y3), value_type(z3), value_type(w3)); + } + + template + template + GLM_FUNC_DECL tmat4x2::tmat4x2 + ( + tvec4 const & v1, + tvec4 const & v2, + tvec4 const & v3 + ) + { + this->value[0] = col_type(v1); + this->value[1] = col_type(v2); + this->value[2] = col_type(v3); + } + // Conversion template template