Browse Source

Updated equal and not equal operators for vectors

Christophe Riccio 15 years ago
parent
commit
efce35f901
6 changed files with 111 additions and 5 deletions
  1. 23 0
      glm/core/type_vec1.inl
  2. 23 0
      glm/core/type_vec2.inl
  3. 23 0
      glm/core/type_vec3.inl
  4. 36 0
      glm/core/type_vec4.inl
  5. 4 3
      glm/gtx/comparison.hpp
  6. 2 2
      glm/gtx/comparison.inl

+ 23 - 0
glm/core/type_vec1.inl

@@ -234,6 +234,29 @@ namespace glm
 			return *this;
 		}
 
+		//////////////////////////////////////
+		// Boolean operators
+
+		template <typename T> 
+		inline bool operator==
+		(
+			tvec1<T> const & v1, 
+			tvec1<T> const & v2
+		)
+		{
+			return (v1.x == v2.x);
+		}
+
+		template <typename T> 
+		inline bool operator!=
+		(
+			tvec1<T> const & v1, 
+			tvec1<T> const & v2
+		)
+		{
+			return (v1.x != v2.x);
+		}
+
 		//////////////////////////////////////
 		// Unary bit operators
 

+ 23 - 0
glm/core/type_vec2.inl

@@ -296,6 +296,29 @@ namespace glm
 			return *this;
 		}
 
+		//////////////////////////////////////
+		// Boolean operators
+
+		template <typename T> 
+		inline bool operator==
+		(
+			tvec2<T> const & v1, 
+			tvec2<T> const & v2
+		)
+		{
+			return (v1.x == v2.x) && (v1.y == v2.y);
+		}
+
+		template <typename T> 
+		inline bool operator!=
+		(
+			tvec2<T> const & v1, 
+			tvec2<T> const & v2
+		)
+		{
+			return (v1.x != v2.x) || (v1.y != v2.y);
+		}
+
 		//////////////////////////////////////
 		// Unary bit operators
 

+ 23 - 0
glm/core/type_vec3.inl

@@ -333,6 +333,29 @@ namespace glm
 			return *this;
 		}
 
+		//////////////////////////////////////
+		// Boolean operators
+
+		template <typename T> 
+		inline bool operator==
+		(
+			tvec3<T> const & v1, 
+			tvec3<T> const & v2
+		)
+		{
+			return (v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z);
+		}
+
+		template <typename T> 
+		inline bool operator!=
+		(
+			tvec3<T> const & v1, 
+			tvec3<T> const & v2
+		)
+		{
+			return (v1.x != v2.x) || (v1.y != v2.y) || (v1.z != v2.z);
+		}
+
 		//////////////////////////////////////
 		// Unary bit operators
 

+ 36 - 0
glm/core/type_vec4.inl

@@ -861,6 +861,29 @@ namespace glm
 				v.w - One);
 		}
 
+		//////////////////////////////////////
+		// Boolean operators
+
+		template <typename T> 
+		inline bool operator==
+		(
+			tvec4<T> const & v1, 
+			tvec4<T> const & v2
+		)
+		{
+			return (v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z) && (v1.w == v2.w);
+		}
+
+		template <typename T> 
+		inline bool operator!=
+		(
+			tvec4<T> const & v1, 
+			tvec4<T> const & v2
+		)
+		{
+			return (v1.x != v2.x) || (v1.y != v2.y) || (v1.z != v2.z) || (v1.w != v2.w);
+		}
+
 		//////////////////////////////////////
 		// Binary bit operators
 
@@ -1129,6 +1152,19 @@ namespace glm
 				~v.w);
 		}
 
+		template <typename T> 
+		inline tvec4<T> operator~
+		(
+			tvec4<T> const & v
+		)
+		{
+			return tvec4<T>(
+				~v.x,
+				~v.y,
+				~v.z,
+				~v.w);
+		}
+
 		//////////////////////////////////////
 		// tref definition
 

+ 4 - 3
glm/gtx/comparison.hpp

@@ -24,8 +24,9 @@ namespace glm
 
 	namespace gtx{
 	//! GLM_GTX_comparison extension: Defined comparison operators for vectors.
-	namespace comparison{
-
+	namespace comparison
+	{
+/*
 		//! Define == operator for vectors
 		//! From GLM_GTX_comparison extension.
 		template <typename T>
@@ -67,7 +68,7 @@ namespace glm
 		bool operator!= (
 			detail::tvec4<T> const & x, 
 			detail::tvec4<T> const & y);
-
+*/
 	}//namespace comparison
 	}//namespace gtx
 }//namespace glm

+ 2 - 2
glm/gtx/comparison.inl

@@ -10,7 +10,7 @@
 namespace glm{
 namespace gtx{
 namespace comparison{
-
+/*
 template <typename valType>
 inline bool operator== 
 (
@@ -70,7 +70,7 @@ inline bool operator!=
 {
 	return glm::any(glm::notEqual(x, y));
 }
-
+*/
 }//namespace comparison
 }//namespace gtx
 }//namespace glm