Fixed matrix conversions and added unit tests #371

This commit is contained in:
Christophe Riccio 2015-08-01 21:40:36 +02:00
parent 6ccdafb718
commit d6ae2fd694
14 changed files with 411 additions and 16 deletions

View File

@ -73,10 +73,9 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x4<T, P>::tmat3x4(T const & s)
{
value_type const Zero(0);
this->value[0] = col_type(s, Zero, Zero, Zero);
this->value[1] = col_type(Zero, s, Zero, Zero);
this->value[2] = col_type(Zero, Zero, s, Zero);
this->value[0] = col_type(s, 0, 0, 0);
this->value[1] = col_type(0, s, 0, 0);
this->value[2] = col_type(0, 0, s, 0);
}
template <typename T, precision P>
@ -186,7 +185,7 @@ namespace glm
{
this->value[0] = col_type(m[0], 0, 0);
this->value[1] = col_type(m[1], 0, 0);
this->value[2] = col_type(m[2], 0, 1);
this->value[2] = col_type(m[2], 1, 0);
}
template <typename T, precision P>

View File

@ -76,11 +76,10 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x2<T, P>::tmat4x2(T const & s)
{
value_type const Zero(0);
this->value[0] = col_type(s, Zero);
this->value[1] = col_type(Zero, s);
this->value[2] = col_type(Zero, Zero);
this->value[3] = col_type(Zero, Zero);
this->value[0] = col_type(s, 0);
this->value[1] = col_type(0, s);
this->value[2] = col_type(0, 0);
this->value[3] = col_type(0, 0);
}
template <typename T, precision P>

View File

@ -169,7 +169,7 @@ namespace glm
{
this->value[0] = col_type(m[0], 0);
this->value[1] = col_type(m[1], 0);
this->value[2] = col_type(m[2], 1);
this->value[2] = col_type(0, 0, 1);
this->value[3] = col_type(0);
}

View File

@ -256,7 +256,7 @@ namespace detail
{
this->value[0] = col_type(m[0], 0, 0);
this->value[1] = col_type(m[1], 0, 0);
this->value[2] = col_type(0);
this->value[2] = col_type(0, 0, 1, 0);
this->value[3] = col_type(0, 0, 0, 1);
}
@ -274,7 +274,7 @@ namespace detail
{
this->value[0] = col_type(m[0], 0);
this->value[1] = col_type(m[1], 0);
this->value[2] = col_type(0);
this->value[2] = col_type(0, 0, 1, 0);
this->value[3] = col_type(0, 0, 0, 1);
}
@ -283,7 +283,7 @@ namespace detail
{
this->value[0] = col_type(m[0], 0, 0);
this->value[1] = col_type(m[1], 0, 0);
this->value[2] = col_type(m[2], 0, 0);
this->value[2] = col_type(m[2], 1, 0);
this->value[3] = col_type(0, 0, 0, 1);
}
@ -292,7 +292,7 @@ namespace detail
{
this->value[0] = m[0];
this->value[1] = m[1];
this->value[2] = col_type(0);
this->value[2] = col_type(0, 0, 1, 0);
this->value[3] = col_type(0, 0, 0, 1);
}
@ -301,7 +301,7 @@ namespace detail
{
this->value[0] = col_type(m[0], 0, 0);
this->value[1] = col_type(m[1], 0, 0);
this->value[2] = col_type(0);
this->value[2] = col_type(0, 0, 1, 0);
this->value[3] = col_type(0, 0, 0, 1);
}

View File

@ -81,6 +81,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate)
- Fixed use of libstdc++ with Clang #351
- Fixed quaternion pow #346
- Fixed decompose warnings #373
- Fixed matrix conversions #371
##### Deprecation:
- Removed integer specification for 'mod' in GTC_integer #308

View File

