Added missing bvec* && and || operators

This commit is contained in:
Christophe Riccio 2015-10-15 04:28:08 +02:00
parent 560dcdbec0
commit a257beb5de
11 changed files with 95 additions and 0 deletions

View File

@ -314,6 +314,12 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_DECL bool operator!=(tvec1<T, P> const & v1, tvec1<T, P> const & v2);
template <precision P>
GLM_FUNC_DECL bool operator&&(tvec1<bool, P> const & v1, tvec1<bool, P> const & v2);
template <precision P>
GLM_FUNC_DECL bool operator||(tvec1<bool, P> const & v1, tvec1<bool, P> const & v2);
// -- Is type --
template <typename T, precision P>

View File

@ -601,4 +601,16 @@ namespace glm
{
return (v1.x != v2.x);
}
template <precision P>
GLM_FUNC_QUALIFIER tvec1<bool, P> operator&&(tvec1<bool, P> const & v1, tvec1<bool, P> const & v2)
{
return tvec1<bool, P>(v1.x && v2.x);
}
template <precision P>
GLM_FUNC_QUALIFIER tvec1<bool, P> operator||(tvec1<bool, P> const & v1, tvec1<bool, P> const & v2)
{
return tvec1<bool, P>(v1.x || v2.x);
}
}//namespace glm

View File

@ -406,6 +406,12 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_DECL bool operator!=(tvec2<T, P> const & v1, tvec2<T, P> const & v2);
template <precision P>
GLM_FUNC_DECL bool operator&&(tvec2<bool, P> const & v1, tvec2<bool, P> const & v2);
template <precision P>
GLM_FUNC_DECL bool operator||(tvec2<bool, P> const & v1, tvec2<bool, P> const & v2);
// -- Is type --
template <typename T, precision P>

View File

@ -926,4 +926,16 @@ namespace glm
{
return (v1.x != v2.x) || (v1.y != v2.y);
}
template <precision P>
GLM_FUNC_QUALIFIER tvec2<bool, P> operator&&(tvec2<bool, P> const & v1, tvec2<bool, P> const & v2)
{
return tvec2<bool, P>(v1.x && v2.x, v1.y && v2.y);
}
template <precision P>
GLM_FUNC_QUALIFIER tvec2<bool, P> operator||(tvec2<bool, P> const & v1, tvec2<bool, P> const & v2)
{
return tvec2<bool, P>(v1.x || v2.x, v1.y || v2.y);
}
}//namespace glm

View File

@ -429,6 +429,12 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_DECL bool operator!=(tvec3<T, P> const & v1, tvec3<T, P> const & v2);
template <precision P>
GLM_FUNC_DECL bool operator&&(tvec3<bool, P> const & v1, tvec3<bool, P> const & v2);
template <precision P>
GLM_FUNC_DECL bool operator||(tvec3<bool, P> const & v1, tvec3<bool, P> const & v2);
// -- Is type --
template <typename T, precision P>

View File

@ -1058,4 +1058,16 @@ namespace glm
{
return (v1.x != v2.x) || (v1.y != v2.y) || (v1.z != v2.z);
}
template <precision P>
GLM_FUNC_QUALIFIER tvec3<bool, P> operator&&(tvec3<bool, P> const & v1, tvec3<bool, P> const & v2)
{
return tvec3<bool, P>(v1.x && v2.x, v1.y && v2.y, v1.z && v2.z);
}
template <precision P>
GLM_FUNC_QUALIFIER tvec3<bool, P> operator||(tvec3<bool, P> const & v1, tvec3<bool, P> const & v2)
{
return tvec3<bool, P>(v1.x || v2.x, v1.y || v2.y, v1.z || v2.z);
}
}//namespace glm

View File

@ -542,6 +542,12 @@ namespace detail
template <typename T, precision P>
GLM_FUNC_DECL bool operator!=(tvec4<T, P> const & v1, tvec4<T, P> const & v2);
template <precision P>
GLM_FUNC_DECL bool operator&&(tvec4<bool, P> const & v1, tvec4<bool, P> const & v2);
template <precision P>
GLM_FUNC_DECL bool operator||(tvec4<bool, P> const & v1, tvec4<bool, P> const & v2);
// -- Is type --
template <typename T, precision P>

View File

@ -1168,6 +1168,18 @@ namespace glm
{
return (v1.x != v2.x) || (v1.y != v2.y) || (v1.z != v2.z) || (v1.w != v2.w);
}
template <precision P>
GLM_FUNC_QUALIFIER tvec4<bool, P> operator&&(tvec4<bool, P> const & v1, tvec4<bool, P> const & v2)
{
return tvec4<bool, P>(v1.x && v2.x, v1.y && v2.y, v1.z && v2.z, v1.w && v2.w);
}
template <precision P>
GLM_FUNC_QUALIFIER tvec4<bool, P> operator||(tvec4<bool, P> const & v1, tvec4<bool, P> const & v2)
{
return tvec4<bool, P>(v1.x || v2.x, v1.y || v2.y, v1.z || v2.z, v1.w || v2.w);
}
}//namespace glm
#if GLM_HAS_ANONYMOUS_UNION && GLM_NOT_BUGGY_VC32BITS

View File

@ -59,6 +59,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate)
- Added (un)packUnorm and (un)packSnorm to GTC_packing
- Added 16bit pack and unpack to GTC_packing
- Added 8bit pack and unpack to GTC_packing
- Added missing bvec* && and || operators
##### Improvements:
- Improved GTC_random linearRand documentation

View File

@ -159,6 +159,26 @@ int test_vec4_ctor()
return Error;
}
int test_bvec4_ctor()
{
int Error = 0;
glm::bvec4 const A(true);
glm::bvec4 const B(true);
glm::bvec4 const C(false);
glm::bvec4 const D = A && B;
glm::bvec4 const E = A && C;
glm::bvec4 const F = A || C;
bool const G = A == C;
bool const H = A != C;
Error += D == glm::bvec4(true) ? 0 : 1;
Error += E == glm::bvec4(false) ? 0 : 1;
Error += F == glm::bvec4(true) ? 0 : 1;
return Error;
}
int test_vec4_operators()
{
int Error = 0;
@ -511,6 +531,7 @@ int main()
Error += test_vec4_static_const();
Error += test_vec4_ctor();
Error += test_bvec4_ctor();
Error += test_vec4_size();
Error += test_vec4_operators();
Error += test_vec4_swizzle_partial();

View File

@ -438,6 +438,7 @@ int test_packSnorm1x8()
std::vector<glm::vec1> A;
A.push_back(glm::vec1( 1.0f));
A.push_back(glm::vec1(-0.7f));
A.push_back(glm::vec1(-1.0f));
for(std::size_t i = 0; i < A.size(); ++i)
{