diff --git a/glm/detail/func_common.inl b/glm/detail/func_common.inl index a97ff90c..b987de63 100644 --- a/glm/detail/func_common.inl +++ b/glm/detail/func_common.inl @@ -84,7 +84,7 @@ namespace detail { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_CONFIG_UNRESTRICTED_GENTYPE, "'mix' only accept floating-point inputs for the interpolator a"); - return vec(vec(x) + a * vec(y - x)); + return vec(vec(x) * (static_cast(1) - a) + vec(y) * a); } }; @@ -107,7 +107,7 @@ namespace detail { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_CONFIG_UNRESTRICTED_GENTYPE, "'mix' only accept floating-point inputs for the interpolator a"); - return vec(vec(x) + a * vec(y - x)); + return vec(vec(x) * (static_cast(1) - a) + vec(y) * a); } }; @@ -127,7 +127,7 @@ namespace detail { GLM_STATIC_ASSERT(std::numeric_limits::is_iec559 || GLM_CONFIG_UNRESTRICTED_GENTYPE, "'mix' only accept floating-point inputs for the interpolator a"); - return static_cast(static_cast(x) + a * static_cast(y - x)); + return static_cast(static_cast(x) * (static_cast(1) - a) + static_cast(y) * a); } }; diff --git a/readme.md b/readme.md index d53f0bea..46766eda 100644 --- a/readme.md +++ b/readme.md @@ -59,6 +59,7 @@ glm::mat4 camera(float Translate, glm::vec2 const& Rotate) #### Fixes: - Fixed in mat4x3 conversion #829 - Fixed constexpr issue on GCC #832 +- Fixed mix implementation to improve GLSL conformance #866 ### [GLM 0.9.9.3](https://github.com/g-truc/glm/releases/tag/0.9.9.3) - 2018-10-31 #### Features: