Fixed default initialization with vector and quaternion types using GLM_FORCE_CTOR_INIT #812

This commit is contained in:
Christophe Riccio 2018-09-10 15:45:01 +02:00
parent cf6504b65e
commit fe83040cbd
9 changed files with 143 additions and 11 deletions

View File

@ -710,21 +710,22 @@ namespace detail
///////////////////////////////////////////////////////////////////////////////////
// Configure the use of defaulted initialized types
#define GLM_CTOR_INITIALIZER_LIST (1 << 1)
#define GLM_CTOR_INITIALISATION (1 << 2)
#define GLM_CTOR_INIT_DISABLE 0
#define GLM_CTOR_INITIALIZER_LIST 1
#define GLM_CTOR_INITIALISATION 2
#if defined(GLM_FORCE_CTOR_INIT) && GLM_HAS_INITIALIZER_LISTS
# define GLM_CONFIG_CTOR_INIT GLM_CTOR_INITIALIZER_LIST
#elif defined(GLM_FORCE_CTOR_INIT) && !GLM_HAS_INITIALIZER_LISTS
# define GLM_CONFIG_CTOR_INIT GLM_CTOR_INITIALISATION
#else
# define GLM_CONFIG_CTOR_INIT GLM_DISABLE
# define GLM_CONFIG_CTOR_INIT GLM_CTOR_INIT_DISABLE
#endif
///////////////////////////////////////////////////////////////////////////////////
// Configure the use of defaulted function
#if GLM_HAS_DEFAULTED_FUNCTIONS && GLM_CONFIG_CTOR_INIT == GLM_DISABLE
#if GLM_HAS_DEFAULTED_FUNCTIONS && GLM_CONFIG_CTOR_INIT == GLM_CTOR_INIT_DISABLE
# define GLM_CONFIG_DEFAULTED_FUNCTIONS GLM_ENABLE
# define GLM_DEFAULT = default
#else

View File

@ -89,7 +89,7 @@ namespace detail
# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_DISABLE
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR qua<T, Q>::qua()
# if GLM_CONFIG_DEFAULTED_FUNCTIONS != GLM_DISABLE
# if GLM_CONFIG_CTOR_INIT != GLM_CTOR_INIT_DISABLE
: x(0), y(0), z(0), w(1)
# endif
{}

View File

@ -9,7 +9,7 @@ namespace glm
# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_DISABLE
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<1, T, Q>::vec()
# if GLM_CONFIG_DEFAULTED_FUNCTIONS != GLM_DISABLE
# if GLM_CONFIG_CTOR_INIT != GLM_CTOR_INIT_DISABLE
: x(0)
# endif
{}

View File

@ -9,7 +9,7 @@ namespace glm
# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_DISABLE
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<2, T, Q>::vec()
# if GLM_CONFIG_DEFAULTED_FUNCTIONS != GLM_DISABLE
# if GLM_CONFIG_CTOR_INIT != GLM_CTOR_INIT_DISABLE
: x(0), y(0)
# endif
{}

View File

@ -9,7 +9,7 @@ namespace glm
# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_DISABLE
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<3, T, Q>::vec()
# if GLM_CONFIG_DEFAULTED_FUNCTIONS != GLM_DISABLE
# if GLM_CONFIG_CTOR_INIT != GLM_CTOR_INIT_DISABLE
: x(0), y(0), z(0)
# endif
{}

View File

@ -132,7 +132,7 @@ namespace detail
# if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_DISABLE
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR vec<4, T, Q>::vec()
# if GLM_CONFIG_DEFAULTED_FUNCTIONS != GLM_DISABLE
# if GLM_CONFIG_CTOR_INIT != GLM_CTOR_INIT_DISABLE
: x(0), y(0), z(0), w(0)
# endif
{}

View File

@ -55,6 +55,7 @@ glm::mat4 camera(float Translate, glm::vec2 const& Rotate)
### [GLM 0.9.9.2](https://github.com/g-truc/glm/commits/master) - 2018-XX-XX
#### Fixes:
- Fixed GLM_FORCE_CXX** section in the manual
- Fixed default initialization with vector and quaternion types using GLM_FORCE_CTOR_INIT #812
### [GLM 0.9.9.1](https://github.com/g-truc/glm/releases/tag/0.9.9.1) - 2018-09-03
#### Features:

View File

