- Added to_string for quat and dual_quat in GTX_string_cast #375

This commit is contained in:
Christophe Riccio 2015-08-31 22:34:14 +02:00
parent d8f7b080d0
commit bf30816e36
3 changed files with 35 additions and 0 deletions

View File

@ -48,6 +48,8 @@
// Dependency:
#include "../glm.hpp"
#include "../gtc/type_precision.hpp"
#include "../gtc/quaternion.hpp"
#include "../gtx/dual_quaternion.hpp"
#include <string>
#if(GLM_COMPILER & GLM_COMPILER_CUDA)

View File

@ -444,6 +444,38 @@ namespace detail
x[3][0], x[3][1], x[3][2], x[3][3]);
}
};
template <typename T, precision P>
struct compute_to_string<tquat, T, P>
{
GLM_FUNC_QUALIFIER static std::string call(tquat<T, P> const & x)
{
char const * PrefixStr = prefix<T>::value();
char const * LiteralStr = literal<T, std::numeric_limits<T>::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 <typename T, precision P>
struct compute_to_string<tdualquat, T, P>
{
GLM_FUNC_QUALIFIER static std::string call(tdualquat<T, P> const & x)
{
char const * PrefixStr = prefix<T>::value();
char const * LiteralStr = literal<T, std::numeric_limits<T>::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 <template <typename, precision> class matType, typename T, precision P>

View File

@ -53,6 +53,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate)
#### [GLM 0.9.7.1](https://github.com/g-truc/glm/releases/latest) - 2015-XX-XX
##### Improvements:
- Improved constexpr for constant functions coverage #198
- Added to_string for quat and dual_quat in GTX_string_cast #375
##### Fixes:
- Fixed strict alignment warnings #235 #370