mirror of
https://github.com/g-truc/glm.git
synced 2024-11-26 02:04:35 +00:00
Fixed contructor of mat2 and added tests
This commit is contained in:
parent
9fbf421f13
commit
6fab8113d7
@ -56,10 +56,12 @@ namespace glm
|
||||
GLM_FUNC_DECL tmat2x2<T> _inverse() const;
|
||||
|
||||
private:
|
||||
//////////////////////////////////////
|
||||
// Data
|
||||
col_type value[2];
|
||||
|
||||
public:
|
||||
//////////////////////////////////////
|
||||
// Constructors
|
||||
GLM_FUNC_DECL tmat2x2();
|
||||
GLM_FUNC_DECL tmat2x2(
|
||||
@ -76,6 +78,23 @@ namespace glm
|
||||
col_type const & v1,
|
||||
col_type const & v2);
|
||||
|
||||
//////////////////////////////////////
|
||||
// Convertion constructors
|
||||
template <typename U>
|
||||
GLM_FUNC_DECL explicit tmat2x2(
|
||||
U const & x);
|
||||
|
||||
template <typename U, typename V, typename M, typename N>
|
||||
GLM_FUNC_DECL explicit tmat2x2(
|
||||
U const & x1, V const & y1,
|
||||
M const & x2, N const & y2);
|
||||
|
||||
//template <typename U, typename V, typename M, typename N>
|
||||
//GLM_FUNC_DECL explicit tmat2x2(
|
||||
// tvec2<U, V> const & v1,
|
||||
// tvec2<M, N> const & v2);
|
||||
|
||||
//////////////////////////////////////
|
||||
// Conversions
|
||||
template <typename U>
|
||||
GLM_FUNC_DECL explicit tmat2x2(tmat2x2<U> const & m);
|
||||
|
@ -107,8 +107,46 @@ namespace detail
|
||||
this->value[1] = v1;
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
// Convertion constructors
|
||||
template <typename T>
|
||||
template <typename U>
|
||||
GLM_FUNC_DECL tmat2x2<T>::tmat2x2
|
||||
(
|
||||
U const & s
|
||||
)
|
||||
{
|
||||
value_type const Zero(0);
|
||||
this->value[0] = tvec2<T>(value_type(s), Zero);
|
||||
this->value[1] = tvec2<T>(Zero, value_type(s));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template <typename U, typename V, typename M, typename N>
|
||||
GLM_FUNC_DECL tmat2x2<T>::tmat2x2
|
||||
(
|
||||
U const & x1, V const & y1,
|
||||
M const & x2, N const & y2
|
||||
)
|
||||
{
|
||||
this->value[0] = col_type(value_type(x1), value_type(y1));
|
||||
this->value[1] = col_type(value_type(x2), value_type(y2));
|
||||
}
|
||||
|
||||
//template <typename T>
|
||||
//template <typename U, typename V, typename M, typename N>
|
||||
//GLM_FUNC_DECL tmat2x2<T>::tmat2x2
|
||||
//(
|
||||
// tvec2<U, V> const & v1,
|
||||
// tvec2<M, N> const & v2
|
||||
//)
|
||||
//{
|
||||
// this->value[0] = col_type(v1);
|
||||
// this->value[1] = col_type(v2);
|
||||
//}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// mat2 conversions
|
||||
// mat2x2 conversions
|
||||
|
||||
template <typename T>
|
||||
template <typename U>
|
||||
@ -215,7 +253,7 @@ namespace detail
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// mat3 operators
|
||||
// mat2x2 operators
|
||||
|
||||
// This function shouldn't required but it seems that VC7.1 have an optimisation bug if this operator wasn't declared
|
||||
template <typename T>
|
||||
|
@ -93,7 +93,7 @@ namespace glm
|
||||
tvec2(tref2<T> const & r);
|
||||
|
||||
//////////////////////////////////////
|
||||
// Convertion scalar constructors
|
||||
// Convertion constructors
|
||||
|
||||
//! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
|
||||
template <typename U>
|
||||
|
@ -51,10 +51,38 @@ int test_half_precision_mat()
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_half_ctor_mat2x2()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::hvec2 A(1, 2);
|
||||
glm::hvec2 B(3, 4);
|
||||
glm::hmat2 C(A, B);//, 2.0f, 3.0f, 4.0f);
|
||||
glm::hmat2 D(1, 2, 3, 4);
|
||||
|
||||
Error += C[0] == D[0] ? 0 : 1;
|
||||
Error += C[1] == D[1] ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::hvec2 A(1, 2.0);
|
||||
glm::hvec2 B(3, 4.0);
|
||||
glm::hmat2 C(A, B);//, 2.0f, 3.0f, 4.0f);
|
||||
glm::hmat2 D(1, 2.0, 3u, 4.0f);
|
||||
|
||||
Error += C[0] == D[0] ? 0 : 1;
|
||||
Error += C[1] == D[1] ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_half_ctor_mat2x2();
|
||||
Error += test_half_precision_scalar();
|
||||
Error += test_half_precision_vec();
|
||||
Error += test_half_precision_mat();
|
||||
|
Loading…
Reference in New Issue
Block a user