From bf30816e363b196805c99ef06c41ec1560005040 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Mon, 31 Aug 2015 22:34:14 +0200 Subject: [PATCH] - Added to_string for quat and dual_quat in GTX_string_cast #375 --- glm/gtx/string_cast.hpp | 2 ++ glm/gtx/string_cast.inl | 32 ++++++++++++++++++++++++++++++++ readme.md | 1 + 3 files changed, 35 insertions(+) diff --git a/glm/gtx/string_cast.hpp b/glm/gtx/string_cast.hpp index e04320c0..c292efd1 100644 --- a/glm/gtx/string_cast.hpp +++ b/glm/gtx/string_cast.hpp @@ -48,6 +48,8 @@ // Dependency: #include "../glm.hpp" #include "../gtc/type_precision.hpp" +#include "../gtc/quaternion.hpp" +#include "../gtx/dual_quaternion.hpp" #include #if(GLM_COMPILER & GLM_COMPILER_CUDA) diff --git a/glm/gtx/string_cast.inl b/glm/gtx/string_cast.inl index fb70ebc0..c21fa75f 100644 --- a/glm/gtx/string_cast.inl +++ b/glm/gtx/string_cast.inl @@ -444,6 +444,38 @@ namespace detail x[3][0], x[3][1], x[3][2], x[3][3]); } }; + + + template + struct compute_to_string + { + GLM_FUNC_QUALIFIER static std::string call(tquat const & x) + { + char const * PrefixStr = prefix::value(); + char const * LiteralStr = literal::is_iec559>::value(); + std::string FormatStr(detail::format("%squat(%s, %s, %s, %s)", + PrefixStr, + LiteralStr, LiteralStr, LiteralStr, LiteralStr)); + + return detail::format(FormatStr.c_str(), x[0], x[1], x[2], x[3]); + } + }; + + template + struct compute_to_string + { + GLM_FUNC_QUALIFIER static std::string call(tdualquat const & x) + { + 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))", + PrefixStr, + LiteralStr, LiteralStr, LiteralStr, LiteralStr)); + + return detail::format(FormatStr.c_str(), x.real[0], x.real[1], x.real[2], x.real[3], x.dual[0], x.dual[1], x.dual[2], x.dual[3]); + } + }; + }//namespace detail template