Clean up GLM_FORCE_NO_CTOR_INIT and fixed tests

This commit is contained in:
Christophe Riccio 2017-07-25 22:15:55 +02:00
parent f2cb4a3fdf
commit c933f6e591
9 changed files with 37 additions and 32 deletions

View File

@ -342,23 +342,14 @@ namespace detail
# if !GLM_HAS_DEFAULTED_FUNCTIONS # if !GLM_HAS_DEFAULTED_FUNCTIONS
template<> template<>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD vec<4, float, aligned_lowp>::vec() GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD vec<4, float, aligned_lowp>::vec()
# ifndef GLM_FORCE_NO_CTOR_INIT
: data(_mm_setzero_ps())
# endif
{} {}
template<> template<>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD vec<4, float, aligned_mediump>::vec() GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD vec<4, float, aligned_mediump>::vec()
# ifndef GLM_FORCE_NO_CTOR_INIT
: data(_mm_setzero_ps())
# endif
{} {}
template<> template<>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD vec<4, float, aligned_highp>::vec() GLM_FUNC_QUALIFIER GLM_CONSTEXPR_SIMD vec<4, float, aligned_highp>::vec()
# ifndef GLM_FORCE_NO_CTOR_INIT
: data(_mm_setzero_ps())
# endif
{} {}
# endif//!GLM_HAS_DEFAULTED_FUNCTIONS # endif//!GLM_HAS_DEFAULTED_FUNCTIONS

View File

@ -133,6 +133,12 @@ namespace glm
template<typename T, precision P> template<typename T, precision P>
GLM_FUNC_DECL bool operator!=(tdualquat<T, P> const & q1, tdualquat<T, P> const & q2); GLM_FUNC_DECL bool operator!=(tdualquat<T, P> const & q1, tdualquat<T, P> const & q2);
/// Creates an identity dual quaternion.
///
/// @see gtx_dual_quaternion
template <typename T, precision P>
GLM_FUNC_DECL tdualquat<T, P> dual_quat_identity();
/// Returns the normalized quaternion. /// Returns the normalized quaternion.
/// ///
/// @see gtx_dual_quaternion /// @see gtx_dual_quaternion

View File

