소스 검색

isfinite support for quaternions

Adam Lusch 8 달 전
부모
커밋
3aed772ae9
3개의 변경된 파일41개의 추가작업 그리고 0개의 파일을 삭제
  1. 1 0
      glm/gtx/compatibility.hpp
  2. 11 0
      glm/gtx/compatibility.inl
  3. 29 0
      test/gtx/gtx_compatibility.cpp

+ 1 - 0
glm/gtx/compatibility.hpp

@@ -60,6 +60,7 @@ namespace glm
 	template<typename T, qualifier Q> GLM_FUNC_DECL vec<2, bool, Q> isfinite(const vec<2, T, Q>& x);				//!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility)
 	template<typename T, qualifier Q> GLM_FUNC_DECL vec<3, bool, Q> isfinite(const vec<3, T, Q>& x);				//!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility)
 	template<typename T, qualifier Q> GLM_FUNC_DECL vec<4, bool, Q> isfinite(const vec<4, T, Q>& x);				//!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility)
+	template<typename T, qualifier Q> GLM_FUNC_DECL vec<4, bool, Q> isfinite(const qua<T, Q>& x);					//!< \brief Test whether or not a scalar or each vector component is a finite value. (From GLM_GTX_compatibility)
 
 	typedef bool						bool1;			//!< \brief boolean type with 1 component. (From GLM_GTX_compatibility extension)
 	typedef vec<2, bool, highp>			bool2;			//!< \brief boolean type with 2 components. (From GLM_GTX_compatibility extension)

+ 11 - 0
glm/gtx/compatibility.inl

@@ -59,4 +59,15 @@ namespace glm
 			isfinite(x.w));
 	}
 
+	template<typename T, qualifier Q>
+	GLM_FUNC_QUALIFIER vec<4, bool, Q> isfinite(
+		qua<T, Q> const& x)
+	{
+		return vec<4, bool, Q>(
+			isfinite(x.x),
+			isfinite(x.y),
+			isfinite(x.z),
+			isfinite(x.w));
+	}
+
 }//namespace glm

+ 29 - 0
test/gtx/gtx_compatibility.cpp

@@ -5,6 +5,9 @@ int main()
 {
 	int Error(0);
 
+	float Zero_f = 0.0;
+	double Zero_d = 0.0;
+
 	Error += glm::isfinite(1.0f) ? 0 : 1;
 	Error += glm::isfinite(1.0) ? 0 : 1;
 	Error += glm::isfinite(-1.0f) ? 0 : 1;
@@ -15,5 +18,31 @@ int main()
 	Error += glm::all(glm::isfinite(glm::vec4(-1.0f))) ? 0 : 1;
 	Error += glm::all(glm::isfinite(glm::dvec4(-1.0))) ? 0 : 1;
 
+	Error += glm::all(glm::isfinite(glm::quat(1.0f, 1.0f, 1.0f, 1.0f))) ? 0 : 1;
+	Error += glm::all(glm::isfinite(glm::dquat(1.0, 1.0, 1.0, 1.0))) ? 0 : 1;
+	Error += glm::all(glm::isfinite(glm::quat(-1.0f, -1.0f, -1.0f, -1.0f))) ? 0 : 1;
+	Error += glm::all(glm::isfinite(glm::dquat(-1.0, -1.0, -1.0, -1.0))) ? 0 : 1;
+
+	Error += glm::isfinite(0.0f/Zero_f) ? 1 : 0;
+	Error += glm::isfinite(0.0/Zero_d) ? 1 : 0;
+	Error += glm::isfinite(1.0f/Zero_f) ? 1 : 0;
+	Error += glm::isfinite(1.0/Zero_d) ? 1 : 0;
+	Error += glm::isfinite(-1.0f/Zero_f) ? 1 : 0;
+	Error += glm::isfinite(-1.0/Zero_d) ? 1 : 0;
+
+	Error += glm::all(glm::isfinite(glm::vec4(0.0f/Zero_f))) ? 1 : 0;
+	Error += glm::all(glm::isfinite(glm::dvec4(0.0/Zero_d))) ? 1 : 0;
+	Error += glm::all(glm::isfinite(glm::vec4(1.0f/Zero_f))) ? 1 : 0;
+	Error += glm::all(glm::isfinite(glm::dvec4(1.0/Zero_d))) ? 1 : 0;
+	Error += glm::all(glm::isfinite(glm::vec4(-1.0f/Zero_f))) ? 1 : 0;
+	Error += glm::all(glm::isfinite(glm::dvec4(-1.0/Zero_d))) ? 1 : 0;
+
+	Error += glm::all(glm::isfinite(glm::quat(0.0f/Zero_f, 0.0f/Zero_f, 0.0f/Zero_f, 0.0f/Zero_f))) ? 1 : 0;
+	Error += glm::all(glm::isfinite(glm::dquat(0.0/Zero_d, 0.0/Zero_d, 0.0/Zero_d, 0.0/Zero_d))) ? 1 : 0;
+	Error += glm::all(glm::isfinite(glm::quat(1.0f/Zero_f, 1.0f/Zero_f, 1.0f/Zero_f, 1.0f/Zero_f))) ? 1 : 0;
+	Error += glm::all(glm::isfinite(glm::dquat(1.0/Zero_d, 1.0/Zero_d, 1.0/Zero_d, 1.0/Zero_d))) ? 1 : 0;
+	Error += glm::all(glm::isfinite(glm::quat(-1.0f/Zero_f, -1.0f/Zero_f, -1.0f/Zero_f, -1.0f/Zero_f))) ? 1 : 0;
+	Error += glm::all(glm::isfinite(glm::dquat(-1.0/Zero_d, -1.0/Zero_d, -1.0/Zero_d, -1.0/Zero_d))) ? 1 : 0;
+
 	return Error;
 }