From 258361ccd450ec078cc4b2ab541712445422e0bc Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Tue, 1 Oct 2013 02:00:27 +0200 Subject: [PATCH] Added C++11 initalizer lists to quaternions --- glm/gtc/quaternion.hpp | 5 +++++ glm/gtc/quaternion.inl | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/glm/gtc/quaternion.hpp b/glm/gtc/quaternion.hpp index cf5690b7..4d9f6c13 100644 --- a/glm/gtc/quaternion.hpp +++ b/glm/gtc/quaternion.hpp @@ -77,6 +77,11 @@ namespace detail T const & y, T const & z); +#if(GLM_HAS_INITIALIZER_LISTS) + template + GLM_FUNC_DECL tquat(std::initializer_list l); +#endif//GLM_HAS_INITIALIZER_LISTS + // Convertions /// Create a quaternion from two normalized axis diff --git a/glm/gtc/quaternion.inl b/glm/gtc/quaternion.inl index 197dc6eb..d5bbc10d 100644 --- a/glm/gtc/quaternion.inl +++ b/glm/gtc/quaternion.inl @@ -83,6 +83,19 @@ namespace detail w(w) {} +#if(GLM_HAS_INITIALIZER_LISTS) + template + template + GLM_FUNC_QUALIFIER tquat::tquat(std::initializer_list l) : + x(static_cast(l.begin()[0])), + y(static_cast(l.begin()[1])), + z(static_cast(l.begin()[2])), + w(static_cast(l.begin()[3])) + { + assert(v.size() >= this->length()); + } +#endif//GLM_HAS_INITIALIZER_LISTS + ////////////////////////////////////////////////////////////// // tquat conversions