@ -218,6 +218,14 @@ namespace glm
// -- Operations -- // -- Operations --
template<typename T, precision P>
GLM_FUNC_QUALIFIER tdualquat<T, P> dual_quat_identity()
{
return tdualquat<T, P>(
tquat<T, P>(static_cast<T>(1), static_cast<T>(0), static_cast<T>(0), static_cast<T>(0)),
tquat<T, P>(static_cast<T>(0), static_cast<T>(0), static_cast<T>(0), static_cast<T>(0)));
}
template<typename T, precision P> template<typename T, precision P>
GLM_FUNC_QUALIFIER tdualquat<T, P> normalize(tdualquat<T, P> const & q) GLM_FUNC_QUALIFIER tdualquat<T, P> normalize(tdualquat<T, P> const & q)
{ {

View File

@ -32,6 +32,12 @@ namespace glm
/// @addtogroup gtx_quaternion /// @addtogroup gtx_quaternion
/// @{ /// @{
/// Create an identity quaternion.
///
/// @see gtx_quaternion
template<typename T, precision P>
GLM_FUNC_DECL tquat<T, P> quat_identity();
/// Compute a cross product between a quaternion and a vector. /// Compute a cross product between a quaternion and a vector.
/// ///
/// @see gtx_quaternion /// @see gtx_quaternion

View File

@ -6,6 +6,12 @@
namespace glm namespace glm
{ {
template<typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P> quat_identity()
{
return tquat<T, P>(static_cast<T>(1), static_cast<T>(0), static_cast<T>(0), static_cast<T>(0));
}
template<typename T, precision P> template<typename T, precision P>
GLM_FUNC_QUALIFIER vec<3, T, P> cross(vec<3, T, P> const& v, tquat<T, P> const& q) GLM_FUNC_QUALIFIER vec<3, T, P> cross(vec<3, T, P> const& v, tquat<T, P> const& q)
{ {

View File

@ -101,6 +101,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate)
- Removed GLM_MESSAGES, use GLM_FORCE_MESSAGES instead - Removed GLM_MESSAGES, use GLM_FORCE_MESSAGES instead
- Removed GLM_DEPTH_ZERO_TO_ONE, use GLM_FORCE_DEPTH_ZERO_TO_ONE instead - Removed GLM_DEPTH_ZERO_TO_ONE, use GLM_FORCE_DEPTH_ZERO_TO_ONE instead
- Removed GLM_LEFT_HANDED, use GLM_FORCE_LEFT_HANDED instead - Removed GLM_LEFT_HANDED, use GLM_FORCE_LEFT_HANDED instead
- Removed GLM_FORCE_NO_CTOR_INIT
--- ---
### [GLM 0.9.8.5](https://github.com/g-truc/glm/tree/0.9.8) - 2017-0X-XX ### [GLM 0.9.8.5](https://github.com/g-truc/glm/tree/0.9.8) - 2017-0X-XX

View File

@ -1,4 +1,3 @@
#define GLM_FORCE_NO_CTOR_INIT
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <glm/gtc/vec1.hpp> #include <glm/gtc/vec1.hpp>
#include <glm/gtc/quaternion.hpp> #include <glm/gtc/quaternion.hpp>
@ -76,14 +75,6 @@ int test_vec4_ctor()
{ {
int Error = 0; int Error = 0;
# ifndef GLM_FORCE_NO_CTOR_INIT
{
glm::vec4 A;
glm::vec4 B(0);
Error += glm::all(glm::equal(A, B)) ? 0 : 1;
}
# endif//GLM_FORCE_NO_CTOR_INIT
# if GLM_HAS_DEFAULTED_FUNCTIONS # if GLM_HAS_DEFAULTED_FUNCTIONS
{ {
union pack union pack
@ -316,7 +307,7 @@ int test_quat_ctor()
{ {
int Error = 0; int Error = 0;
# if GLM_HAS_DEFAULTED_FUNCTIONS && defined(GLM_FORCE_NO_CTOR_INIT) # if GLM_HAS_DEFAULTED_FUNCTIONS
{ {
union pack union pack
{ {

View File

@ -135,7 +135,7 @@ int test_quat_slerp()
float const Epsilon = 0.0001f;//glm::epsilon<float>(); float const Epsilon = 0.0001f;//glm::epsilon<float>();
float sqrt2 = sqrt(2.0f)/2.0f; float sqrt2 = sqrt(2.0f)/2.0f;
glm::quat id; glm::quat id(static_cast<float>(1), static_cast<float>(0), static_cast<float>(0), static_cast<float>(0));
glm::quat Y90rot(sqrt2, 0.0f, sqrt2, 0.0f); glm::quat Y90rot(sqrt2, 0.0f, sqrt2, 0.0f);
glm::quat Y180rot(0.0f, 0.0f, 1.0f, 0.0f); glm::quat Y180rot(0.0f, 0.0f, 1.0f, 0.0f);
@ -211,16 +211,12 @@ int test_quat_mul()
glm::quat temp5 = glm::normalize(temp1 * temp2); glm::quat temp5 = glm::normalize(temp1 * temp2);
glm::vec3 temp6 = temp5 * glm::vec3(0.0, 1.0, 0.0) * glm::inverse(temp5); glm::vec3 temp6 = temp5 * glm::vec3(0.0, 1.0, 0.0) * glm::inverse(temp5);
# ifndef GLM_FORCE_NO_CTOR_INIT glm::quat temp7(1.0f, glm::vec3(0.0, 1.0, 0.0));
{
glm::quat temp7;
temp7 *= temp5; temp7 *= temp5;
temp7 *= glm::inverse(temp5); temp7 *= glm::inverse(temp5);
Error += temp7 != glm::quat(); Error += temp7 != glm::quat(1.0f, glm::vec3(0.0, 1.0, 0.0));
}
# endif
return Error; return Error;
} }

View File

@ -22,10 +22,10 @@ float myfrand() // returns values from -1 to 1 inclusive
int test_dquat_type() int test_dquat_type()
{ {
glm::dvec3 vA; glm::dvec3 vA;
glm::dquat dqA,dqB; glm::dquat dqA, dqB;
glm::ddualquat C(dqA,dqB); glm::ddualquat C(dqA, dqB);
glm::ddualquat B(dqA); glm::ddualquat B(dqA);
glm::ddualquat D(dqA,vA); glm::ddualquat D(dqA, vA);
return 0; return 0;
} }
@ -67,7 +67,7 @@ int test_inverse()
float const Epsilon = 0.0001f; float const Epsilon = 0.0001f;
glm::dualquat dqid; glm::dualquat dqid = glm::dual_quat_identity<float, glm::defaultp>();
glm::mat4x4 mid(1.0f); glm::mat4x4 mid(1.0f);
for (int j = 0; j < 100; ++j) for (int j = 0; j < 100; ++j)