diff --git a/glm/gtx/string_cast.inl b/glm/gtx/string_cast.inl index b376ce4e..4ff9e671 100644 --- a/glm/gtx/string_cast.inl +++ b/glm/gtx/string_cast.inl @@ -446,15 +446,15 @@ namespace detail { char const * PrefixStr = prefix::value(); char const * LiteralStr = literal::is_iec559>::value(); - std::string FormatStr(detail::format("%squat(%s, %s, %s, %s)", + std::string FormatStr(detail::format("%squat(%s, {%s, %s, %s})", PrefixStr, LiteralStr, LiteralStr, LiteralStr, LiteralStr)); return detail::format(FormatStr.c_str(), + static_cast::value_type>(x[3]), static_cast::value_type>(x[0]), static_cast::value_type>(x[1]), - static_cast::value_type>(x[2]), - static_cast::value_type>(x[3])); + static_cast::value_type>(x[2])); } }; @@ -465,19 +465,19 @@ namespace detail { char const * PrefixStr = prefix::value(); char const * LiteralStr = literal::is_iec559>::value(); - std::string FormatStr(detail::format("%sdualquat((%s, %s, %s, %s), (%s, %s, %s, %s))", + std::string FormatStr(detail::format("%sdualquat((%s, {%s, %s, %s}), (%s, {%s, %s, %s}))", PrefixStr, LiteralStr, LiteralStr, LiteralStr, LiteralStr)); return detail::format(FormatStr.c_str(), + static_cast::value_type>(x.real[3]), static_cast::value_type>(x.real[0]), static_cast::value_type>(x.real[1]), static_cast::value_type>(x.real[2]), - static_cast::value_type>(x.real[3]), + static_cast::value_type>(x.dual[3]), static_cast::value_type>(x.dual[0]), static_cast::value_type>(x.dual[1]), - static_cast::value_type>(x.dual[2]), - static_cast::value_type>(x.dual[3])); + static_cast::value_type>(x.dual[2])); } }; diff --git a/readme.md b/readme.md index 74043af7..ff374be0 100644 --- a/readme.md +++ b/readme.md @@ -101,7 +101,8 @@ glm::mat4 camera(float Translate, glm::vec2 const& Rotate) - Fixed documentation warnings - Fixed GLM_HAS_OPENMP when OpenMP is not enabled - Fixed Better follow GLSL min and max specification #372 -- Fixed quaternion constructor from two vectors special cases #469 +- Fixed quaternion constructor from two vectors special cases #469 +- Fixed glm::to_string on quaternions wrong components order #681 #### Deprecation: - Requires Visual Studio 2013, GCC 4.7, Clang 3.4, Cuda 7, ICC 2013 or a C++11 compiler diff --git a/test/gtx/gtx_string_cast.cpp b/test/gtx/gtx_string_cast.cpp index 812017a0..9cfa48f6 100644 --- a/test/gtx/gtx_string_cast.cpp +++ b/test/gtx/gtx_string_cast.cpp @@ -117,11 +117,24 @@ int test_string_cast_matrix() return Error; } +int test_string_cast_quaternion() +{ + int Error = 0; + + glm::quat Q0 = glm::quat(1.0f, 2.0f, 3.0f, 4.0f); + std::string S0 = glm::to_string(Q0); + Error += S0 != std::string("quat(1.000000, {2.000000, 3.000000, 4.000000})") ? 1 : 0; + + return Error; + +} + int main() { int Error = 0; Error += test_string_cast_vector(); Error += test_string_cast_matrix(); + Error += test_string_cast_quaternion(); return Error; }