Merge branch '0.9.5' into 0.9.6

This commit is contained in:
Christophe Riccio 2014-01-04 22:29:45 +01:00
commit bd8836e53b
35 changed files with 619 additions and 575 deletions

View File

@ -35,31 +35,31 @@ namespace detail
template <typename T>
GLM_FUNC_QUALIFIER T mod289(T const & x)
{
return x - floor(x * T(1.0 / 289.0)) * T(289.0);
return x - floor(x * static_cast<T>(1.0) / static_cast<T>(289.0)) * static_cast<T>(289.0);
}
template <typename T>
GLM_FUNC_QUALIFIER T permute(T const & x)
{
return mod289(((x * T(34)) + T(1)) * x);
return mod289(((x * static_cast<T>(34)) + static_cast<T>(1)) * x);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec2<T, P> permute(tvec2<T, P> const & x)
{
return mod289(((x * T(34)) + T(1)) * x);
return mod289(((x * static_cast<T>(34)) + static_cast<T>(1)) * x);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec3<T, P> permute(tvec3<T, P> const & x)
{
return mod289(((x * T(34)) + T(1)) * x);
return mod289(((x * static_cast<T>(34)) + static_cast<T>(1)) * x);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec4<T, P> permute(tvec4<T, P> const & x)
{
return mod289(((x * T(34)) + T(1)) * x);
return mod289(((x * static_cast<T>(34)) + static_cast<T>(1)) * x);
}
/*
template <typename T, precision P, template<typename> class vecType>

View File

@ -153,68 +153,53 @@ namespace detail
VECTORIZE_VEC(sqrt)
template <typename genType>
GLM_FUNC_QUALIFIER genType inversesqrt
namespace detail
{
template <template <class, precision> class vecType, typename T, precision P>
struct compute_inversesqrt
{
static vecType<T, P> call(vecType<T, P> const & x)
{
return static_cast<T>(1) / sqrt(x);
}
};
template <template <class, precision> class vecType>
struct compute_inversesqrt<vecType, float, lowp>
{
static vecType<float, lowp> call(vecType<float, lowp> const & x)
{
vecType<float, lowp> tmp(x);
vecType<float, lowp> xhalf(tmp * 0.5f);
vecType<uint, lowp> i = *reinterpret_cast<vecType<uint, lowp>*>(const_cast<vecType<float, lowp>*>(&x));
i = vecType<uint, lowp>(0x5f375a86) - (i >> vecType<uint, lowp>(1));
tmp = *reinterpret_cast<vecType<float, lowp>*>(&i);
tmp = tmp * (1.5f - xhalf * tmp * tmp);
return tmp;
}
};
}//namespace detail
// inversesqrt
GLM_FUNC_QUALIFIER float inversesqrt(float const & x)
{
return 1.0f / sqrt(x);
}
GLM_FUNC_QUALIFIER double inversesqrt(double const & x)
{
return 1.0 / sqrt(x);
}
template <template <class, precision> class vecType, typename T, precision P>
GLM_FUNC_QUALIFIER vecType<T, P> inversesqrt
(
genType const & x
vecType<T, P> const & x
)
{
GLM_STATIC_ASSERT(
std::numeric_limits<genType>::is_iec559,
"'inversesqrt' only accept floating-point inputs");
assert(x > genType(0));
return genType(1) / std::sqrt(x);
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'inversesqrt' only accept floating-point inputs");
return detail::compute_inversesqrt<vecType, T, P>::call(x);
}
VECTORIZE_VEC(inversesqrt)
namespace detail
{
template <typename genType, typename genUType>
genType fastInversesqrt(genType const & v)
{
genType tmp(v);
genType xhalf(tmp * genType(0.5f));
genUType i = *reinterpret_cast<genUType*>(const_cast<genType*>(&v));
i = genUType(0x5f375a86) - (i >> genUType(1));
tmp = *reinterpret_cast<genType*>(&i);
tmp = tmp * (genType(1.5f) - xhalf * tmp * tmp);
return tmp;
}
}
template <>
GLM_FUNC_QUALIFIER lowp_vec1 inversesqrt(lowp_vec1 const & v)
{
assert(glm::all(glm::greaterThan(v, lowp_vec1(0))));
return detail::fastInversesqrt<lowp_vec1, uint>(v);
}
template <>
GLM_FUNC_QUALIFIER lowp_vec2 inversesqrt(lowp_vec2 const & v)
{
assert(glm::all(glm::greaterThan(v, lowp_vec2(0))));
return detail::fastInversesqrt<lowp_vec2, lowp_uvec2>(v);
}
template <>
GLM_FUNC_QUALIFIER lowp_vec3 inversesqrt(lowp_vec3 const & v)
{
assert(glm::all(glm::greaterThan(v, lowp_vec3(0))));
return detail::fastInversesqrt<lowp_vec3, lowp_uvec3>(v);
}
template <>
GLM_FUNC_QUALIFIER lowp_vec4 inversesqrt(lowp_vec4 const & v)
{
assert(glm::all(glm::greaterThan(v, lowp_vec4(0))));
return detail::fastInversesqrt<lowp_vec4, lowp_uvec4>(v);
}
}//namespace glm

View File

@ -74,7 +74,7 @@ namespace glm
GLM_FUNC_DECL T dot(
vecType<T, P> const & x,
vecType<T, P> const & y);
/*
/// Returns the dot product of x and y, i.e., result = x * y.
///
/// @tparam genType Floating-point vector types.
@ -85,7 +85,7 @@ namespace glm
GLM_FUNC_DECL genType dot(
genType const & x,
genType const & y);
*/
/// Returns the cross product of x and y.
///
/// @tparam valType Floating-point scalar types.

View File

@ -106,8 +106,6 @@ namespace glm
vecType<T, P> const & y
)
{
//GLM_STATIC_ASSERT(detail::is_vector<vecType<T, P> >::_YES,
// "Invalid template instantiation of 'equal', GLM vector types required");
assert(x.length() == y.length());
typename vecType<bool, P>::bool_type Result(vecType<bool, P>::_null);
@ -123,8 +121,6 @@ namespace glm
vecType<T, P> const & y
)
{
//GLM_STATIC_ASSERT(detail::is_vector<vecType<T, P> >::_YES,
// "Invalid template instantiation of 'notEqual', GLM vector types required");
assert(x.length() == y.length());
typename vecType<bool, P>::bool_type Result(vecType<bool, P>::_null);
@ -136,9 +132,6 @@ namespace glm
template <precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER bool any(vecType<bool, P> const & v)
{
//GLM_STATIC_ASSERT(detail::is_vector<vecType<bool, P> >::_YES,
// "Invalid template instantiation of 'any', GLM boolean vector types required");
bool Result = false;
for(int i = 0; i < v.length(); ++i)
Result = Result || v[i];
@ -148,9 +141,6 @@ namespace glm
template <precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER bool all(vecType<bool, P> const & v)
{
//GLM_STATIC_ASSERT(detail::is_vector<vecType<bool, P> >::_YES,
// "Invalid template instantiation of 'all', GLM boolean vector types required");
bool Result = true;
for(int i = 0; i < v.length(); ++i)
Result = Result && v[i];
@ -160,9 +150,6 @@ namespace glm
template <precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<bool, P> not_(vecType<bool, P> const & v)
{
//GLM_STATIC_ASSERT(detail::is_vector<vecType<bool, P> >::_YES,
// "Invalid template instantiation of 'not_', GLM vector types required");
typename vecType<bool, P>::bool_type Result(vecType<bool, P>::_null);
for(int i = 0; i < v.length(); ++i)
Result[i] = !v[i];

View File

@ -50,8 +50,6 @@ namespace detail
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
template <typename U, precision Q>
friend tmat2x2<U, Q> inverse(tmat2x2<U, Q> const & m);
template <typename U, precision Q>
friend tvec2<U, Q> operator/(tmat2x2<U, Q> const & m, tvec2<U, Q> const & v);
template <typename U, precision Q>
@ -60,8 +58,6 @@ namespace detail
private:
/// @cond DETAIL
col_type value[2];
GLM_FUNC_DECL tmat2x2<T, P> _inverse() const;
/// @endcond
public:
@ -152,8 +148,10 @@ namespace detail
GLM_FUNC_DECL tmat2x2<T, P> operator--(int);
};
// Binary operators
template <typename T, precision P>
GLM_FUNC_DECL tmat2x2<T, P> compute_inverse_mat2(tmat2x2<T, P> const & m);
// Binary operators
template <typename T, precision P>
GLM_FUNC_DECL tmat2x2<T, P> operator+ (
tmat2x2<T, P> const & m,

View File

@ -272,19 +272,6 @@ namespace detail
this->value[1] = col_type(m[1]);
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x2<T, P> tmat2x2<T, P>::_inverse() const
{
typename tmat2x2<T, P>::value_type Determinant = this->value[0][0] * this->value[1][1] - this->value[1][0] * this->value[0][1];
tmat2x2<T, P> Inverse(
+ this->value[1][1] / Determinant,
- this->value[0][1] / Determinant,
- this->value[1][0] / Determinant,
+ this->value[0][0] / Determinant);
return Inverse;
}
//////////////////////////////////////////////////////////////
// mat2x2 operators
@ -371,7 +358,7 @@ namespace detail
template <typename U>
GLM_FUNC_QUALIFIER tmat2x2<T, P>& tmat2x2<T, P>::operator/= (tmat2x2<U, P> const & m)
{
return (*this = *this * m._inverse());
return (*this = *this * compute_inverse_mat2(m));
}
template <typename T, precision P>
@ -406,6 +393,18 @@ namespace detail
return Result;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat2x2<T, P> compute_inverse_mat2(tmat2x2<T, P> const & m)
{
T Determinant = m[0][0] * m[1][1] - m[1][0] * m[0][1];
tmat2x2<T, P> Inverse(
+ m[1][1] / Determinant, - m[0][1] / Determinant,
- m[1][0] / Determinant, + m[0][0] / Determinant);
return Inverse;
}
//////////////////////////////////////////////////////////////
// Binary operators
@ -608,7 +607,7 @@ namespace detail
typename tmat2x2<T, P>::row_type & v
)
{
return m._inverse() * v;
return detail::compute_inverse_mat2(m) * v;
}
template <typename T, precision P>
@ -618,7 +617,7 @@ namespace detail
tmat2x2<T, P> const & m
)
{
return v * m._inverse();
return v * detail::compute_inverse_mat2(m);
}
template <typename T, precision P>

View File

@ -500,19 +500,19 @@ namespace detail
tmat3x2<T, P> const & m2
)
{
typename tmat2x3<T, P>::value_type SrcA00 = m1[0][0];
typename tmat2x3<T, P>::value_type SrcA01 = m1[0][1];
typename tmat2x3<T, P>::value_type SrcA02 = m1[0][2];
typename tmat2x3<T, P>::value_type SrcA10 = m1[1][0];
typename tmat2x3<T, P>::value_type SrcA11 = m1[1][1];
typename tmat2x3<T, P>::value_type SrcA12 = m1[1][2];
T SrcA00 = m1[0][0];
T SrcA01 = m1[0][1];
T SrcA02 = m1[0][2];
T SrcA10 = m1[1][0];
T SrcA11 = m1[1][1];
T SrcA12 = m1[1][2];
typename tmat2x3<T, P>::value_type SrcB00 = m2[0][0];
typename tmat2x3<T, P>::value_type SrcB01 = m2[0][1];
typename tmat2x3<T, P>::value_type SrcB10 = m2[1][0];
typename tmat2x3<T, P>::value_type SrcB11 = m2[1][1];
typename tmat2x3<T, P>::value_type SrcB20 = m2[2][0];
typename tmat2x3<T, P>::value_type SrcB21 = m2[2][1];
T SrcB00 = m2[0][0];
T SrcB01 = m2[0][1];
T SrcB10 = m2[1][0];
T SrcB11 = m2[1][1];
T SrcB20 = m2[2][0];
T SrcB21 = m2[2][1];
tmat3x3<T, P> Result(tmat3x3<T, P>::null);
Result[0][0] = SrcA00 * SrcB00 + SrcA10 * SrcB01;

View File

@ -490,23 +490,23 @@ namespace detail
tmat4x2<T, P> const & m2
)
{
typename tmat2x4<T, P>::value_type SrcA00 = m1[0][0];
typename tmat2x4<T, P>::value_type SrcA01 = m1[0][1];
typename tmat2x4<T, P>::value_type SrcA02 = m1[0][2];
typename tmat2x4<T, P>::value_type SrcA03 = m1[0][3];
typename tmat2x4<T, P>::value_type SrcA10 = m1[1][0];
typename tmat2x4<T, P>::value_type SrcA11 = m1[1][1];
typename tmat2x4<T, P>::value_type SrcA12 = m1[1][2];
typename tmat2x4<T, P>::value_type SrcA13 = m1[1][3];
T SrcA00 = m1[0][0];
T SrcA01 = m1[0][1];
T SrcA02 = m1[0][2];
T SrcA03 = m1[0][3];
T SrcA10 = m1[1][0];
T SrcA11 = m1[1][1];
T SrcA12 = m1[1][2];
T SrcA13 = m1[1][3];
typename tmat2x4<T, P>::value_type SrcB00 = m2[0][0];
typename tmat2x4<T, P>::value_type SrcB01 = m2[0][1];
typename tmat2x4<T, P>::value_type SrcB10 = m2[1][0];
typename tmat2x4<T, P>::value_type SrcB11 = m2[1][1];
typename tmat2x4<T, P>::value_type SrcB20 = m2[2][0];
typename tmat2x4<T, P>::value_type SrcB21 = m2[2][1];
typename tmat2x4<T, P>::value_type SrcB30 = m2[3][0];
typename tmat2x4<T, P>::value_type SrcB31 = m2[3][1];
T SrcB00 = m2[0][0];
T SrcB01 = m2[0][1];
T SrcB10 = m2[1][0];
T SrcB11 = m2[1][1];
T SrcB20 = m2[2][0];
T SrcB21 = m2[2][1];
T SrcB30 = m2[3][0];
T SrcB31 = m2[3][1];
tmat4x4<T, P> Result(tmat4x4<T, P>::null);
Result[0][0] = SrcA00 * SrcB00 + SrcA10 * SrcB01;

View File

@ -50,8 +50,6 @@ namespace detail
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
template <typename U, precision Q>
friend tmat3x3<U, Q> inverse(tmat3x3<U, Q> const & m);
template <typename U, precision Q>
friend tvec3<U, Q> operator/(tmat3x3<U, Q> const & m, tvec3<U, Q> const & v);
template <typename U, precision Q>
@ -60,8 +58,6 @@ namespace detail
private:
/// @cond DETAIL
col_type value[3];
GLM_FUNC_DECL tmat3x3<T, P> _inverse() const;
/// @endcond
public:
@ -155,6 +151,9 @@ namespace detail
GLM_FUNC_DECL tmat3x3<T, P> operator--(int);
};
template <typename T, precision P>
GLM_FUNC_DECL tmat3x3<T, P> compute_inverse_mat3(tmat3x3<T, P> const & m);
// Binary operators
template <typename T, precision P>
GLM_FUNC_DECL tmat3x3<T, P> operator+ (

View File

@ -393,7 +393,7 @@ namespace detail
template <typename U>
GLM_FUNC_QUALIFIER tmat3x3<T, P> & tmat3x3<T, P>::operator/= (tmat3x3<U, P> const & m)
{
return (*this = *this * m._inverse());
return (*this = *this * detail::compute_inverse_mat3(m));
}
template <typename T, precision P>
@ -431,19 +431,19 @@ namespace detail
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat3x3<T, P> tmat3x3<T, P>::_inverse() const
GLM_FUNC_QUALIFIER tmat3x3<T, P> compute_inverse_mat3(tmat3x3<T, P> const & m)
{
T S00 = value[0][0];
T S01 = value[0][1];
T S02 = value[0][2];
T S00 = m[0][0];
T S01 = m[0][1];
T S02 = m[0][2];
T S10 = value[1][0];
T S11 = value[1][1];
T S12 = value[1][2];
T S10 = m[1][0];
T S11 = m[1][1];
T S12 = m[1][2];
T S20 = value[2][0];
T S21 = value[2][1];
T S22 = value[2][2];
T S20 = m[2][0];
T S21 = m[2][1];
T S22 = m[2][2];
/*
tmat3x3<T, P> Inverse(
+ (S11 * S22 - S21 * S12),
@ -467,9 +467,10 @@ namespace detail
S10 * S02 - S12 * S00,
S11 * S00 - S10 * S01);
T Determinant = S00 * (S11 * S22 - S21 * S12)
- S10 * (S01 * S22 - S21 * S02)
+ S20 * (S01 * S12 - S11 * S02);
T Determinant =
+ S00 * (S11 * S22 - S21 * S12)
- S10 * (S01 * S22 - S21 * S02)
+ S20 * (S01 * S12 - S11 * S02);
Inverse /= Determinant;
return Inverse;
@ -615,25 +616,25 @@ namespace detail
tmat3x3<T, P> const & m2
)
{
typename tmat3x3<T, P>::value_type const SrcA00 = m1[0][0];
typename tmat3x3<T, P>::value_type const SrcA01 = m1[0][1];
typename tmat3x3<T, P>::value_type const SrcA02 = m1[0][2];
typename tmat3x3<T, P>::value_type const SrcA10 = m1[1][0];
typename tmat3x3<T, P>::value_type const SrcA11 = m1[1][1];
typename tmat3x3<T, P>::value_type const SrcA12 = m1[1][2];
typename tmat3x3<T, P>::value_type const SrcA20 = m1[2][0];
typename tmat3x3<T, P>::value_type const SrcA21 = m1[2][1];
typename tmat3x3<T, P>::value_type const SrcA22 = m1[2][2];
T const SrcA00 = m1[0][0];
T const SrcA01 = m1[0][1];
T const SrcA02 = m1[0][2];
T const SrcA10 = m1[1][0];
T const SrcA11 = m1[1][1];
T const SrcA12 = m1[1][2];
T const SrcA20 = m1[2][0];
T const SrcA21 = m1[2][1];
T const SrcA22 = m1[2][2];
typename tmat3x3<T, P>::value_type const SrcB00 = m2[0][0];
typename tmat3x3<T, P>::value_type const SrcB01 = m2[0][1];
typename tmat3x3<T, P>::value_type const SrcB02 = m2[0][2];
typename tmat3x3<T, P>::value_type const SrcB10 = m2[1][0];
typename tmat3x3<T, P>::value_type const SrcB11 = m2[1][1];
typename tmat3x3<T, P>::value_type const SrcB12 = m2[1][2];
typename tmat3x3<T, P>::value_type const SrcB20 = m2[2][0];
typename tmat3x3<T, P>::value_type const SrcB21 = m2[2][1];
typename tmat3x3<T, P>::value_type const SrcB22 = m2[2][2];
T const SrcB00 = m2[0][0];
T const SrcB01 = m2[0][1];
T const SrcB02 = m2[0][2];
T const SrcB10 = m2[1][0];
T const SrcB11 = m2[1][1];
T const SrcB12 = m2[1][2];
T const SrcB20 = m2[2][0];
T const SrcB21 = m2[2][1];
T const SrcB22 = m2[2][2];
tmat3x3<T, P> Result(tmat3x3<T, P>::_null);
Result[0][0] = SrcA00 * SrcB00 + SrcA10 * SrcB01 + SrcA20 * SrcB02;
@ -719,7 +720,7 @@ namespace detail
typename tmat3x3<T, P>::row_type const & v
)
{
return m._inverse() * v;
return detail::compute_inverse_mat3(m) * v;
}
template <typename T, precision P>
@ -729,7 +730,7 @@ namespace detail
tmat3x3<T, P> const & m
)
{
return v * m._inverse();
return v * detail::compute_inverse_mat3(m);
}
template <typename T, precision P>

View File

@ -54,8 +54,6 @@ namespace detail
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
template <typename U, precision Q>
friend tmat4x4<U, Q> inverse(tmat4x4<U, Q> const & m);
template <typename U, precision Q>
friend tvec4<U, Q> operator/(tmat4x4<U, Q> const & m, tvec4<U, Q> const & v);
template <typename U, precision Q>
@ -64,9 +62,6 @@ namespace detail
private:
/// @cond DETAIL
col_type value[4];
GLM_FUNC_DECL tmat4x4<T, P> _inverse() const;
/// @endcond
public:
// Constructors
@ -165,6 +160,9 @@ namespace detail
GLM_FUNC_DECL tmat4x4<T, P> operator--(int);
};
template <typename T, precision P>
GLM_FUNC_DECL tmat4x4<T, P> compute_inverse_mat4(tmat4x4<T, P> const & m);
// Binary operators
template <typename T, precision P>
GLM_FUNC_DECL tmat4x4<T, P> operator+ (

View File

@ -66,8 +66,8 @@ namespace detail
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P>::tmat4x4()
{
value_type Zero(0);
value_type One(1);
T Zero(0);
T One(1);
this->value[0] = col_type(One, Zero, Zero, Zero);
this->value[1] = col_type(Zero, One, Zero, Zero);
this->value[2] = col_type(Zero, Zero, One, Zero);
@ -461,7 +461,7 @@ namespace detail
template <typename U>
GLM_FUNC_QUALIFIER tmat4x4<T, P> & tmat4x4<T, P>::operator/= (tmat4x4<U, P> const & m)
{
return (*this = *this * m._inverse());
return (*this = *this * detail::compute_inverse_mat4(m));
}
template <typename T, precision P>
@ -501,76 +501,48 @@ namespace detail
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER tmat4x4<T, P> tmat4x4<T, P>::_inverse() const
GLM_FUNC_QUALIFIER tmat4x4<T, P> compute_inverse_mat4(tmat4x4<T, P> const & m)
{
// Calculate all mat2 determinants
value_type SubFactor00 = this->value[2][2] * this->value[3][3] - this->value[3][2] * this->value[2][3];
value_type SubFactor01 = this->value[2][1] * this->value[3][3] - this->value[3][1] * this->value[2][3];
value_type SubFactor02 = this->value[2][1] * this->value[3][2] - this->value[3][1] * this->value[2][2];
value_type SubFactor03 = this->value[2][0] * this->value[3][3] - this->value[3][0] * this->value[2][3];
value_type SubFactor04 = this->value[2][0] * this->value[3][2] - this->value[3][0] * this->value[2][2];
value_type SubFactor05 = this->value[2][0] * this->value[3][1] - this->value[3][0] * this->value[2][1];
value_type SubFactor06 = this->value[1][2] * this->value[3][3] - this->value[3][2] * this->value[1][3];
value_type SubFactor07 = this->value[1][1] * this->value[3][3] - this->value[3][1] * this->value[1][3];
value_type SubFactor08 = this->value[1][1] * this->value[3][2] - this->value[3][1] * this->value[1][2];
value_type SubFactor09 = this->value[1][0] * this->value[3][3] - this->value[3][0] * this->value[1][3];
value_type SubFactor10 = this->value[1][0] * this->value[3][2] - this->value[3][0] * this->value[1][2];
value_type SubFactor11 = this->value[1][1] * this->value[3][3] - this->value[3][1] * this->value[1][3];
value_type SubFactor12 = this->value[1][0] * this->value[3][1] - this->value[3][0] * this->value[1][1];
value_type SubFactor13 = this->value[1][2] * this->value[2][3] - this->value[2][2] * this->value[1][3];
value_type SubFactor14 = this->value[1][1] * this->value[2][3] - this->value[2][1] * this->value[1][3];
value_type SubFactor15 = this->value[1][1] * this->value[2][2] - this->value[2][1] * this->value[1][2];
value_type SubFactor16 = this->value[1][0] * this->value[2][3] - this->value[2][0] * this->value[1][3];
value_type SubFactor17 = this->value[1][0] * this->value[2][2] - this->value[2][0] * this->value[1][2];
value_type SubFactor18 = this->value[1][0] * this->value[2][1] - this->value[2][0] * this->value[1][1];
/*
T const SubFactor00 = m[2][2] * m[3][3] - m[3][2] * m[2][3];
T const SubFactor01 = m[2][1] * m[3][3] - m[3][1] * m[2][3];
T const SubFactor02 = m[2][1] * m[3][2] - m[3][1] * m[2][2];
T const SubFactor03 = m[2][0] * m[3][3] - m[3][0] * m[2][3];
T const SubFactor04 = m[2][0] * m[3][2] - m[3][0] * m[2][2];
T const SubFactor05 = m[2][0] * m[3][1] - m[3][0] * m[2][1];
T const SubFactor06 = m[1][2] * m[3][3] - m[3][2] * m[1][3];
T const SubFactor07 = m[1][1] * m[3][3] - m[3][1] * m[1][3];
T const SubFactor08 = m[1][1] * m[3][2] - m[3][1] * m[1][2];
T const SubFactor09 = m[1][0] * m[3][3] - m[3][0] * m[1][3];
T const SubFactor10 = m[1][0] * m[3][2] - m[3][0] * m[1][2];
T const SubFactor11 = m[1][1] * m[3][3] - m[3][1] * m[1][3];
T const SubFactor12 = m[1][0] * m[3][1] - m[3][0] * m[1][1];
T const SubFactor13 = m[1][2] * m[2][3] - m[2][2] * m[1][3];
T const SubFactor14 = m[1][1] * m[2][3] - m[2][1] * m[1][3];
T const SubFactor15 = m[1][1] * m[2][2] - m[2][1] * m[1][2];
T const SubFactor16 = m[1][0] * m[2][3] - m[2][0] * m[1][3];
T const SubFactor17 = m[1][0] * m[2][2] - m[2][0] * m[1][2];
T const SubFactor18 = m[1][0] * m[2][1] - m[2][0] * m[1][1];
tmat4x4<T, P> Inverse(
+ (this->value[1][1] * SubFactor00 - this->value[1][2] * SubFactor01 + this->value[1][3] * SubFactor02),
- (this->value[1][0] * SubFactor00 - this->value[1][2] * SubFactor03 + this->value[1][3] * SubFactor04),
+ (this->value[1][0] * SubFactor01 - this->value[1][1] * SubFactor03 + this->value[1][3] * SubFactor05),
- (this->value[1][0] * SubFactor02 - this->value[1][1] * SubFactor04 + this->value[1][2] * SubFactor05),
- (this->value[0][1] * SubFactor00 - this->value[0][2] * SubFactor01 + this->value[0][3] * SubFactor02),
+ (this->value[0][0] * SubFactor00 - this->value[0][2] * SubFactor03 + this->value[0][3] * SubFactor04),
- (this->value[0][0] * SubFactor01 - this->value[0][1] * SubFactor03 + this->value[0][3] * SubFactor05),
+ (this->value[0][0] * SubFactor02 - this->value[0][1] * SubFactor04 + this->value[0][2] * SubFactor05),
+ (this->value[0][1] * SubFactor06 - this->value[0][2] * SubFactor07 + this->value[0][3] * SubFactor08),
- (this->value[0][0] * SubFactor06 - this->value[0][2] * SubFactor09 + this->value[0][3] * SubFactor10),
+ (this->value[0][0] * SubFactor11 - this->value[0][1] * SubFactor09 + this->value[0][3] * SubFactor12),
- (this->value[0][0] * SubFactor08 - this->value[0][1] * SubFactor10 + this->value[0][2] * SubFactor12),
- (this->value[0][1] * SubFactor13 - this->value[0][2] * SubFactor14 + this->value[0][3] * SubFactor15),
+ (this->value[0][0] * SubFactor13 - this->value[0][2] * SubFactor16 + this->value[0][3] * SubFactor17),
- (this->value[0][0] * SubFactor14 - this->value[0][1] * SubFactor16 + this->value[0][3] * SubFactor18),
+ (this->value[0][0] * SubFactor15 - this->value[0][1] * SubFactor17 + this->value[0][2] * SubFactor18));
*/
tmat4x4<T, P> Inverse(
+ this->value[1][1] * SubFactor00 - this->value[1][2] * SubFactor01 + this->value[1][3] * SubFactor02,
- this->value[1][0] * SubFactor00 + this->value[1][2] * SubFactor03 - this->value[1][3] * SubFactor04,
+ this->value[1][0] * SubFactor01 - this->value[1][1] * SubFactor03 + this->value[1][3] * SubFactor05,
- this->value[1][0] * SubFactor02 + this->value[1][1] * SubFactor04 - this->value[1][2] * SubFactor05,
- this->value[0][1] * SubFactor00 + this->value[0][2] * SubFactor01 - this->value[0][3] * SubFactor02,
+ this->value[0][0] * SubFactor00 - this->value[0][2] * SubFactor03 + this->value[0][3] * SubFactor04,
- this->value[0][0] * SubFactor01 + this->value[0][1] * SubFactor03 - this->value[0][3] * SubFactor05,
+ this->value[0][0] * SubFactor02 - this->value[0][1] * SubFactor04 + this->value[0][2] * SubFactor05,
+ this->value[0][1] * SubFactor06 - this->value[0][2] * SubFactor07 + this->value[0][3] * SubFactor08,
- this->value[0][0] * SubFactor06 + this->value[0][2] * SubFactor09 - this->value[0][3] * SubFactor10,
+ this->value[0][0] * SubFactor11 - this->value[0][1] * SubFactor09 + this->value[0][3] * SubFactor12,
- this->value[0][0] * SubFactor08 + this->value[0][1] * SubFactor10 - this->value[0][2] * SubFactor12,
- this->value[0][1] * SubFactor13 + this->value[0][2] * SubFactor14 - this->value[0][3] * SubFactor15,
+ this->value[0][0] * SubFactor13 - this->value[0][2] * SubFactor16 + this->value[0][3] * SubFactor17,
- this->value[0][0] * SubFactor14 + this->value[0][1] * SubFactor16 - this->value[0][3] * SubFactor18,
+ this->value[0][0] * SubFactor15 - this->value[0][1] * SubFactor17 + this->value[0][2] * SubFactor18);
T Determinant = static_cast<T>(
+ this->value[0][0] * Inverse[0][0]
+ this->value[0][1] * Inverse[1][0]
+ this->value[0][2] * Inverse[2][0]
+ this->value[0][3] * Inverse[3][0]);
+ m[1][1] * SubFactor00 - m[1][2] * SubFactor01 + m[1][3] * SubFactor02,
- m[1][0] * SubFactor00 + m[1][2] * SubFactor03 - m[1][3] * SubFactor04,
+ m[1][0] * SubFactor01 - m[1][1] * SubFactor03 + m[1][3] * SubFactor05,
- m[1][0] * SubFactor02 + m[1][1] * SubFactor04 - m[1][2] * SubFactor05,
- m[0][1] * SubFactor00 + m[0][2] * SubFactor01 - m[0][3] * SubFactor02,
+ m[0][0] * SubFactor00 - m[0][2] * SubFactor03 + m[0][3] * SubFactor04,
- m[0][0] * SubFactor01 + m[0][1] * SubFactor03 - m[0][3] * SubFactor05,
+ m[0][0] * SubFactor02 - m[0][1] * SubFactor04 + m[0][2] * SubFactor05,
+ m[0][1] * SubFactor06 - m[0][2] * SubFactor07 + m[0][3] * SubFactor08,
- m[0][0] * SubFactor06 + m[0][2] * SubFactor09 - m[0][3] * SubFactor10,
+ m[0][0] * SubFactor11 - m[0][1] * SubFactor09 + m[0][3] * SubFactor12,
- m[0][0] * SubFactor08 + m[0][1] * SubFactor10 - m[0][2] * SubFactor12,
- m[0][1] * SubFactor13 + m[0][2] * SubFactor14 - m[0][3] * SubFactor15,
+ m[0][0] * SubFactor13 - m[0][2] * SubFactor16 + m[0][3] * SubFactor17,
- m[0][0] * SubFactor14 + m[0][1] * SubFactor16 - m[0][3] * SubFactor18,
+ m[0][0] * SubFactor15 - m[0][1] * SubFactor17 + m[0][2] * SubFactor18);
T Determinant = static_cast<T>(+ m[0][0] * Inverse[0][0] + m[0][1] * Inverse[1][0] + m[0][2] * Inverse[2][0] + m[0][3] * Inverse[3][0]);
Inverse /= Determinant;
return Inverse;
@ -851,7 +823,7 @@ namespace detail
typename tmat4x4<T, P>::row_type const & v
)
{
return m._inverse() * v;
return detail::compute_inverse_mat4(m) * v;
}
template <typename T, precision P>
@ -861,7 +833,7 @@ namespace detail
tmat4x4<T, P> const & m
)
{
return v * m._inverse();
return v * detail::compute_inverse_mat4(m);
}
template <typename T, precision P>
@ -897,10 +869,10 @@ namespace detail
)
{
return tmat4x4<T, P>(
m[0] + typename tmat4x4<T, P>::value_type(1),
m[1] + typename tmat4x4<T, P>::value_type(1),
m[2] + typename tmat4x4<T, P>::value_type(1),
m[3] + typename tmat4x4<T, P>::value_type(1));
m[0] + static_cast<T>(1),
m[1] + static_cast<T>(1),
m[2] + static_cast<T>(1),
m[3] + static_cast<T>(1));
}
template <typename T, precision P>
@ -911,10 +883,10 @@ namespace detail
)
{
return tmat4x4<T, P>(
m[0] - typename tmat4x4<T, P>::value_type(1),
m[1] - typename tmat4x4<T, P>::value_type(1),
m[2] - typename tmat4x4<T, P>::value_type(1),
m[3] - typename tmat4x4<T, P>::value_type(1));
m[0] - static_cast<T>(1),
m[1] - static_cast<T>(1),
m[2] - static_cast<T>(1),
m[3] - static_cast<T>(1));
}
//////////////////////////////////////

