From 23ba487f03527fb511399c1286651afeabf2bdf1 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Fri, 12 Nov 2010 18:58:55 +0000 Subject: [PATCH] Improved C++0x static_assert support --- glm/core/func_common.inl | 44 ++++++++++++------------- glm/core/func_exponential.inl | 16 ++++----- glm/core/func_geometric.inl | 34 ++++++++++---------- glm/core/func_integer.inl | 12 +++---- glm/core/func_matrix.inl | 50 ++++++++++++++++++----------- glm/core/func_noise.inl | 26 +++++++-------- glm/core/func_trigonometric.inl | 22 ++++++------- glm/core/func_vector_relational.hpp | 21 ++++++++---- glm/glm.hpp | 26 +++++++-------- glm/gtc/matrix_access.inl | 2 +- glm/gtx/bit.inl | 6 ++-- glm/gtx/reciprocal.inl | 24 +++++++------- glm/setup.hpp | 2 +- 13 files changed, 153 insertions(+), 132 deletions(-) diff --git a/glm/core/func_common.inl b/glm/core/func_common.inl index e09649e4..13d79d3b 100644 --- a/glm/core/func_common.inl +++ b/glm/core/func_common.inl @@ -23,7 +23,7 @@ namespace glm { GLM_STATIC_ASSERT( detail::type::is_float || - detail::type::is_int); + detail::type::is_int, "'abs' only accept floating-point and integer inputs"); return x >= genFIType(0) ? x : -x; } }; @@ -34,7 +34,7 @@ namespace glm static genFIType get(genFIType const & x) { GLM_STATIC_ASSERT( - detail::type::is_uint); + detail::type::is_uint, "'abs' only accept floating-point and integer inputs"); return x; } @@ -100,7 +100,7 @@ namespace glm { GLM_STATIC_ASSERT( detail::type::is_float || - detail::type::is_int); + detail::type::is_int, "'sign' only accept signed inputs"); genFIType result; if(x > genFIType(0)) @@ -152,7 +152,7 @@ namespace glm template inline genType floor(genType const& x) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'floor' only accept floating-point inputs"); return ::std::floor(x); } @@ -188,7 +188,7 @@ namespace glm template inline genType trunc(genType const & x) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'trunc' only accept floating-point inputs"); return floor(abs(x)); } @@ -223,7 +223,7 @@ namespace glm template inline genType round(genType const& x) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'round' only accept floating-point inputs"); return genType(int(x + genType(0.5))); } @@ -259,7 +259,7 @@ namespace glm template inline genType roundEven(genType const& x) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'roundEven' only accept floating-point inputs"); return genType(int(x + genType(int(x) % 2))); } @@ -295,7 +295,7 @@ namespace glm template inline genType ceil(genType const & x) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'ceil' only accept floating-point inputs"); return ::std::ceil(x); } @@ -334,7 +334,7 @@ namespace glm genType const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'fract' only accept floating-point inputs"); return x - ::std::floor(x); } @@ -383,7 +383,7 @@ namespace glm genType const & y ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'mod' only accept floating-point inputs"); return x - y * floor(x / y); } @@ -474,7 +474,7 @@ namespace glm genType & i ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'modf' only accept floating-point inputs"); i = glm::floor(x); @@ -539,7 +539,7 @@ namespace glm GLM_STATIC_ASSERT( detail::type::is_float || detail::type::is_int || - detail::type::is_uint); + detail::type::is_uint, "'min' only accept numbers"); return x < y ? x : y; } @@ -633,7 +633,7 @@ namespace glm GLM_STATIC_ASSERT( detail::type::is_float || detail::type::is_int || - detail::type::is_uint); + detail::type::is_uint, "'max' only accept numbers"); return x > y ? x : y; } @@ -727,7 +727,7 @@ namespace glm GLM_STATIC_ASSERT( detail::type::is_float || detail::type::is_int || - detail::type::is_uint); + detail::type::is_uint, "'clamp' only accept numbers"); if(x >= maxVal) return maxVal; if(x <= minVal) return minVal; @@ -932,7 +932,7 @@ namespace glm bool a ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'mix' only accept floating-point inputs"); return a ? x : y; } @@ -945,7 +945,7 @@ namespace glm typename detail::tvec2::bool_type a ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'mix' only accept floating-point inputs"); detail::tvec2 result; for @@ -968,7 +968,7 @@ namespace glm typename detail::tvec3::bool_type a ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'mix' only accept floating-point inputs"); detail::tvec3 result; for @@ -991,7 +991,7 @@ namespace glm typename detail::tvec4::bool_type a ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'mix' only accept floating-point inputs"); detail::tvec4 result; for @@ -1014,7 +1014,7 @@ namespace glm genType const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'mix' only accept floating-point inputs"); return x <= edge ? genType(0) : genType(1); } @@ -1106,7 +1106,7 @@ namespace glm genType const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'mix' only accept floating-point inputs"); genType tmp = clamp((x - edge0) / (edge1 - edge0), genType(0), genType(1)); return tmp * tmp * (genType(3) - genType(2) * tmp); @@ -1202,7 +1202,7 @@ namespace glm genType const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'mix' only accept floating-point inputs"); #if(defined(GLM_COMPILER) && GLM_COMPILER & GLM_COMPILER_VC) return typename genType::bool_type(_isnan(x)); @@ -1253,7 +1253,7 @@ namespace glm genType const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'isinf' only accept floating-point inputs"); #if(defined(GLM_COMPILER) && GLM_COMPILER & GLM_COMPILER_VC) return typename genType::bool_type(_fpclass(x) == _FPCLASS_NINF || _fpclass(x) == _FPCLASS_PINF); diff --git a/glm/core/func_exponential.inl b/glm/core/func_exponential.inl index 0d0dc512..e825ca7a 100644 --- a/glm/core/func_exponential.inl +++ b/glm/core/func_exponential.inl @@ -21,7 +21,7 @@ namespace glm genType const & y ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'pow' only accept floating-point input"); return ::std::pow(x, y); } @@ -72,7 +72,7 @@ namespace glm genType const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'exp' only accept floating-point input"); return ::std::exp(x); } @@ -120,7 +120,7 @@ namespace glm genType const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'log' only accept floating-point input"); return ::std::log(x); } @@ -168,7 +168,7 @@ namespace glm genType const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'exp2' only accept floating-point input"); return ::std::exp(genType(0.69314718055994530941723212145818) * x); } @@ -216,7 +216,7 @@ namespace glm genType const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'log2' only accept floating-point input"); return ::std::log(x) / genType(0.69314718055994530941723212145818); } @@ -264,9 +264,9 @@ namespace glm genType const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'sqrt' only accept floating-point input"); - return genType(::std::sqrt(double(x))); + return genType(::std::sqrt(x)); } template @@ -311,7 +311,7 @@ namespace glm genType const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'inversesqrt' only accept floating-point input"); return genType(1) / ::std::sqrt(x); } diff --git a/glm/core/func_geometric.inl b/glm/core/func_geometric.inl index 83bb9561..83c6c9fd 100644 --- a/glm/core/func_geometric.inl +++ b/glm/core/func_geometric.inl @@ -20,7 +20,7 @@ namespace glm genType const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'length' only accept floating-point inputs"); genType sqr = x * x; return sqrt(sqr); @@ -32,7 +32,7 @@ namespace glm detail::tvec2 const & v ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'length' only accept floating-point inputs"); typename detail::tvec2::value_type sqr = v.x * v.x + v.y * v.y; return sqrt(sqr); @@ -44,7 +44,7 @@ namespace glm detail::tvec3 const & v ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'length' only accept floating-point inputs"); typename detail::tvec3::value_type sqr = v.x * v.x + v.y * v.y + v.z * v.z; return sqrt(sqr); @@ -56,7 +56,7 @@ namespace glm detail::tvec4 const & v ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'length' only accept floating-point inputs"); typename detail::tvec4::value_type sqr = v.x * v.x + v.y * v.y + v.z * v.z + v.w * v.w; return sqrt(sqr); @@ -70,7 +70,7 @@ namespace glm genType const & p1 ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'distance' only accept floating-point inputs"); return length(p1 - p0); } @@ -82,7 +82,7 @@ namespace glm detail::tvec2 const & p1 ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'distance' only accept floating-point inputs"); return length(p1 - p0); } @@ -94,7 +94,7 @@ namespace glm detail::tvec3 const & p1 ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'distance' only accept floating-point inputs"); return length(p1 - p0); } @@ -106,7 +106,7 @@ namespace glm detail::tvec4 const & p1 ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'distance' only accept floating-point inputs"); return length(p1 - p0); } @@ -119,7 +119,7 @@ namespace glm genType const & y ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'dot' only accept floating-point inputs"); return x * y; } @@ -131,7 +131,7 @@ namespace glm detail::tvec2 const & y ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'dot' only accept floating-point inputs"); return x.x * y.x + x.y * y.y; } @@ -143,7 +143,7 @@ namespace glm detail::tvec3 const & y ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'dot' only accept floating-point inputs"); return x.x * y.x + x.y * y.y + x.z * y.z; } @@ -171,7 +171,7 @@ namespace glm detail::tvec4 const & y ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'dot' only accept floating-point inputs"); return x.x * y.x + x.y * y.y + x.z * y.z + x.w * y.w; } @@ -184,7 +184,7 @@ namespace glm detail::tvec3 const & y ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'cross' only accept floating-point inputs"); return detail::tvec3( x.y * y.z - y.y * x.z, @@ -199,7 +199,7 @@ namespace glm genType const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'normalize' only accept floating-point inputs"); return x < genType(0) ? genType(-1) : genType(1); } @@ -211,7 +211,7 @@ namespace glm detail::tvec2 const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'normalize' only accept floating-point inputs"); typename detail::tvec2::value_type sqr = x.x * x.x + x.y * x.y; return x * inversesqrt(sqr); @@ -223,7 +223,7 @@ namespace glm detail::tvec3 const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'normalize' only accept floating-point inputs"); typename detail::tvec3::value_type sqr = x.x * x.x + x.y * x.y + x.z * x.z; return x * inversesqrt(sqr); @@ -235,7 +235,7 @@ namespace glm detail::tvec4 const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'normalize' only accept floating-point inputs"); typename detail::tvec4::value_type sqr = x.x * x.x + x.y * x.y + x.z * x.z + x.w * x.w; return x * inversesqrt(sqr); diff --git a/glm/core/func_integer.inl b/glm/core/func_integer.inl index e866032c..4c6bdbd1 100644 --- a/glm/core/func_integer.inl +++ b/glm/core/func_integer.inl @@ -266,7 +266,7 @@ namespace glm int const & Bits ) { - GLM_STATIC_ASSERT(std::numeric_limits::is_integer); + GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'bitfieldExtract' only accept integer values"); assert(Offset + Bits <= sizeof(genIUType)); genIUType Result = 0; @@ -332,7 +332,7 @@ namespace glm int const & Bits ) { - GLM_STATIC_ASSERT(std::numeric_limits::is_integer); + GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'bitfieldInsert' only accept integer values"); assert(Offset + Bits <= sizeof(genIUType)); if(Bits == 0) @@ -394,7 +394,7 @@ namespace glm template inline genIUType bitfieldReverse(genIUType const & Value) { - GLM_STATIC_ASSERT(std::numeric_limits::is_integer); + GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'bitfieldReverse' only accept integer values"); genIUType Result = 0; for(std::size_t i = 0; i < sizeof(genIUType) * std::size_t(8); ++i) @@ -443,7 +443,7 @@ namespace glm template int bitCount(genIUType const & Value) { - GLM_STATIC_ASSERT(std::numeric_limits::is_integer); + GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'bitCount' only accept integer values"); int Count = 0; for(std::size_t i = 0; i < sizeof(genIUType) * std::size_t(8); ++i) @@ -497,7 +497,7 @@ namespace glm genIUType const & Value ) { - GLM_STATIC_ASSERT(std::numeric_limits::is_integer); + GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'findLSB' only accept integer values"); if(Value == 0) return -1; @@ -549,7 +549,7 @@ namespace glm genIUType const & Value ) { - GLM_STATIC_ASSERT(std::numeric_limits::is_integer); + GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'findMSB' only accept integer values"); if(Value == 0) return -1; diff --git a/glm/core/func_matrix.inl b/glm/core/func_matrix.inl index 5ec3efac..7801b622 100644 --- a/glm/core/func_matrix.inl +++ b/glm/core/func_matrix.inl @@ -21,7 +21,7 @@ namespace glm matType const & y ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'matrixCompMult' only accept floating-point inputs"); matType result(matType::null); for(typename matType::size_type i = 0; i < matType::col_size(); ++i) @@ -37,7 +37,7 @@ namespace glm detail::tvec2 const & r ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'outerProduct' only accept floating-point inputs"); detail::tmat2x2 m(detail::tmat2x2::null); m[0][0] = c[0] * r[0]; @@ -54,7 +54,7 @@ namespace glm detail::tvec3 const & r ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'outerProduct' only accept floating-point inputs"); detail::tmat3x3 m(detail::tmat3x3::null); for(typename detail::tmat3x3::size_type i = 0; i < detail::tmat3x3::col_size(); ++i) @@ -69,7 +69,7 @@ namespace glm detail::tvec4 const & r ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'outerProduct' only accept floating-point inputs"); detail::tmat4x4 m(detail::tmat4x4::null); for(typename detail::tmat4x4::size_type i = 0; i < detail::tmat4x4::col_size(); ++i) @@ -84,7 +84,7 @@ namespace glm detail::tvec2 const & r ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'outerProduct' only accept floating-point inputs"); detail::tmat2x3 m(detail::tmat2x3::null); m[0][0] = c.x * r.x; @@ -103,7 +103,7 @@ namespace glm detail::tvec3 const & r ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'outerProduct' only accept floating-point inputs"); detail::tmat3x2 m(detail::tmat3x2::null); m[0][0] = c.x * r.x; @@ -122,7 +122,7 @@ namespace glm detail::tvec4 const & r ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'outerProduct' only accept floating-point inputs"); detail::tmat2x4 m(detail::tmat2x4::null); m[0][0] = c.x * r.x; @@ -143,7 +143,7 @@ namespace glm detail::tvec2 const & r ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'outerProduct' only accept floating-point inputs"); detail::tmat4x2 m(detail::tmat4x2::null); m[0][0] = c.x * r.x; @@ -164,7 +164,7 @@ namespace glm detail::tvec3 const & r ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'outerProduct' only accept floating-point inputs"); detail::tmat3x4 m(detail::tmat3x4::null); m[0][0] = c.x * r.x; @@ -189,7 +189,7 @@ namespace glm detail::tvec4 const & r ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'outerProduct' only accept floating-point inputs"); detail::tmat4x3 m(detail::tmat4x3::null); m[0][0] = c.x * r.x; @@ -213,7 +213,7 @@ namespace glm detail::tmat2x2 const & m ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'transpose' only accept floating-point inputs"); detail::tmat2x2 result(detail::tmat2x2::null); result[0][0] = m[0][0]; @@ -229,7 +229,7 @@ namespace glm detail::tmat3x3 const & m ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'transpose' only accept floating-point inputs"); detail::tmat3x3 result(detail::tmat3x3::null); result[0][0] = m[0][0]; @@ -252,7 +252,7 @@ namespace glm detail::tmat4x4 const & m ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'transpose' only accept floating-point inputs"); detail::tmat4x4 result(detail::tmat4x4::null); result[0][0] = m[0][0]; @@ -283,7 +283,7 @@ namespace glm detail::tmat3x2 const & m ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'transpose' only accept floating-point inputs"); detail::tmat2x3 result(detail::tmat2x3::null); result[0][0] = m[0][0]; @@ -301,7 +301,7 @@ namespace glm detail::tmat2x3 const & m ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'transpose' only accept floating-point inputs"); detail::tmat3x2 result(detail::tmat3x2::null); result[0][0] = m[0][0]; @@ -319,7 +319,7 @@ namespace glm detail::tmat4x2 const & m ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'transpose' only accept floating-point inputs"); detail::tmat2x4 result(detail::tmat2x4::null); result[0][0] = m[0][0]; @@ -339,7 +339,7 @@ namespace glm detail::tmat2x4 const & m ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'transpose' only accept floating-point inputs"); detail::tmat4x2 result(detail::tmat4x2::null); result[0][0] = m[0][0]; @@ -359,7 +359,7 @@ namespace glm detail::tmat4x3 const & m ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'transpose' only accept floating-point inputs"); detail::tmat3x4 result(detail::tmat3x4::null); result[0][0] = m[0][0]; @@ -383,7 +383,7 @@ namespace glm detail::tmat3x4 const & m ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'transpose' only accept floating-point inputs"); detail::tmat4x3 result(detail::tmat4x3::null); result[0][0] = m[0][0]; @@ -407,6 +407,8 @@ namespace glm detail::tmat2x2 const & m ) { + GLM_STATIC_ASSERT(detail::type::is_float, "'determinant' only accept floating-point inputs"); + return m[0][0] * m[1][1] - m[1][0] * m[0][1]; } @@ -416,6 +418,8 @@ namespace glm detail::tmat3x3 const & m ) { + GLM_STATIC_ASSERT(detail::type::is_float, "'determinant' only accept floating-point inputs"); + return + m[0][0] * (m[1][1] * m[2][2] - m[2][1] * m[1][2]) - m[1][0] * (m[0][1] * m[2][2] - m[2][1] * m[0][2]) @@ -428,6 +432,8 @@ namespace glm detail::tmat4x4 const & m ) { + GLM_STATIC_ASSERT(detail::type::is_float, "'determinant' only accept floating-point inputs"); + 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]; T SubFactor02 = m[2][1] * m[3][2] - m[3][1] * m[2][2]; @@ -453,6 +459,8 @@ namespace glm detail::tmat2x2 const & m ) { + GLM_STATIC_ASSERT(detail::type::is_float, "'inverse' only accept floating-point inputs"); + //valType Determinant = m[0][0] * m[1][1] - m[1][0] * m[0][1]; T Determinant = determinant(m); @@ -471,6 +479,8 @@ namespace glm detail::tmat3x3 const & m ) { + GLM_STATIC_ASSERT(detail::type::is_float, "'inverse' only accept floating-point inputs"); + //valType Determinant = m[0][0] * (m[1][1] * m[2][2] - m[2][1] * m[1][2]) // - m[1][0] * (m[0][1] * m[2][2] - m[2][1] * m[0][2]) // + m[2][0] * (m[0][1] * m[1][2] - m[1][1] * m[0][2]); @@ -498,6 +508,8 @@ namespace glm detail::tmat4x4 const & m ) { + GLM_STATIC_ASSERT(detail::type::is_float, "'inverse' only accept floating-point inputs"); + T Coef00 = m[2][2] * m[3][3] - m[3][2] * m[2][3]; T Coef02 = m[1][2] * m[3][3] - m[3][2] * m[1][3]; T Coef03 = m[1][2] * m[2][3] - m[2][2] * m[1][3]; diff --git a/glm/core/func_noise.inl b/glm/core/func_noise.inl index f2787c07..2746932f 100644 --- a/glm/core/func_noise.inl +++ b/glm/core/func_noise.inl @@ -20,7 +20,7 @@ namespace glm genType const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'noise1' only accept floating-point values"); int iNbr = int(x + genType(3) / genType(2)) * 1103515245 + 12345; return genType(int(iNbr / genType(65536)) % 32768) / genType(32767); @@ -69,7 +69,7 @@ namespace glm genType const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'noise2' only accept floating-point values"); genType f1 = x * genType(1103515245) + genType(12345); genType f2 = f1 * genType(1103515245) + genType(12345); @@ -84,7 +84,7 @@ namespace glm detail::tvec2 const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'noise2' only accept floating-point values"); T f0(0); for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size(); ++i) @@ -103,7 +103,7 @@ namespace glm detail::tvec3 const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'noise2' only accept floating-point values"); T f0(0); for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size(); ++i) @@ -122,7 +122,7 @@ namespace glm detail::tvec4 const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'noise2' only accept floating-point values"); T f0(0); for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size(); ++i) @@ -142,7 +142,7 @@ namespace glm genType const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'noise3' only accept floating-point values"); genType f1 = x * genType(1103515245) + genType(12345); genType f2 = f1 * genType(1103515245) + genType(12345); @@ -159,7 +159,7 @@ namespace glm detail::tvec2 const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'noise3' only accept floating-point values"); T f0(0); for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size(); ++i) @@ -179,7 +179,7 @@ namespace glm detail::tvec3 const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'noise3' only accept floating-point values"); T f0(0); for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size(); ++i) @@ -199,7 +199,7 @@ namespace glm detail::tvec4 const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'noise3' only accept floating-point values"); T f0(0); for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size(); ++i) @@ -220,7 +220,7 @@ namespace glm genType const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'noise4' only accept floating-point values"); genType f1 = x * genType(1103515245) + genType(12345); genType f2 = f1 * genType(1103515245) + genType(12345); @@ -239,7 +239,7 @@ namespace glm detail::tvec2 const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'noise4' only accept floating-point values"); T f0(0); for(typename detail::tvec2::size_type i = 0; i < detail::tvec2::value_size(); ++i) @@ -261,7 +261,7 @@ namespace glm detail::tvec3 const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'noise4' only accept floating-point values"); T f0(0); for(typename detail::tvec3::size_type i = 0; i < detail::tvec3::value_size()(); ++i) @@ -283,7 +283,7 @@ namespace glm detail::tvec4 const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'noise4' only accept floating-point values"); T f0(0); for(typename detail::tvec4::size_type i = 0; i < detail::tvec4::value_size()(); ++i) diff --git a/glm/core/func_trigonometric.inl b/glm/core/func_trigonometric.inl index f69e86a7..39689b2f 100644 --- a/glm/core/func_trigonometric.inl +++ b/glm/core/func_trigonometric.inl @@ -211,7 +211,7 @@ namespace glm genType const & angle ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'tan' only accept floating-point input"); return ::std::tan(angle); } @@ -259,7 +259,7 @@ namespace glm genType const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'asin' only accept floating-point input"); return ::std::asin(x); } @@ -307,7 +307,7 @@ namespace glm genType const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'acos' only accept floating-point input"); return ::std::acos(x); } @@ -356,7 +356,7 @@ namespace glm genType const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'atan' only accept floating-point input"); return ::std::atan2(y, x); } @@ -406,7 +406,7 @@ namespace glm genType const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'atan' only accept floating-point input"); return ::std::atan(x); } @@ -454,7 +454,7 @@ namespace glm genType const & angle ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'sinh' only accept floating-point input"); return std::sinh(angle); } @@ -502,7 +502,7 @@ namespace glm genType const & angle ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'cosh' only accept floating-point input"); return std::cosh(angle); } @@ -550,7 +550,7 @@ namespace glm genType const & angle ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'tanh' only accept floating-point input"); return std::tanh(angle); } @@ -598,7 +598,7 @@ namespace glm genType const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'asinh' only accept floating-point input"); return (x < genType(0) ? genType(-1) : (x > genType(0) ? genType(1) : genType(0))) * log(abs(x) + sqrt(genType(1) + x * x)); } @@ -646,7 +646,7 @@ namespace glm genType const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'acosh' only accept floating-point input"); if(x < genType(1)) return genType(0); @@ -696,7 +696,7 @@ namespace glm genType const & x ) { - GLM_STATIC_ASSERT(detail::type::is_float); + GLM_STATIC_ASSERT(detail::type::is_float, "'atanh' only accept floating-point input"); if(abs(x) >= genType(1)) return 0; diff --git a/glm/core/func_vector_relational.hpp b/glm/core/func_vector_relational.hpp index 3916d7e5..d912c563 100644 --- a/glm/core/func_vector_relational.hpp +++ b/glm/core/func_vector_relational.hpp @@ -34,7 +34,7 @@ namespace glm GLM_STATIC_ASSERT( detail::type::is_float || detail::type::is_int || - detail::type::is_uint); + detail::type::is_uint, "'lessThan' only accept numbers"); typename vecType::bool_type Result(vecType::null); for(typename vecType::size_type i = 0; i < vecType::value_size(); ++i) @@ -54,7 +54,7 @@ namespace glm GLM_STATIC_ASSERT( detail::type::is_float || detail::type::is_int || - detail::type::is_uint); + detail::type::is_uint, "'lessThanEqual' only accept numbers"); typename vecType::bool_type Result(vecType::null); for(typename vecType::size_type i = 0; i < vecType::value_size(); ++i) @@ -74,7 +74,7 @@ namespace glm GLM_STATIC_ASSERT( detail::type::is_float || detail::type::is_int || - detail::type::is_uint); + detail::type::is_uint, "'greaterThan' only accept numbers"); typename vecType::bool_type Result(vecType::null); for(typename vecType::size_type i = 0; i < vecType::value_size(); ++i) @@ -94,7 +94,7 @@ namespace glm GLM_STATIC_ASSERT( detail::type::is_float || detail::type::is_int || - detail::type::is_uint); + detail::type::is_uint, "'greaterThanEqual' only accept numbers"); typename vecType::bool_type Result(vecType::null); for(typename vecType::size_type i = 0; i < vecType::value_size(); ++i) @@ -115,7 +115,7 @@ namespace glm detail::type::is_float || detail::type::is_int || detail::type::is_uint || - detail::type::is_bool); + detail::type::is_bool, "'equal' only accept GLM vectors"); typename vecType::bool_type Result(vecType::null); for(typename vecType::size_type i = 0; i < vecType::value_size(); ++i) @@ -136,7 +136,7 @@ namespace glm detail::type::is_float || detail::type::is_int || detail::type::is_uint || - detail::type::is_bool); + detail::type::is_bool, "'notEqual' only accept GLM vectors"); typename vecType::bool_type Result(vecType::null); for(typename vecType::size_type i = 0; i < vecType::value_size(); ++i) @@ -149,6 +149,9 @@ namespace glm template