Added mat4 initializer experiment
This commit is contained in:
@@ -1000,46 +1000,46 @@ namespace detail
|
||||
|
||||
GLM_FUNC_QUALIFIER int floatBitsToInt(float const & v)
|
||||
{
|
||||
return *reinterpret_cast<int*>(const_cast<float*>(&v));
|
||||
return reinterpret_cast<int&>(const_cast<float&>(v));
|
||||
}
|
||||
|
||||
template <template <typename, precision> class vecType, precision P>
|
||||
GLM_FUNC_QUALIFIER vecType<int, P> floatBitsToInt(vecType<float, P> const & v)
|
||||
{
|
||||
return *reinterpret_cast<vecType<int, P>*>(const_cast<vecType<float, P>*>(&v));
|
||||
return reinterpret_cast<vecType<int, P>&>(const_cast<vecType<float, P>&>(v));
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint floatBitsToUint(float const & v)
|
||||
{
|
||||
return *reinterpret_cast<uint*>(const_cast<float*>(&v));
|
||||
return reinterpret_cast<uint&>(const_cast<float&>(v));
|
||||
}
|
||||
|
||||
template <template <typename, precision> class vecType, precision P>
|
||||
GLM_FUNC_QUALIFIER vecType<uint, P> floatBitsToUint(vecType<float, P> const & v)
|
||||
{
|
||||
return *reinterpret_cast<vecType<uint, P>*>(const_cast<vecType<float, P>*>(&v));
|
||||
return reinterpret_cast<vecType<uint, P>&>(const_cast<vecType<float, P>&>(v));
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER float intBitsToFloat(int const & v)
|
||||
{
|
||||
return *reinterpret_cast<float*>(const_cast<int*>(&v));
|
||||
return reinterpret_cast<float&>(const_cast<int&>(v));
|
||||
}
|
||||
|
||||
template <template <typename, precision> class vecType, precision P>
|
||||
GLM_FUNC_QUALIFIER vecType<float, P> intBitsToFloat(vecType<int, P> const & v)
|
||||
{
|
||||
return *reinterpret_cast<vecType<float, P>*>(const_cast<vecType<int, P>*>(&v));
|
||||
return reinterpret_cast<vecType<float, P>&>(const_cast<vecType<int, P>&>(v));
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER float uintBitsToFloat(uint const & v)
|
||||
{
|
||||
return *reinterpret_cast<float*>(const_cast<uint*>(&v));
|
||||
return reinterpret_cast<float&>(const_cast<uint&>(v));
|
||||
}
|
||||
|
||||
template <template <typename, precision> class vecType, precision P>
|
||||
GLM_FUNC_QUALIFIER vecType<float, P> uintBitsToFloat(vecType<uint, P> const & v)
|
||||
{
|
||||
return *reinterpret_cast<vecType<float, P>*>(const_cast<vecType<uint, P>*>(&v));
|
||||
return reinterpret_cast<vecType<float, P>&>(const_cast<vecType<uint, P>&>(v));
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
|
||||
@@ -514,7 +514,7 @@
|
||||
// N2672
|
||||
#define GLM_HAS_INITIALIZER_LISTS ( \
|
||||
(GLM_LANG & GLM_LANG_CXX11_FLAG) || \
|
||||
((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2012)) || \
|
||||
((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2013)) || \
|
||||
((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC44)) || \
|
||||
__has_feature(cxx_generalized_initializers))
|
||||
|
||||
|
||||
@@ -32,7 +32,11 @@
|
||||
#include "../fwd.hpp"
|
||||
#include "type_vec4.hpp"
|
||||
#include "type_mat.hpp"
|
||||
#if(GLM_HAS_INITIALIZER_LISTS)
|
||||
# include <initializer_list>
|
||||
#endif //GLM_HAS_INITIALIZER_LISTS
|
||||
#include <limits>
|
||||
#include <cstddef>
|
||||
|
||||
namespace glm{
|
||||
namespace detail
|
||||
@@ -85,6 +89,14 @@ namespace detail
|
||||
col_type const & v2,
|
||||
col_type const & v3);
|
||||
|
||||
#if(GLM_HAS_INITIALIZER_LISTS)
|
||||
template <typename U>
|
||||
GLM_FUNC_DECL tmat4x4(std::initializer_list<U> const & m);
|
||||
|
||||
template <typename U>
|
||||
GLM_FUNC_DECL tmat4x4(std::initializer_list<tvec4<U, P> > const & m);
|
||||
#endif//GLM_HAS_INITIALIZER_LISTS
|
||||
|
||||
//////////////////////////////////////
|
||||
// Conversions
|
||||
template <typename U>
|
||||
|
||||
@@ -174,11 +174,35 @@ namespace detail
|
||||
this->value[3] = col_type(m[3]);
|
||||
}
|
||||
|
||||
#if(GLM_HAS_INITIALIZER_LISTS)
|
||||
template <typename T, precision P>
|
||||
template <typename U>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, P>::tmat4x4(std::initializer_list<U> const & m)
|
||||
{
|
||||
assert(m.size() >= this->length());
|
||||
|
||||
this->value[0] = static_cast<tvec4<T, P> >(reinterpret_cast<tvec4<U, P>&>(const_cast<U&>(m.begin()[0])));
|
||||
this->value[1] = static_cast<tvec4<T, P> >(reinterpret_cast<tvec4<U, P>&>(const_cast<U&>(m.begin()[4])));
|
||||
this->value[2] = static_cast<tvec4<T, P> >(reinterpret_cast<tvec4<U, P>&>(const_cast<U&>(m.begin()[8])));
|
||||
this->value[3] = static_cast<tvec4<T, P> >(reinterpret_cast<tvec4<U, P>&>(const_cast<U&>(m.begin()[12])));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
template <typename U>
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, P>::tmat4x4(std::initializer_list<tvec4<U, P> > const & m)
|
||||
{
|
||||
this->value[0] = static_cast<tvec4<T, P> >(m.begin()[0]);
|
||||
this->value[1] = static_cast<tvec4<T, P> >(m.begin()[1]);
|
||||
this->value[2] = static_cast<tvec4<T, P> >(m.begin()[2]);
|
||||
this->value[3] = static_cast<tvec4<T, P> >(m.begin()[3]);
|
||||
}
|
||||
#endif//GLM_HAS_INITIALIZER_LISTS
|
||||
|
||||
//////////////////////////////////////
|
||||
// Conversion constructors
|
||||
template <typename T, precision P>
|
||||
template <typename U>
|
||||
GLM_FUNC_DECL tmat4x4<T, P>::tmat4x4
|
||||
GLM_FUNC_QUALIFIER tmat4x4<T, P>::tmat4x4
|
||||
(
|
||||
U const & s
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user