Added mat4 initializer experiment
This commit is contained in:
@@ -1000,46 +1000,46 @@ namespace detail
|
|||||||
|
|
||||||
GLM_FUNC_QUALIFIER int floatBitsToInt(float const & v)
|
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>
|
template <template <typename, precision> class vecType, precision P>
|
||||||
GLM_FUNC_QUALIFIER vecType<int, P> floatBitsToInt(vecType<float, P> const & v)
|
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)
|
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>
|
template <template <typename, precision> class vecType, precision P>
|
||||||
GLM_FUNC_QUALIFIER vecType<uint, P> floatBitsToUint(vecType<float, P> const & v)
|
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)
|
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>
|
template <template <typename, precision> class vecType, precision P>
|
||||||
GLM_FUNC_QUALIFIER vecType<float, P> intBitsToFloat(vecType<int, P> const & v)
|
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)
|
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>
|
template <template <typename, precision> class vecType, precision P>
|
||||||
GLM_FUNC_QUALIFIER vecType<float, P> uintBitsToFloat(vecType<uint, P> const & v)
|
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>
|
template <typename genType>
|
||||||
|
|||||||
@@ -514,7 +514,7 @@
|
|||||||
// N2672
|
// N2672
|
||||||
#define GLM_HAS_INITIALIZER_LISTS ( \
|
#define GLM_HAS_INITIALIZER_LISTS ( \
|
||||||
(GLM_LANG & GLM_LANG_CXX11_FLAG) || \
|
(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)) || \
|
((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC44)) || \
|
||||||
__has_feature(cxx_generalized_initializers))
|
__has_feature(cxx_generalized_initializers))
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,11 @@
|
|||||||
#include "../fwd.hpp"
|
#include "../fwd.hpp"
|
||||||
#include "type_vec4.hpp"
|
#include "type_vec4.hpp"
|
||||||
#include "type_mat.hpp"
|
#include "type_mat.hpp"
|
||||||
|
#if(GLM_HAS_INITIALIZER_LISTS)
|
||||||
|
# include <initializer_list>
|
||||||
|
#endif //GLM_HAS_INITIALIZER_LISTS
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
namespace glm{
|
namespace glm{
|
||||||
namespace detail
|
namespace detail
|
||||||
@@ -85,6 +89,14 @@ namespace detail
|
|||||||
col_type const & v2,
|
col_type const & v2,
|
||||||
col_type const & v3);
|
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
|
// Conversions
|
||||||
template <typename U>
|
template <typename U>
|
||||||
|
|||||||
@@ -174,11 +174,35 @@ namespace detail
|
|||||||
this->value[3] = col_type(m[3]);
|
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
|
// Conversion constructors
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
template <typename U>
|
template <typename U>
|
||||||
GLM_FUNC_DECL tmat4x4<T, P>::tmat4x4
|
GLM_FUNC_QUALIFIER tmat4x4<T, P>::tmat4x4
|
||||||
(
|
(
|
||||||
U const & s
|
U const & s
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include <glm/core/type_mat4x4.hpp>
|
#include <glm/core/type_mat4x4.hpp>
|
||||||
#include <glm/gtc/epsilon.hpp>
|
#include <glm/gtc/epsilon.hpp>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
void print(glm::dmat4 const & Mat0)
|
void print(glm::dmat4 const & Mat0)
|
||||||
{
|
{
|
||||||
@@ -122,10 +123,53 @@ int test_inverse()
|
|||||||
return Error;
|
return Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int test_ctr()
|
||||||
|
{
|
||||||
|
int Error(0);
|
||||||
|
|
||||||
|
#if(GLM_HAS_INITIALIZER_LISTS)
|
||||||
|
glm::mat4 m1{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
|
||||||
|
|
||||||
|
glm::mat4 m2{
|
||||||
|
{0, 1, 2, 3},
|
||||||
|
{4, 5, 6, 7},
|
||||||
|
{8, 9, 10, 11},
|
||||||
|
{12, 13, 14, 15}};
|
||||||
|
|
||||||
|
std::initializer_list<glm::mat4> m3{
|
||||||
|
{0, 1, 2, 3},
|
||||||
|
{4, 5, 6, 7},
|
||||||
|
{8, 9, 10, 11},
|
||||||
|
{12, 13, 14, 15}};
|
||||||
|
|
||||||
|
glm::mat4 m4{m3};
|
||||||
|
|
||||||
|
/*
|
||||||
|
std::vector<glm::mat4> v{
|
||||||
|
{
|
||||||
|
{ 0, 1, 2, 3 },
|
||||||
|
{ 4, 5, 6, 7 },
|
||||||
|
{ 8, 9, 10, 11 },
|
||||||
|
{ 12, 13, 14, 15 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{ 0, 1, 2, 3 },
|
||||||
|
{ 4, 5, 6, 7 },
|
||||||
|
{ 8, 9, 10, 11 },
|
||||||
|
{ 12, 13, 14, 15 }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
#endif//GLM_HAS_INITIALIZER_LISTS
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
int Error = 0;
|
int Error = 0;
|
||||||
|
|
||||||
|
Error += test_ctr();
|
||||||
Error += test_inverse_dmat4x4();
|
Error += test_inverse_dmat4x4();
|
||||||
Error += test_inverse_mat4x4();
|
Error += test_inverse_mat4x4();
|
||||||
Error += test_operators();
|
Error += test_operators();
|
||||||
|
|||||||
@@ -41,7 +41,13 @@ int test_vec4_ctor()
|
|||||||
int Error = 0;
|
int Error = 0;
|
||||||
|
|
||||||
#if(GLM_HAS_INITIALIZER_LISTS)
|
#if(GLM_HAS_INITIALIZER_LISTS)
|
||||||
glm::vec4 v{0, 1, 2, 3};
|
{
|
||||||
|
glm::vec4 a{ 0, 1, 2, 3 };
|
||||||
|
std::vector<glm::vec4> v = {
|
||||||
|
{0, 1, 2, 3},
|
||||||
|
{4, 5, 6, 7},
|
||||||
|
{8, 9, 0, 1}};
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user