Browse Source

Fixed refract for double based types

Christophe Riccio 14 years ago
parent
commit
390498ef87
3 changed files with 50 additions and 5 deletions
  1. 1 1
      glm/core/func_geometric.inl
  2. 1 1
      test/core/core_func_common.cpp
  3. 48 3
      test/core/core_func_geometric.cpp

+ 1 - 1
glm/core/func_geometric.inl

@@ -279,7 +279,7 @@ namespace glm
 		genType const & N
 	)
 	{
-		return I - N * dot(N, I) * float(2);
+		return I - N * dot(N, I) * genType(2);
 	}
 
     // refract

+ 1 - 1
test/core/core_func_common.cpp

@@ -245,7 +245,7 @@ int test_roundEven()
 
 int main()
 {
-	int Error = 0;
+	int Error(0);
 
 	Error += test_floatBitsToInt();
 	Error += test_floatBitsToUint();

+ 48 - 3
test/core/core_func_geometric.cpp

@@ -2,17 +2,62 @@
 // OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // Created : 2011-01-15
-// Updated : 2011-09-13
+// Updated : 2011-11-14
 // Licence : This source is under MIT licence
 // File    : test/gtx/func_geometric.cpp
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 #include <glm/glm.hpp>
 
+int test_reflect()
+{
+	int Error = 0;
+
+	{
+		glm::vec2 A(1.0f, 0.0f);
+		glm::vec2 B(0.0f, 1.0f);
+		glm::vec2 C = glm::reflect(A, B);
+		Error += C == glm::vec2(-1.0, 0.0) ? 0 : 1;
+	}
+
+	{
+		glm::dvec2 A(1.0f, 0.0f);
+		glm::dvec2 B(0.0f, 1.0f);
+		glm::dvec2 C = glm::reflect(A, B);
+		Error += C == glm::dvec2(-1.0, 0.0) ? 0 : 1;
+	}
+
+	return Error;
+}
+
+int test_refract()
+{
+	int Error = 0;
+
+	{
+		glm::vec2 A(1.0f, 0.0f);
+		glm::vec2 B(0.0f, 1.0f);
+		glm::vec2 C = glm::reflect(A, B);
+		Error += C == glm::vec2(-1.0, 0.0) ? 0 : 1;
+	}
+
+	{
+		glm::dvec2 A(1.0f, 0.0f);
+		glm::dvec2 B(0.0f, 1.0f);
+		glm::dvec2 C = glm::reflect(A, B);
+		Error += C == glm::dvec2(-1.0, 0.0) ? 0 : 1;
+	}
+
+	return Error;
+}
+
 int main()
 {
-	int Failed = 0;
+	int Error(0);
+
+	Error += test_reflect();
+	Error += test_refract();
 
-	return Failed;
+	return Error;
 }