@ -3,10 +3,137 @@
#include <glm/glm.hpp>
#include <glm/ext.hpp>
int main()
static int test_vec()
{
int Error = 0;
glm::vec1 V1;
Error += glm::all(glm::equal(V1, glm::vec1(0), glm::epsilon<float>())) ? 0 : 1;
glm::dvec1 U1;
Error += glm::all(glm::equal(U1, glm::dvec1(0), glm::epsilon<double>())) ? 0 : 1;
glm::vec2 V2;
Error += glm::all(glm::equal(V2, glm::vec2(0, 0), glm::epsilon<float>())) ? 0 : 1;
glm::dvec2 U2;
Error += glm::all(glm::equal(U2, glm::dvec2(0, 0), glm::epsilon<double>())) ? 0 : 1;
glm::vec3 V3;
Error += glm::all(glm::equal(V3, glm::vec3(0, 0, 0), glm::epsilon<float>())) ? 0 : 1;
glm::dvec3 U3;
Error += glm::all(glm::equal(U3, glm::dvec3(0, 0, 0), glm::epsilon<double>())) ? 0 : 1;
glm::vec4 V4;
Error += glm::all(glm::equal(V4, glm::vec4(0, 0, 0, 0), glm::epsilon<float>())) ? 0 : 1;
glm::dvec4 U4;
Error += glm::all(glm::equal(U4, glm::dvec4(0, 0, 0, 0), glm::epsilon<double>())) ? 0 : 1;
return Error;
}
static int test_mat()
{
int Error = 0;
{
glm::mat2x2 F;
Error += glm::all(glm::equal(F, glm::mat2x2(1), glm::epsilon<float>())) ? 0 : 1;
glm::dmat2x2 D;
Error += glm::all(glm::equal(D, glm::dmat2x2(1), glm::epsilon<double>())) ? 0 : 1;
}
{
glm::mat2x3 F;
Error += glm::all(glm::equal(F, glm::mat2x3(1), glm::epsilon<float>())) ? 0 : 1;
glm::dmat2x3 D;
Error += glm::all(glm::equal(D, glm::dmat2x3(1), glm::epsilon<double>())) ? 0 : 1;
}
{
glm::mat2x4 F;
Error += glm::all(glm::equal(F, glm::mat2x4(1), glm::epsilon<float>())) ? 0 : 1;
glm::dmat2x4 D;
Error += glm::all(glm::equal(D, glm::dmat2x4(1), glm::epsilon<double>())) ? 0 : 1;
}
{
glm::mat3x2 F;
Error += glm::all(glm::equal(F, glm::mat3x2(1), glm::epsilon<float>())) ? 0 : 1;
glm::dmat3x2 D;
Error += glm::all(glm::equal(D, glm::dmat3x2(1), glm::epsilon<double>())) ? 0 : 1;
}
{
glm::mat3x3 F;
Error += glm::all(glm::equal(F, glm::mat3x3(1), glm::epsilon<float>())) ? 0 : 1;
glm::dmat3x3 D;
Error += glm::all(glm::equal(D, glm::dmat3x3(1), glm::epsilon<double>())) ? 0 : 1;
}
{
glm::mat3x4 F;
Error += glm::all(glm::equal(F, glm::mat3x4(1), glm::epsilon<float>())) ? 0 : 1;
glm::dmat3x4 D;
Error += glm::all(glm::equal(D, glm::dmat3x4(1), glm::epsilon<double>())) ? 0 : 1;
}
{
glm::mat4x2 F;
Error += glm::all(glm::equal(F, glm::mat4x2(1), glm::epsilon<float>())) ? 0 : 1;
glm::dmat4x2 D;
Error += glm::all(glm::equal(D, glm::dmat4x2(1), glm::epsilon<double>())) ? 0 : 1;
}
{
glm::mat4x3 F;
Error += glm::all(glm::equal(F, glm::mat4x3(1), glm::epsilon<float>())) ? 0 : 1;
glm::dmat4x3 D;
Error += glm::all(glm::equal(D, glm::dmat4x3(1), glm::epsilon<double>())) ? 0 : 1;
}
{
glm::mat4x4 F;
Error += glm::all(glm::equal(F, glm::mat4x4(1), glm::epsilon<float>())) ? 0 : 1;
glm::dmat4x4 D;
Error += glm::all(glm::equal(D, glm::dmat4x4(1), glm::epsilon<double>())) ? 0 : 1;
}
return Error;
}
static int test_qua()
{
int Error = 0;
glm::quat F;
Error += glm::all(glm::equal(F, glm::quat(1, 0, 0, 0), glm::epsilon<float>())) ? 0 : 1;
glm::dquat D;
Error += glm::all(glm::equal(D, glm::dquat(1, 0, 0, 0), glm::epsilon<double>())) ? 0 : 1;
return Error;
}
int main()
{
int Error = 0;
Error += test_vec();
Error += test_mat();
Error += test_qua();
return Error;
}

View File

@ -422,7 +422,10 @@ namespace heap
p->f = 0.f;
delete p;
Error += sizeof(B) == (sizeof(glm::vec4) + sizeof(float) * 2) ? 0 : 1;
std::size_t const Count1 = sizeof(B);
std::size_t const Count2 = 32;
Error += Count1 == Count2 ? 0 : 1;
return Error;
}