View File

@ -39,27 +39,6 @@ namespace detail
template <typename T, precision P> struct tvec2;
template <typename T, precision P> struct tvec3;
template <typename T, precision P> struct tvec4;
template <typename T>
struct is_vector
{
enum is_vector_enum
{
_YES = 0,
_NO = 1
};
};
# define GLM_DETAIL_IS_VECTOR(TYPE) \
template <typename T, precision P> \
struct is_vector<TYPE<T, P> > \
{ \
enum is_vector_enum \
{ \
_YES = 1, \
_NO = 0 \
}; \
}
}//namespace detail
typedef detail::tvec1<float, highp> highp_vec1_t;

View File

@ -95,18 +95,6 @@ namespace detail
GLM_FUNC_DECL explicit tvec1(
T const & s);
//////////////////////////////////////
// Swizzle constructors
//////////////////////////////////////
// Conversion scalar constructors
//! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U>
GLM_FUNC_DECL explicit tvec1(U const & s);
//////////////////////////////////////
// Conversion vector constructors
@ -184,7 +172,108 @@ namespace detail
GLM_FUNC_DECL tvec1<T, P> & operator>>=(tvec1<U, P> const & v);
};
GLM_DETAIL_IS_VECTOR(tvec1);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator+(tvec1<T, P> const & v, T const & s);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator+(T const & s, tvec1<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator+(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator-(tvec1<T, P> const & v, T const & s);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator-(T const & s, tvec1<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator- (tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator*(tvec1<T, P> const & v, T const & s);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator*(T const & s, tvec1<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator*(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator/(tvec1<T, P> const & v, T const & s);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator/(T const & s, tvec1<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator/(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator-(tvec1<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL bool operator==(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL bool operator!=(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator%(tvec1<T, P> const & v, T const & s);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator%(T const & s, tvec1<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator%(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator&(tvec1<T, P> const & v, T const & s);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator&(T const & s, tvec1<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator&(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator|(tvec1<T, P> const & v, T const & s);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator|(T const & s, tvec1<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator|(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator^(tvec1<T, P> const & v, T const & s);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator^(T const & s, tvec1<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator^(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator<<(tvec1<T, P> const & v, T const & s);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator<<(T const & s, tvec1<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator<<(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator>>(tvec1<T, P> const & v, T const & s);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator>>(T const & s, tvec1<T, P> const & v);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator>>(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <typename T, precision P>
GLM_FUNC_DECL tvec1<T, P> operator~(tvec1<T, P> const & v);
}//namespace detail
}//namespace glm

View File

@ -93,18 +93,6 @@ namespace detail
x(s)
{}
//////////////////////////////////////
// Conversion scalar constructors
template <typename T, precision P>
template <typename U>
GLM_FUNC_QUALIFIER tvec1<T, P>::tvec1
(
U const & s
) :
x(static_cast<T>(s))
{}
//////////////////////////////////////
// Conversion vector constructors
@ -454,7 +442,7 @@ namespace detail
GLM_FUNC_QUALIFIER tvec1<T, P> operator+
(
tvec1<T, P> const & v,
typename tvec1<T, P>::T const & s
T const & s
)
{
return tvec1<T, P>(
@ -464,7 +452,7 @@ namespace detail
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator+
(
typename tvec1<T, P>::T const & s,
T const & s,
tvec1<T, P> const & v
)
{
@ -488,7 +476,7 @@ namespace detail
GLM_FUNC_QUALIFIER tvec1<T, P> operator-
(
tvec1<T, P> const & v,
typename tvec1<T, P>::T const & s
T const & s
)
{
return tvec1<T, P>(
@ -498,7 +486,7 @@ namespace detail
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator-
(
typename tvec1<T, P>::T const & s,
T const & s,
tvec1<T, P> const & v
)
{
@ -522,7 +510,7 @@ namespace detail
GLM_FUNC_QUALIFIER tvec1<T, P> operator*
(
tvec1<T, P> const & v,
typename tvec1<T, P>::T const & s
T const & s
)
{
return tvec1<T, P>(
@ -532,7 +520,7 @@ namespace detail
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator*
(
typename tvec1<T, P>::T const & s,
T const & s,
tvec1<T, P> const & v
)
{
@ -556,7 +544,7 @@ namespace detail
GLM_FUNC_QUALIFIER tvec1<T, P> operator/
(
tvec1<T, P> const & v,
typename tvec1<T, P>::T const & s
T const & s
)
{
return tvec1<T, P>(
@ -566,7 +554,7 @@ namespace detail
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator/
(
typename tvec1<T, P>::T const & s,
T const & s,
tvec1<T, P> const & v
)
{
@ -625,7 +613,7 @@ namespace detail
GLM_FUNC_QUALIFIER tvec1<T, P> operator%
(
tvec1<T, P> const & v,
typename tvec1<T, P>::T const & s
T const & s
)
{
return tvec1<T, P>(
@ -635,7 +623,7 @@ namespace detail
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator%
(
typename tvec1<T, P>::T const & s,
T const & s,
tvec1<T, P> const & v
)
{
@ -658,7 +646,7 @@ namespace detail
GLM_FUNC_QUALIFIER tvec1<T, P> operator&
(
tvec1<T, P> const & v,
typename tvec1<T, P>::T const & s
T const & s
)
{
return tvec1<T, P>(
@ -668,7 +656,7 @@ namespace detail
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator&
(
typename tvec1<T, P>::T const & s,
T const & s,
tvec1<T, P> const & v
)
{
@ -691,7 +679,7 @@ namespace detail
GLM_FUNC_QUALIFIER tvec1<T, P> operator|
(
tvec1<T, P> const & v,
typename tvec1<T, P>::T const & s
T const & s
)
{
return tvec1<T, P>(
@ -701,7 +689,7 @@ namespace detail
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator|
(
typename tvec1<T, P>::T const & s,
T const & s,
tvec1<T, P> const & v
)
{
@ -724,7 +712,7 @@ namespace detail
GLM_FUNC_QUALIFIER tvec1<T, P> operator^
(
tvec1<T, P> const & v,
typename tvec1<T, P>::T const & s
T const & s
)
{
return tvec1<T, P>(
@ -734,7 +722,7 @@ namespace detail
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator^
(
typename tvec1<T, P>::T const & s,
T const & s,
tvec1<T, P> const & v
)
{
@ -757,7 +745,7 @@ namespace detail
GLM_FUNC_QUALIFIER tvec1<T, P> operator<<
(
tvec1<T, P> const & v,
typename tvec1<T, P>::T const & s
T const & s
)
{
return tvec1<T, P>(
@ -767,7 +755,7 @@ namespace detail
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator<<
(
typename tvec1<T, P>::T const & s,
T const & s,
tvec1<T, P> const & v
)
{
@ -790,7 +778,7 @@ namespace detail
GLM_FUNC_QUALIFIER tvec1<T, P> operator>>
(
tvec1<T, P> const & v,
typename tvec1<T, P>::T const & s
T const & s
)
{
return tvec1<T, P>(
@ -800,7 +788,7 @@ namespace detail
template <typename T, precision P>
GLM_FUNC_QUALIFIER tvec1<T, P> operator>>
(
typename tvec1<T, P>::T const & s,
T const & s,
tvec1<T, P> const & v
)
{

View File

@ -217,8 +217,6 @@ namespace detail
GLM_FUNC_DECL tvec2<T, P> & operator>>=(tvec2<U, P> const & v);
};
GLM_DETAIL_IS_VECTOR(tvec2);
template <typename T, precision P>
GLM_FUNC_DECL tvec2<T, P> operator+(tvec2<T, P> const & v, T const & s);

View File

@ -235,8 +235,6 @@ namespace detail
GLM_FUNC_DECL tvec3<T, P> & operator>>=(tvec3<U, P> const & v);
};
GLM_DETAIL_IS_VECTOR(tvec3);
template <typename T, precision P>
GLM_FUNC_DECL tvec3<T, P> operator+(tvec3<T, P> const & v, T const & s);

View File

@ -317,8 +317,6 @@ namespace detail
GLM_FUNC_DECL tvec4<T, P> & operator>>=(tvec4<U, P> const & v);
};
GLM_DETAIL_IS_VECTOR(tvec4);
template <typename T, precision P>
GLM_FUNC_DECL tvec4<T, P> operator+(tvec4<T, P> const & v, T const & s);

View File

@ -92,14 +92,26 @@
# pragma message("GLM: Core library included")
#endif//GLM_MESSAGE
#include "./detail/func_trigonometric.hpp"
#include "./detail/func_exponential.hpp"
#include "./detail/func_common.hpp"
#include "./detail/func_packing.hpp"
#include "./detail/func_geometric.hpp"
#include "./detail/func_matrix.hpp"
#include "./detail/func_vector_relational.hpp"
#include "./detail/func_integer.hpp"
#include "./detail/func_noise.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"
#include "trigonometric.hpp"
#include "exponential.hpp"
#include "common.hpp"
#include "packing.hpp"
#include "geometric.hpp"
#include "matrix.hpp"
#include "vector_relational.hpp"
#include "integer.hpp"
#endif//GLM_INCLUDED

View File

@ -384,14 +384,14 @@ namespace glm
detail::tvec4<U, P> const & viewport
)
{
detail::tmat4x4<T, P> inverse = glm::inverse(proj * model);
detail::tmat4x4<T, P> Inverse = inverse(proj * model);
detail::tvec4<T, P> tmp = detail::tvec4<T, P>(win, T(1));
tmp.x = (tmp.x - T(viewport[0])) / T(viewport[2]);
tmp.y = (tmp.y - T(viewport[1])) / T(viewport[3]);
tmp = tmp * T(2) - T(1);
detail::tvec4<T, P> obj = inverse * tmp;
detail::tvec4<T, P> obj = Inverse * tmp;
obj /= obj.w;
return detail::tvec3<T, P>(obj);

View File

@ -457,7 +457,7 @@ namespace detail
(
detail::tquat<T, P> const & x,
detail::tquat<T, P> const & y,
typename detail::tquat<T, P>::T const & a
T const & a
)
{
if(a <= T(0)) return x;
@ -617,7 +617,7 @@ namespace detail
GLM_FUNC_QUALIFIER detail::tquat<T, P> rotate
(
detail::tquat<T, P> const & q,
typename detail::tquat<T, P>::value_type const & angle,
T const & angle,
detail::tvec3<T, P> const & v
)
{

View File

@ -289,7 +289,7 @@ namespace detail
// Lerp is only defined in [0, 1]
assert(a >= static_cast<T>(0));
assert(a <= static_cast<T>(1));
T const k = dot(x.real,y.real) < detail::tdualquat<T, P>::value_type(0) ? -a : a;
T const k = dot(x.real,y.real) < static_cast<T>(0) ? -a : a;
T const one(1);
return detail::tdualquat<T, P>(x * (one - a) + y * k);
}
@ -304,15 +304,7 @@ namespace detail
const glm::detail::tquat<T, P> dual = conjugate(q.dual);
return detail::tdualquat<T, P>(real, dual + (real * (-2.0f * dot(real,dual))));
}
/*
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tmat3x3<T, P> mat3_cast
(
detail::tdualquat<T, P> const & x
)
{
}
*/
template <typename T, precision P>
GLM_FUNC_QUALIFIER detail::tmat2x4<T, P> mat2x4_cast
(

View File

@ -24,13 +24,18 @@ namespace glm
VECTORIZE_VEC(fastSqrt)
// fastInversesqrt
template <typename genType>
GLM_FUNC_QUALIFIER genType fastInverseSqrt
GLM_FUNC_QUALIFIER float fastInverseSqrt(float x)
{
return detail::compute_inversesqrt<detail::tvec1, float, lowp>::call(detail::tvec1<float, lowp>(x)).x;
}
template <template <class, precision> class vecType, typename T, precision P>
GLM_FUNC_QUALIFIER vecType<T, P> fastInverseSqrt
(
genType const & x
vecType<T, P> const & x
)
{
return detail::fastInversesqrt<genType, uint>(x);
return detail::compute_inversesqrt<vecType, T, P>::call(x);
}
VECTORIZE_VEC(fastInverseSqrt)

View File

@ -74,7 +74,7 @@ namespace glm
template <typename genType>
bool intersectRaySphere(
genType const & rayStarting, genType const & rayNormalizedDirection,
genType const & sphereCenter, const typename genType::value_type sphereRadiusSquered,
genType const & sphereCenter, typename genType::value_type const sphereRadiusSquered,
typename genType::value_type & intersectionDistance);
//! Compute the intersection of a ray and a sphere.

View File

@ -56,58 +56,42 @@ namespace glm
/// Return whether a matrix a null matrix.
/// From GLM_GTX_matrix_query extension.
template<typename T, precision P>
bool isNull(
detail::tmat2x2<T, P> const & m,
T const & epsilon/* = std::numeric_limits<T>::epsilon()*/);
bool isNull(detail::tmat2x2<T, P> const & m, T const & epsilon);
/// Return whether a matrix a null matrix.
/// From GLM_GTX_matrix_query extension.
template<typename T, precision P>
bool isNull(
detail::tmat3x3<T, P> const & m,
T const & epsilon/* = std::numeric_limits<T>::epsilon()*/);
bool isNull(detail::tmat3x3<T, P> const & m, T const & epsilon);
/// Return whether a matrix is a null matrix.
/// From GLM_GTX_matrix_query extension.
template<typename T, precision P>
bool isNull(
detail::tmat4x4<T, P> const & m,
T const & epsilon/* = std::numeric_limits<T>::epsilon()*/);
bool isNull(detail::tmat4x4<T, P> const & m, T const & epsilon);
/// Return whether a matrix is an identity matrix.
/// From GLM_GTX_matrix_query extension.
template<typename genType>
bool isIdentity(
genType const & m,
typename genType::T const & epsilon/* = std::numeric_limits<typename genType::value_type>::epsilon()*/);
template<typename T, precision P, template <typename, precision> class matType>
bool isIdentity(matType<T, P> const & m, T const & epsilon);
/// Return whether a matrix is a normalized matrix.
/// From GLM_GTX_matrix_query extension.
template<typename T, precision P>
bool isNormalized(
detail::tmat2x2<T, P> const & m,
T const & epsilon/* = std::numeric_limits<T>::epsilon()*/);
bool isNormalized(detail::tmat2x2<T, P> const & m, T const & epsilon);
/// Return whether a matrix is a normalized matrix.
/// From GLM_GTX_matrix_query extension.
template<typename T, precision P>
bool isNormalized(
detail::tmat3x3<T, P> const & m,
T const & epsilon/* = std::numeric_limits<valType>::epsilon()*/);
bool isNormalized(detail::tmat3x3<T, P> const & m, T const & epsilon);
/// Return whether a matrix is a normalized matrix.
/// From GLM_GTX_matrix_query extension.
template<typename T, precision P>
bool isNormalized(
detail::tmat4x4<T, P> const & m,
T const & epsilon/* = std::numeric_limits<valType>::epsilon()*/);
bool isNormalized(detail::tmat4x4<T, P> const & m, T const & epsilon);
/// Return whether a matrix is an orthonormalized matrix.
/// From GLM_GTX_matrix_query extension.
template<typename T, precision P, template <typename, precision> class matType>
bool isOrthogonal(
matType<T, P> const & m,
T const & epsilon/* = std::numeric_limits<genType>::epsilon()*/);
bool isOrthogonal(matType<T, P> const & m, T const & epsilon);
/// @}
}//namespace glm

View File

@ -81,7 +81,7 @@ namespace glm
template <typename T, precision P>
detail::tquat<T, P> rotateNormalizedAxis(
detail::tquat<T, P> const & q,
typename detail::tquat<T, P>::T const & angle,
T const & angle,
detail::tvec3<T, P> const & axis);
/// @}

View File

@ -74,7 +74,7 @@ namespace glm
GLM_FUNC_QUALIFIER detail::tquat<T, P> rotateNormalizedAxis
(
detail::tquat<T, P> const & q,
typename detail::tquat<T, P>::T const & angle,
T const & angle,
detail::tvec3<T, P> const & v
)
{
@ -88,7 +88,7 @@ namespace glm
#endif
T const Sin = sin(AngleRad * T(0.5));
return q * detail::tquat<T, P>(cos(AngleRad * T(0.5)), Tmp.x * Sin, Tmp.y * Sin, Tmp.z * Sin);
return q * detail::tquat<T, P>(cos(AngleRad * static_cast<T>(0.5)), Tmp.x * Sin, Tmp.y * Sin, Tmp.z * Sin);
//return gtc::quaternion::cross(q, detail::tquat<T, P>(cos(AngleRad * T(0.5)), Tmp.x * fSin, Tmp.y * fSin, Tmp.z * fSin));
}
}//namespace glm

View File

@ -54,55 +54,33 @@ namespace glm
//! Check whether two vectors are collinears.
/// @see gtx_vector_query extensions.
template <typename genType>
bool areCollinear(
genType const & v0,
genType const & v1,
typename genType::T const & epsilon);
template <typename T, precision P, template <typename, precision> class vecType>
bool areCollinear(vecType<T, P> const & v0, vecType<T, P> const & v1, T const & epsilon);
//! Check whether two vectors are orthogonals.
/// @see gtx_vector_query extensions.
template <typename genType>
bool areOrthogonal(
genType const & v0,
genType const & v1,
typename genType::T const & epsilon);
template <typename T, precision P, template <typename, precision> class vecType>
bool areOrthogonal(vecType<T, P> const & v0, vecType<T, P> const & v1, T const & epsilon);
//! Check whether a vector is normalized.
/// @see gtx_vector_query extensions.
template <typename genType, precision P, template <typename, precision> class vecType>
bool isNormalized(
vecType<genType, P> const & v,
genType const & epsilon);
template <typename T, precision P, template <typename, precision> class vecType>
bool isNormalized(vecType<T, P> const & v, T const & epsilon);
//! Check whether a vector is null.
/// @see gtx_vector_query extensions.
template <typename T, precision P>
bool isNull(
detail::tvec2<T, P> const & v,
T const & epsilon);
template <typename T, precision P, template <typename, precision> class vecType>
bool isNull(vecType<T, P> const & v, T const & epsilon);
//! Check whether a vector is null.
//! Check whether a each component of a vector is null.
/// @see gtx_vector_query extensions.
template <typename T, precision P>
bool isNull(
detail::tvec3<T, P> const & v,
T const & epsilon);
//! Check whether a vector is null.
/// @see gtx_vector_query extensions.
template <typename T, precision P>
bool isNull(
detail::tvec4<T, P> const & v,
T const & epsilon);
template <typename T, precision P, template <typename, precision> class vecType>
vecType<bool, P> isCompNull(vecType<T, P> const & v, T const & epsilon);
//! Check whether two vectors are orthonormal.
/// @see gtx_vector_query extensions.
template <typename genType>
bool areOrthonormal(
genType const & v0,
genType const & v1,
typename genType::T const & epsilon);
template <typename T, precision P, template <typename, precision> class vecType>
bool areOrthonormal(vecType<T, P> const & v0, vecType<T, P> const & v1, T const & epsilon);
/// @}
}// namespace glm

View File

@ -12,39 +12,91 @@
#include <cassert>
namespace glm
namespace glm{
namespace detail
{
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool areCollinear
(
detail::tvec2<T, P> const & v0,
detail::tvec2<T, P> const & v1,
T const & epsilon
)
{
return length(cross(detail::tvec3<T, P>(v0, T(0)), detail::tvec3<T, P>(v1, T(0)))) < epsilon;
}
template <typename T, precision P, template <typename, precision> class vecType>
struct compute_areCollinear{};
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool areCollinear
(
detail::tvec3<T, P> const & v0,
detail::tvec3<T, P> const & v1,
T const & epsilon
)
struct compute_areCollinear<T, P, tvec2>
{
return length(cross(v0, v1)) < epsilon;
}
static bool call(detail::tvec2<T, P> const & v0, detail::tvec2<T, P> const & v1, T const & epsilon)
{
return length(cross(detail::tvec3<T, P>(v0, static_cast<T>(0)), detail::tvec3<T, P>(v1, static_cast<T>(0)))) < epsilon;
}
};
template <typename T, precision P>
struct compute_areCollinear<T, P, tvec3>
{
static bool call(detail::tvec3<T, P> const & v0, detail::tvec3<T, P> const & v1, T const & epsilon)
{
return length(cross(v0, v1)) < epsilon;
}
};
template <typename T, precision P>
struct compute_areCollinear<T, P, tvec4>
{
static bool call(detail::tvec4<T, P> const & v0, detail::tvec4<T, P> const & v1, T const & epsilon)
{
return length(cross(detail::tvec3<T, P>(v0), detail::tvec3<T, P>(v1))) < epsilon;
}
};
template <typename T, precision P, template <typename, precision> class vecType>
struct compute_isCompNull{};
template <typename T, precision P>
struct compute_isCompNull<T, P, tvec2>
{
static detail::tvec2<bool, P> call(detail::tvec2<T, P> const & v, T const & epsilon)
{
return detail::tvec2<bool, P>(
(abs(v.x) < epsilon),
(abs(v.y) < epsilon));
}
};
template <typename T, precision P>
struct compute_isCompNull<T, P, tvec3>
{
static detail::tvec3<bool, P> call(detail::tvec3<T, P> const & v, T const & epsilon)
{
return detail::tvec3<bool, P>(
(abs(v.x) < epsilon),
(abs(v.y) < epsilon),
(abs(v.z) < epsilon));
}
};
template <typename T, precision P>
struct compute_isCompNull<T, P, tvec4>
{
static detail::tvec4<bool, P> call(detail::tvec4<T, P> const & v, T const & epsilon)
{
return detail::tvec4<bool, P>(
(abs(v.x) < epsilon),
(abs(v.y) < epsilon),
(abs(v.z) < epsilon),
(abs(v.w) < epsilon));
}
};
}//namespace detail
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER bool areCollinear
(
detail::tvec4<T, P> const & v0,
detail::tvec4<T, P> const & v1,
vecType<T, P> const & v0,
vecType<T, P> const & v1,
T const & epsilon
)
{
return length(cross(detail::tvec3<T, P>(v0), detail::tvec3<T, P>(v1))) < epsilon;
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'areCollinear' only accept floating-point inputs");
return detail::compute_areCollinear<T, P, vecType>::call(v0, v1, epsilon);
}
template <typename T, precision P, template <typename, precision> class vecType>
@ -55,11 +107,11 @@ namespace glm
T const & epsilon
)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'areOrthogonal' only accept floating-point inputs");
return abs(dot(v0, v1)) <= max(
T(1),
length(v0)) * max(
T(1),
length(v1)) * epsilon;
static_cast<T>(1),
length(v0)) * max(static_cast<T>(1), length(v1)) * epsilon;
}
template <typename T, precision P, template <typename, precision> class vecType>
@ -69,47 +121,33 @@ namespace glm
T const & epsilon
)
{
return abs(length(v) - T(1)) <= T(2) * epsilon;
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isNormalized' only accept floating-point inputs");
return abs(length(v) - static_cast<T>(1)) <= static_cast<T>(2) * epsilon;
}
template <typename T, precision P>
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER bool isNull
(
detail::tvec2<T, P> const & v,
vecType<T, P> const & v,
T const & epsilon
)
{
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isNull' only accept floating-point inputs");
return length(v) <= epsilon;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool isNull
template <typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<bool, P> isCompNull
(
detail::tvec3<T, P> const & v,
vecType<T, P> const & v,
T const & epsilon
)
{
return length(v) <= epsilon;
}
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'isCompNull' only accept floating-point inputs");
template <typename T, precision P>
GLM_FUNC_QUALIFIER bool isNull
(
detail::tvec4<T, P> const & v,
T const & epsilon
)
{
return length(v) <= epsilon;
}
template <typename T>
GLM_FUNC_QUALIFIER bool isCompNull
(
T const & s,
T const & epsilon
)
{
return abs(s) < epsilon;
return detail::compute_isCompNull<T, P, vecType>::call(v, epsilon);
}
template <typename T, precision P>
@ -118,9 +156,7 @@ namespace glm
detail::tvec2<T, P> const & v,
T const & epsilon)
{
return detail::tvec2<bool, P>(
(abs(v.x) < epsilon),
(abs(v.y) < epsilon));
}
template <typename T, precision P>

View File

@ -50,7 +50,8 @@ GLM 0.9.5.1: 2014-XX-XX
- Deprecated degrees for function parameters and display a message
- Added possible static_cast conversion of GLM types (#72)
- Fixed error 'inverse' is not a member of 'glm' from glm::unProject (#146)
- Fixed mismatch of GTC_packing declaration and definition prototypes
- Fixed mismatch between some declarations and definitions
- Fixed inverse link error when using namespace glm; (#147)
================================================================================
GLM 0.9.5.0: 2013-12-25

View File

@ -9,62 +9,64 @@
#include <glm/matrix.hpp>
using namespace glm;
int test_matrixCompMult()
{
int Error(0);
{
glm::mat2 m(0, 1, 2, 3);
glm::mat2 n = glm::matrixCompMult(m, m);
Error += n == glm::mat2(0, 1, 4, 9) ? 0 : 1;
mat2 m(0, 1, 2, 3);
mat2 n = matrixCompMult(m, m);
Error += n == mat2(0, 1, 4, 9) ? 0 : 1;
}
{
glm::mat2x3 m(0, 1, 2, 3, 4, 5);
glm::mat2x3 n = glm::matrixCompMult(m, m);
Error += n == glm::mat2x3(0, 1, 4, 9, 16, 25) ? 0 : 1;
mat2x3 m(0, 1, 2, 3, 4, 5);
mat2x3 n = matrixCompMult(m, m);
Error += n == mat2x3(0, 1, 4, 9, 16, 25) ? 0 : 1;
}
{
glm::mat2x4 m(0, 1, 2, 3, 4, 5, 6, 7);
glm::mat2x4 n = glm::matrixCompMult(m, m);
Error += n == glm::mat2x4(0, 1, 4, 9, 16, 25, 36, 49) ? 0 : 1;
mat2x4 m(0, 1, 2, 3, 4, 5, 6, 7);
mat2x4 n = matrixCompMult(m, m);
Error += n == mat2x4(0, 1, 4, 9, 16, 25, 36, 49) ? 0 : 1;
}
{
glm::mat3 m(0, 1, 2, 3, 4, 5, 6, 7, 8);
glm::mat3 n = glm::matrixCompMult(m, m);
Error += n == glm::mat3(0, 1, 4, 9, 16, 25, 36, 49, 64) ? 0 : 1;
mat3 m(0, 1, 2, 3, 4, 5, 6, 7, 8);
mat3 n = matrixCompMult(m, m);
Error += n == mat3(0, 1, 4, 9, 16, 25, 36, 49, 64) ? 0 : 1;
}
{
glm::mat3x2 m(0, 1, 2, 3, 4, 5);
glm::mat3x2 n = glm::matrixCompMult(m, m);
Error += n == glm::mat3x2(0, 1, 4, 9, 16, 25) ? 0 : 1;
mat3x2 m(0, 1, 2, 3, 4, 5);
mat3x2 n = matrixCompMult(m, m);
Error += n == mat3x2(0, 1, 4, 9, 16, 25) ? 0 : 1;
}
{
glm::mat3x4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
glm::mat3x4 n = glm::matrixCompMult(m, m);
Error += n == glm::mat3x4(0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121) ? 0 : 1;
mat3x4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
mat3x4 n = matrixCompMult(m, m);
Error += n == mat3x4(0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121) ? 0 : 1;
}
{
glm::mat4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
glm::mat4 n = glm::matrixCompMult(m, m);
Error += n == glm::mat4(0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225) ? 0 : 1;
mat4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
mat4 n = matrixCompMult(m, m);
Error += n == mat4(0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225) ? 0 : 1;
}
{
glm::mat4x2 m(0, 1, 2, 3, 4, 5, 6, 7);
glm::mat4x2 n = glm::matrixCompMult(m, m);
Error += n == glm::mat4x2(0, 1, 4, 9, 16, 25, 36, 49) ? 0 : 1;
mat4x2 m(0, 1, 2, 3, 4, 5, 6, 7);
mat4x2 n = matrixCompMult(m, m);
Error += n == mat4x2(0, 1, 4, 9, 16, 25, 36, 49) ? 0 : 1;
}
{
glm::mat4x3 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
glm::mat4x3 n = glm::matrixCompMult(m, m);
Error += n == glm::mat4x3(0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121) ? 0 : 1;
mat4x3 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
mat4x3 n = matrixCompMult(m, m);
Error += n == mat4x3(0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121) ? 0 : 1;
}
return Error;
@ -79,62 +81,62 @@ int test_outerProduct()
int test_transpose()
{
int Error(0);
{
glm::mat2 m(0, 1, 2, 3);
glm::mat2 t = glm::transpose(m);
Error += t == glm::mat2(0, 2, 1, 3) ? 0 : 1;
}
int Error(0);
{
glm::mat2x3 m(0, 1, 2, 3, 4, 5);
glm::mat3x2 t = glm::transpose(m);
Error += t == glm::mat3x2(0, 3, 1, 4, 2, 5) ? 0 : 1;
}
{
mat2 m(0, 1, 2, 3);
mat2 t = transpose(m);
Error += t == mat2(0, 2, 1, 3) ? 0 : 1;
}
{
mat2x3 m(0, 1, 2, 3, 4, 5);
mat3x2 t = transpose(m);
Error += t == mat3x2(0, 3, 1, 4, 2, 5) ? 0 : 1;
}
{
mat2x4 m(0, 1, 2, 3, 4, 5, 6, 7);
mat4x2 t = transpose(m);
Error += t == mat4x2(0, 4, 1, 5, 2, 6, 3, 7) ? 0 : 1;
}
{
mat3 m(0, 1, 2, 3, 4, 5, 6, 7, 8);
mat3 t = transpose(m);
Error += t == mat3(0, 3, 6, 1, 4, 7, 2, 5, 8) ? 0 : 1;
}
{
mat3x2 m(0, 1, 2, 3, 4, 5);
mat2x3 t = transpose(m);
Error += t == mat2x3(0, 2, 4, 1, 3, 5) ? 0 : 1;
}
{
mat3x4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
mat4x3 t = transpose(m);
Error += t == mat4x3(0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11) ? 0 : 1;
}
{
mat4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
mat4 t = transpose(m);
Error += t == mat4(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15) ? 0 : 1;
}
{
mat4x2 m(0, 1, 2, 3, 4, 5, 6, 7);
mat2x4 t = transpose(m);
Error += t == mat2x4(0, 2, 4, 6, 1, 3, 5, 7) ? 0 : 1;
}
{
mat4x3 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
mat3x4 t = transpose(m);
Error += t == mat3x4(0, 3, 6, 9, 1, 4, 7, 10, 2, 5, 8, 11) ? 0 : 1;
}
{
glm::mat2x4 m(0, 1, 2, 3, 4, 5, 6, 7);
glm::mat4x2 t = glm::transpose(m);
Error += t == glm::mat4x2(0, 4, 1, 5, 2, 6, 3, 7) ? 0 : 1;
}
{
glm::mat3 m(0, 1, 2, 3, 4, 5, 6, 7, 8);
glm::mat3 t = glm::transpose(m);
Error += t == glm::mat3(0, 3, 6, 1, 4, 7, 2, 5, 8) ? 0 : 1;
}
{
glm::mat3x2 m(0, 1, 2, 3, 4, 5);
glm::mat2x3 t = glm::transpose(m);
Error += t == glm::mat2x3(0, 2, 4, 1, 3, 5) ? 0 : 1;
}
{
glm::mat3x4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
glm::mat4x3 t = glm::transpose(m);
Error += t == glm::mat4x3(0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11) ? 0 : 1;
}
{
glm::mat4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
glm::mat4 t = glm::transpose(m);
Error += t == glm::mat4(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15) ? 0 : 1;
}
{
glm::mat4x2 m(0, 1, 2, 3, 4, 5, 6, 7);
glm::mat2x4 t = glm::transpose(m);
Error += t == glm::mat2x4(0, 2, 4, 6, 1, 3, 5, 7) ? 0 : 1;
}
{
glm::mat4x3 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
glm::mat3x4 t = glm::transpose(m);
Error += t == glm::mat3x4(0, 3, 6, 9, 1, 4, 7, 10, 2, 5, 8, 11) ? 0 : 1;
}
return Error;
}
@ -154,7 +156,7 @@ int test_inverse()
glm::vec4(0, 1, 0, 0),
glm::vec4(0, 0, 1, 0),
glm::vec4(0, 0, 0, 1));
glm::mat4x4 B4x4 = glm::inverse(A4x4);
glm::mat4x4 B4x4 = inverse(A4x4);
glm::mat4x4 I4x4 = A4x4 * B4x4;
Failed += I4x4 == glm::mat4x4(1) ? 0 : 1;

View File

@ -9,6 +9,7 @@
#include <glm/vector_relational.hpp>
#include <glm/vec2.hpp>
#include <vector>
int test_vec2_operators()
{
@ -199,6 +200,24 @@ int test_vec2_ctor()
{
int Error = 0;
#if(GLM_HAS_INITIALIZER_LISTS)
{
glm::vec2 a{ 0, 1 };
std::vector<glm::vec2> v = {
{0, 1},
{4, 5},
{8, 9}};
}
{
glm::dvec2 a{ 0, 1 };
std::vector<glm::dvec2> v = {
{0, 1},
{4, 5},
{8, 9}};
}
#endif
{
glm::vec2 A = glm::vec2(2.0f);
glm::vec2 B = glm::vec2(2.0f, 3.0f);

View File

@ -20,6 +20,24 @@ int test_vec3_ctor()
{
int Error = 0;
#if(GLM_HAS_INITIALIZER_LISTS)
{
glm::vec3 a{ 0, 1, 2 };
std::vector<glm::vec3> v = {
{0, 1, 2},
{4, 5, 6},
{8, 9, 0}};
}
{
glm::dvec3 a{ 0, 1, 2 };
std::vector<glm::dvec3> v = {
{0, 1, 2},
{4, 5, 6},
{8, 9, 0}};
}
#endif
{
glm::vec3 A(1);
glm::vec3 B(1, 1, 1);

View File

@ -49,6 +49,14 @@ int test_vec4_ctor()
{4, 5, 6, 7},
{8, 9, 0, 1}};
}
{
glm::dvec4 a{ 0, 1, 2, 3 };
std::vector<glm::dvec4> v = {
{0, 1, 2, 3},
{4, 5, 6, 7},
{8, 9, 0, 1}};
}
#endif
{

View File

@ -112,12 +112,12 @@ int test_Half4x16()
int Error = 0;
std::vector<glm::vec4> Tests;
Tests.push_back(glm::vec4(1.0));
Tests.push_back(glm::vec4(0.0));
Tests.push_back(glm::vec4(2.0));
Tests.push_back(glm::vec4(0.1));
Tests.push_back(glm::vec4(0.5));
Tests.push_back(glm::vec4(-0.9));
Tests.push_back(glm::vec4(1.0f));
Tests.push_back(glm::vec4(0.0f));
Tests.push_back(glm::vec4(2.0f));
Tests.push_back(glm::vec4(0.1f));
Tests.push_back(glm::vec4(0.5f));
Tests.push_back(glm::vec4(-0.9f));
for(std::size_t i = 0; i < Tests.size(); ++i)
{
@ -184,12 +184,12 @@ int test_Snorm3x10_1x2()
int Error = 0;
std::vector<glm::vec4> Tests;
Tests.push_back(glm::vec4(1.0));
Tests.push_back(glm::vec4(0.0));
Tests.push_back(glm::vec4(2.0));
Tests.push_back(glm::vec4(0.1));
Tests.push_back(glm::vec4(0.5));
Tests.push_back(glm::vec4(0.9));
Tests.push_back(glm::vec4(1.0f));
Tests.push_back(glm::vec4(0.0f));
Tests.push_back(glm::vec4(2.0f));
Tests.push_back(glm::vec4(0.1f));
Tests.push_back(glm::vec4(0.5f));
Tests.push_back(glm::vec4(0.9f));
for(std::size_t i = 0; i < Tests.size(); ++i)
{
@ -208,12 +208,12 @@ int test_Unorm3x10_1x2()
int Error = 0;
std::vector<glm::vec4> Tests;
Tests.push_back(glm::vec4(1.0));
Tests.push_back(glm::vec4(0.0));
Tests.push_back(glm::vec4(2.0));
Tests.push_back(glm::vec4(0.1));
Tests.push_back(glm::vec4(0.5));
Tests.push_back(glm::vec4(0.9));
Tests.push_back(glm::vec4(1.0f));
Tests.push_back(glm::vec4(0.0f));
Tests.push_back(glm::vec4(2.0f));
Tests.push_back(glm::vec4(0.1f));
Tests.push_back(glm::vec4(0.5f));
Tests.push_back(glm::vec4(0.9f));
for(std::size_t i = 0; i < Tests.size(); ++i)
{
@ -232,12 +232,12 @@ int test_F2x11_1x10()
int Error = 0;
std::vector<glm::vec3> Tests;
Tests.push_back(glm::vec3(1.0));
Tests.push_back(glm::vec3(0.0));
Tests.push_back(glm::vec3(2.0));
Tests.push_back(glm::vec3(0.1));
Tests.push_back(glm::vec3(0.5));
Tests.push_back(glm::vec3(0.9));
Tests.push_back(glm::vec3(1.0f));
Tests.push_back(glm::vec3(0.0f));
Tests.push_back(glm::vec3(2.0f));
Tests.push_back(glm::vec3(0.1f));
Tests.push_back(glm::vec3(0.5f));
Tests.push_back(glm::vec3(0.9f));
for(std::size_t i = 0; i < Tests.size(); ++i)
{