diff --git a/glm/core/func_geometric.inl b/glm/core/func_geometric.inl index 438bef9d..494c875f 100644 --- a/glm/core/func_geometric.inl +++ b/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 diff --git a/test/core/core_func_common.cpp b/test/core/core_func_common.cpp index c34838b4..a0a47f8e 100644 --- a/test/core/core_func_common.cpp +++ b/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(); diff --git a/test/core/core_func_geometric.cpp b/test/core/core_func_geometric.cpp index ebdb159b..05dbbade 100644 --- a/test/core/core_func_geometric.cpp +++ b/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 +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; }