@ -33,6 +33,14 @@
#include <glm/matrix.hpp>
#include <glm/vector_relational.hpp>
#include <glm/mat2x2.hpp>
#include <glm/mat2x3.hpp>
#include <glm/mat2x4.hpp>
#include <glm/mat3x2.hpp>
#include <glm/mat3x3.hpp>
#include <glm/mat3x4.hpp>
#include <glm/mat4x2.hpp>
#include <glm/mat4x3.hpp>
#include <glm/mat4x4.hpp>
#include <vector>
int test_operators()
@ -120,6 +128,41 @@ int test_ctr()
return Error;
}
namespace cast
{
template <typename genType>
int entry()
{
int Error = 0;
genType A(1.0f);
glm::mat2 B(A);
glm::mat2 Identity(1.0f);
for(glm::length_t i = 0, length = B.length(); i < length; ++i)
Error += glm::all(glm::equal(B[i], Identity[i])) ? 0 : 1;
return Error;
}
int test()
{
int Error = 0;
Error += entry<glm::mat2x2>();
Error += entry<glm::mat2x3>();
Error += entry<glm::mat2x4>();
Error += entry<glm::mat3x2>();
Error += entry<glm::mat3x3>();
Error += entry<glm::mat3x4>();
Error += entry<glm::mat4x2>();
Error += entry<glm::mat4x3>();
Error += entry<glm::mat4x4>();
return Error;
}
}//namespace cast
int main()
{
int Error(0);
@ -129,6 +172,7 @@ int main()
assert(glm::mat2::cols == glm::mat2::col_type::components);
#endif
Error += cast::test();
Error += test_ctr();
Error += test_operators();
Error += test_inverse();

View File

@ -30,7 +30,15 @@
///////////////////////////////////////////////////////////////////////////////////
#include <glm/vector_relational.hpp>
#include <glm/mat2x2.hpp>
#include <glm/mat2x3.hpp>
#include <glm/mat2x4.hpp>
#include <glm/mat3x2.hpp>
#include <glm/mat3x3.hpp>
#include <glm/mat3x4.hpp>
#include <glm/mat4x2.hpp>
#include <glm/mat4x3.hpp>
#include <glm/mat4x4.hpp>
#include <vector>
static int test_operators()
@ -94,6 +102,41 @@ int test_ctr()
return Error;
}
namespace cast
{
template <typename genType>
int entry()
{
int Error = 0;
genType A(1.0f);
glm::mat2x3 B(A);
glm::mat2x3 Identity(1.0f);
for(glm::length_t i = 0, length = B.length(); i < length; ++i)
Error += glm::all(glm::equal(B[i], Identity[i])) ? 0 : 1;
return Error;
}
int test()
{
int Error = 0;
Error += entry<glm::mat2x2>();
Error += entry<glm::mat2x3>();
Error += entry<glm::mat2x4>();
Error += entry<glm::mat3x2>();
Error += entry<glm::mat3x3>();
Error += entry<glm::mat3x4>();
Error += entry<glm::mat4x2>();
Error += entry<glm::mat4x3>();
Error += entry<glm::mat4x4>();
return Error;
}
}//namespace cast
int main()
{
int Error = 0;
@ -103,6 +146,7 @@ int main()
assert(glm::mat2x3::cols == glm::mat2x3::col_type::components);
#endif
Error += cast::test();
Error += test_ctr();
Error += test_operators();

View File

@ -30,7 +30,15 @@
///////////////////////////////////////////////////////////////////////////////////
#include <glm/vector_relational.hpp>
#include <glm/mat2x2.hpp>
#include <glm/mat2x3.hpp>
#include <glm/mat2x4.hpp>
#include <glm/mat3x2.hpp>
#include <glm/mat3x3.hpp>
#include <glm/mat3x4.hpp>
#include <glm/mat4x2.hpp>
#include <glm/mat4x3.hpp>
#include <glm/mat4x4.hpp>
#include <vector>
static int test_operators()
@ -94,6 +102,41 @@ int test_ctr()
return Error;
}
namespace cast
{
template <typename genType>
int entry()
{
int Error = 0;
genType A(1.0f);
glm::mat2x4 B(A);
glm::mat2x4 Identity(1.0f);
for(glm::length_t i = 0, length = B.length(); i < length; ++i)
Error += glm::all(glm::equal(B[i], Identity[i])) ? 0 : 1;
return Error;
}
int test()
{
int Error = 0;
Error += entry<glm::mat2x2>();
Error += entry<glm::mat2x3>();
Error += entry<glm::mat2x4>();
Error += entry<glm::mat3x2>();
Error += entry<glm::mat3x3>();
Error += entry<glm::mat3x4>();
Error += entry<glm::mat4x2>();
Error += entry<glm::mat4x3>();
Error += entry<glm::mat4x4>();
return Error;
}
}//namespace cast
int main()
{
int Error = 0;
@ -103,6 +146,7 @@ int main()
assert(glm::mat2x4::cols == glm::mat2x4::col_type::components);
#endif
Error += cast::test();
Error += test_ctr();
Error += test_operators();

View File

@ -30,7 +30,15 @@
///////////////////////////////////////////////////////////////////////////////////
#include <glm/vector_relational.hpp>
#include <glm/mat2x2.hpp>
#include <glm/mat2x3.hpp>
#include <glm/mat2x4.hpp>
#include <glm/mat3x2.hpp>
#include <glm/mat3x3.hpp>
#include <glm/mat3x4.hpp>
#include <glm/mat4x2.hpp>
#include <glm/mat4x3.hpp>
#include <glm/mat4x4.hpp>
#include <vector>
static bool test_operators()
@ -98,6 +106,41 @@ int test_ctr()
return Error;
}
namespace cast
{
template <typename genType>
int entry()
{
int Error = 0;
genType A(1.0f);
glm::mat3x2 B(A);
glm::mat3x2 Identity(1.0f);
for(glm::length_t i = 0, length = B.length(); i < length; ++i)
Error += glm::all(glm::equal(B[i], Identity[i])) ? 0 : 1;
return Error;
}
int test()
{
int Error = 0;
Error += entry<glm::mat2x2>();
Error += entry<glm::mat2x3>();
Error += entry<glm::mat2x4>();
Error += entry<glm::mat3x2>();
Error += entry<glm::mat3x3>();
Error += entry<glm::mat3x4>();
Error += entry<glm::mat4x2>();
Error += entry<glm::mat4x3>();
Error += entry<glm::mat4x4>();
return Error;
}
}//namespace cast
int main()
{
int Error = 0;
@ -107,6 +150,7 @@ int main()
assert(glm::mat3x2::cols == glm::mat3x2::col_type::components);
#endif
Error += cast::test();
Error += test_ctr();
Error += test_operators();

View File

@ -32,7 +32,15 @@
#include <glm/gtc/epsilon.hpp>
#include <glm/matrix.hpp>
#include <glm/vector_relational.hpp>
#include <glm/mat2x2.hpp>
#include <glm/mat2x3.hpp>
#include <glm/mat2x4.hpp>
#include <glm/mat3x2.hpp>
#include <glm/mat3x3.hpp>
#include <glm/mat3x4.hpp>
#include <glm/mat4x2.hpp>
#include <glm/mat4x3.hpp>
#include <glm/mat4x4.hpp>
#include <cstdio>
#include <vector>
@ -157,6 +165,41 @@ int test_ctr()
return Error;
}
namespace cast
{
template <typename genType>
int entry()
{
int Error = 0;
genType A(1.0f);
glm::mat3x3 B(A);
glm::mat3x3 Identity(1.0f);
for(glm::length_t i = 0, length = B.length(); i < length; ++i)
Error += glm::all(glm::equal(B[i], Identity[i])) ? 0 : 1;
return Error;
}
int test()
{
int Error = 0;
Error += entry<glm::mat2x2>();
Error += entry<glm::mat2x3>();
Error += entry<glm::mat2x4>();
Error += entry<glm::mat3x2>();
Error += entry<glm::mat3x3>();
Error += entry<glm::mat3x4>();
Error += entry<glm::mat4x2>();
Error += entry<glm::mat4x3>();
Error += entry<glm::mat4x4>();
return Error;
}
}//namespace cast
int main()
{
int Error = 0;
@ -166,6 +209,7 @@ int main()
assert(glm::mat3::cols == glm::mat3::col_type::components);
#endif
Error += cast::test();
Error += test_ctr();
Error += test_mat3x3();
Error += test_operators();

View File

@ -30,7 +30,15 @@
///////////////////////////////////////////////////////////////////////////////////
#include <glm/vector_relational.hpp>
#include <glm/mat2x2.hpp>
#include <glm/mat2x3.hpp>
#include <glm/mat2x4.hpp>
#include <glm/mat3x2.hpp>
#include <glm/mat3x3.hpp>
#include <glm/mat3x4.hpp>
#include <glm/mat4x2.hpp>
#include <glm/mat4x3.hpp>
#include <glm/mat4x4.hpp>
#include <vector>
static bool test_operators()
@ -98,6 +106,41 @@ int test_ctr()
return Error;
}
namespace cast
{
template <typename genType>
int entry()
{
int Error = 0;
genType A(1.0f);
glm::mat3x4 B(A);
glm::mat3x4 Identity(1.0f);
for(glm::length_t i = 0, length = B.length(); i < length; ++i)
Error += glm::all(glm::equal(B[i], Identity[i])) ? 0 : 1;
return Error;
}
int test()
{
int Error = 0;
Error += entry<glm::mat2x2>();
Error += entry<glm::mat2x3>();
Error += entry<glm::mat2x4>();
Error += entry<glm::mat3x2>();
Error += entry<glm::mat3x3>();
Error += entry<glm::mat3x4>();
Error += entry<glm::mat4x2>();
Error += entry<glm::mat4x3>();
Error += entry<glm::mat4x4>();
return Error;
}
}//namespace cast
int main()
{
int Error = 0;
@ -107,6 +150,7 @@ int main()
assert(glm::mat3x4::cols == glm::mat3x4::col_type::components);
#endif
Error += cast::test();
Error += test_ctr();
Error += test_operators();

View File

@ -30,7 +30,15 @@
///////////////////////////////////////////////////////////////////////////////////
#include <glm/vector_relational.hpp>
#include <glm/mat2x2.hpp>
#include <glm/mat2x3.hpp>
#include <glm/mat2x4.hpp>
#include <glm/mat3x2.hpp>
#include <glm/mat3x3.hpp>
#include <glm/mat3x4.hpp>
#include <glm/mat4x2.hpp>
#include <glm/mat4x3.hpp>
#include <glm/mat4x4.hpp>
#include <vector>
static int test_operators()
@ -102,6 +110,41 @@ int test_ctr()
return Error;
}
namespace cast
{
template <typename genType>
int entry()
{
int Error = 0;
genType A(1.0f);
glm::mat4x2 B(A);
glm::mat4x2 Identity(1.0f);
for(glm::length_t i = 0, length = B.length(); i < length; ++i)
Error += glm::all(glm::equal(B[i], Identity[i])) ? 0 : 1;
return Error;
}
int test()
{
int Error = 0;
Error += entry<glm::mat2x2>();
Error += entry<glm::mat2x3>();
Error += entry<glm::mat2x4>();
Error += entry<glm::mat3x2>();
Error += entry<glm::mat3x3>();
Error += entry<glm::mat3x4>();
Error += entry<glm::mat4x2>();
Error += entry<glm::mat4x3>();
Error += entry<glm::mat4x4>();
return Error;
}
}//namespace cast
int main()
{
int Error = 0;
@ -111,6 +154,7 @@ int main()
assert(glm::mat4x2::cols == glm::mat4x2::col_type::components);
#endif
Error += cast::test();
Error += test_ctr();
Error += test_operators();

View File

@ -30,7 +30,15 @@
///////////////////////////////////////////////////////////////////////////////////
#include <glm/vector_relational.hpp>
#include <glm/mat2x2.hpp>
#include <glm/mat2x3.hpp>
#include <glm/mat2x4.hpp>
#include <glm/mat3x2.hpp>
#include <glm/mat3x3.hpp>
#include <glm/mat3x4.hpp>
#include <glm/mat4x2.hpp>
#include <glm/mat4x3.hpp>
#include <glm/mat4x4.hpp>
#include <vector>
static int test_operators()
@ -102,6 +110,41 @@ int test_ctr()
return Error;
}
namespace cast
{
template <typename genType>
int entry()
{
int Error = 0;
genType A(1.0f);
glm::mat4x3 B(A);
glm::mat4x3 Identity(1.0f);
for(glm::length_t i = 0, length = B.length(); i < length; ++i)
Error += glm::all(glm::equal(B[i], Identity[i])) ? 0 : 1;
return Error;
}
int test()
{
int Error = 0;
Error += entry<glm::mat2x2>();
Error += entry<glm::mat2x3>();
Error += entry<glm::mat2x4>();
Error += entry<glm::mat3x2>();
Error += entry<glm::mat3x3>();
Error += entry<glm::mat3x4>();
Error += entry<glm::mat4x2>();
Error += entry<glm::mat4x3>();
Error += entry<glm::mat4x4>();
return Error;
}
}//namespace cast
int main()
{
int Error = 0;
@ -111,6 +154,7 @@ int main()
assert(glm::mat4x3::cols == glm::mat4x3::col_type::components);
#endif
Error += cast::test();
Error += test_ctr();
Error += test_operators();

View File

@ -31,6 +31,14 @@
#include <glm/gtc/epsilon.hpp>
#include <glm/matrix.hpp>
#include <glm/mat2x2.hpp>
#include <glm/mat2x3.hpp>
#include <glm/mat2x4.hpp>
#include <glm/mat3x2.hpp>
#include <glm/mat3x3.hpp>
#include <glm/mat3x4.hpp>
#include <glm/mat4x2.hpp>
#include <glm/mat4x3.hpp>
#include <glm/mat4x4.hpp>
#include <cstdio>
#include <vector>
@ -274,6 +282,41 @@ int perf_mul()
return Error;
}
namespace cast
{
template <typename genType>
int entry()
{
int Error = 0;
genType A(1.0f);
glm::mat4x4 B(A);
glm::mat4x4 Identity(1.0f);
for(glm::length_t i = 0, length = B.length(); i < length; ++i)
Error += glm::all(glm::equal(B[i], Identity[i])) ? 0 : 1;
return Error;
}
int test()
{
int Error = 0;
Error += entry<glm::mat2x2>();
Error += entry<glm::mat2x3>();
Error += entry<glm::mat2x4>();
Error += entry<glm::mat3x2>();
Error += entry<glm::mat3x3>();
Error += entry<glm::mat3x4>();
Error += entry<glm::mat4x2>();
Error += entry<glm::mat4x3>();
Error += entry<glm::mat4x4>();
return Error;
}
}//namespace cast
int main()
{
int Error = 0;
@ -283,6 +326,7 @@ int main()
assert(glm::mat4::cols == glm::mat4::col_type::components);
#endif
Error += cast::test();
Error += test_ctr();
Error += test_inverse_dmat4x4();
Error += test_inverse_mat4x4();