From 8508e099d0452e25f56b896fc6ebdd0b73e52b35 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Thu, 8 Oct 2015 23:49:43 +0200 Subject: [PATCH] Fixed compScale test --- glm/gtx/component_wise.inl | 7 ++++--- test/gtx/gtx_component_wise.cpp | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/glm/gtx/component_wise.inl b/glm/gtx/component_wise.inl index 4c380b7a..42a641da 100644 --- a/glm/gtx/component_wise.inl +++ b/glm/gtx/component_wise.inl @@ -77,9 +77,10 @@ namespace detail { GLM_FUNC_QUALIFIER static vecType call(vecType const & v) { - floatType const Min = static_cast(std::numeric_limits::min()); - floatType const Max = static_cast(std::numeric_limits::max()); - return (vecType(v) + Min) * (Max - Min) * static_cast(2) - static_cast(1); + floatType const Max = static_cast(std::numeric_limits::max()) + static_cast(0.5); + vecType const Scaled(v * Max); + vecType const Result(Scaled - static_cast(0.5)); + return Result; } }; diff --git a/test/gtx/gtx_component_wise.cpp b/test/gtx/gtx_component_wise.cpp index 3f86836d..318e825d 100644 --- a/test/gtx/gtx_component_wise.cpp +++ b/test/gtx/gtx_component_wise.cpp @@ -104,6 +104,15 @@ namespace compScale Error += A.w == 255 ? 0 : 1; } + { + glm::i8vec4 const A = glm::compScale(glm::vec4(0.0f,-1.0f, 0.5f, 1.0f)); + + Error += A.x == 0 ? 0 : 1; + Error += A.y == -128 ? 0 : 1; + Error += A.z == 63 ? 0 : 1; + Error += A.w == 127 ? 0 : 1; + } + { glm::u16vec4 const A = glm::compScale(glm::vec4(0.0f, 0.2f, 0.5f, 1.0f)); @@ -113,6 +122,15 @@ namespace compScale Error += A.w == 65535 ? 0 : 1; } + { + glm::i16vec4 const A = glm::compScale(glm::vec4(0.0f,-1.0f, 0.5f, 1.0f)); + + Error += A.x == 0 ? 0 : 1; + Error += A.y == -32768 ? 0 : 1; + Error += A.z == 16383 ? 0 : 1; + Error += A.w == 32767 ? 0 : 1; + } + return Error; } }// compScale