From f2e47bfdce67918038b8a2f1d38971254fb3e00e Mon Sep 17 00:00:00 2001 From: Zuzu-Typ Date: Thu, 23 May 2019 10:14:33 +0200 Subject: [PATCH] fixed frexp and ldexp Should resolve #31 Also updated to latest glm version --- PyGLM.cpp | 32 +++++++--- glm/glm/common.hpp | 8 +-- glm/glm/detail/setup.hpp | 4 +- glm/glm/detail/type_quat.hpp | 4 +- glm/glm/detail/type_quat.inl | 4 +- glm/glm/ext/scalar_constants.inl | 2 +- glm/glm/simd/platform.h | 105 +++++++++++++++++-------------- setup.py | 2 +- 8 files changed, 93 insertions(+), 68 deletions(-) diff --git a/PyGLM.cpp b/PyGLM.cpp index 45dd52a..cf30e68 100644 --- a/PyGLM.cpp +++ b/PyGLM.cpp @@ -16127,22 +16127,29 @@ static PyObject* frexp_(PyObject* self, PyObject* args) { PyObject *arg1, *arg2; PyGLM_Arg_Unpack_2O(args, "frexp", arg1, arg2); - int i = 0; - glm::frexp(9.f,i); if (PyGLM_Vec2_Check(arg1) && PyObject_TypeCheck(arg2, &vec2Type)) { glm::vec2 o; unpack_vec2(arg1, &o); - return pack_vec2(glm::frexp(o, ((vec2*)arg2)->super_type)); + glm::ivec2 o2 = ((vec2*)arg2)->super_type; + PyObject* out = pack_vec2(glm::frexp(o, o2)); + ((vec2*)arg2)->super_type = o2; + return out; } if (PyGLM_Vec3_Check(arg1) && PyObject_TypeCheck(arg2, &vec3Type)) { glm::vec3 o; unpack_vec3(arg1, &o); - return pack_vec3(glm::frexp(o, ((vec3*)arg2)->super_type)); + glm::ivec3 o2 = ((vec3*)arg2)->super_type; + PyObject* out = pack_vec2(glm::frexp(o, o2)); + ((vec3*)arg2)->super_type = o2; + return out; } if (PyGLM_Vec4_Check(arg1) && PyObject_TypeCheck(arg2, &vec4Type)) { glm::vec4 o; unpack_vec4(arg1, &o); - return pack_vec4(glm::frexp(o, ((vec4*)arg2)->super_type)); + glm::ivec4 o2 = ((vec4*)arg2)->super_type; + PyObject* out = pack_vec4(glm::frexp(o, o2)); + ((vec4*)arg2)->super_type = o2; + return out; } PyGLM_TYPEERROR_2O("invalid argument type(s) for frexp(): ", arg1, arg2); return NULL; @@ -16155,17 +16162,26 @@ ldexp_(PyObject* self, PyObject* args) { if (PyGLM_Vec2_Check(arg1) && PyObject_TypeCheck(arg2, &vec2Type)) { glm::vec2 o; unpack_vec2(arg1, &o); - return pack_vec2(glm::ldexp(o, ((vec2*)arg2)->super_type)); + glm::ivec2 o2 = ((vec2*)arg2)->super_type; + PyObject* out = pack_vec2(glm::ldexp(o, o2)); + ((vec2*)arg2)->super_type = o2; + return out; } if (PyGLM_Vec3_Check(arg1) && PyObject_TypeCheck(arg2, &vec3Type)) { glm::vec3 o; unpack_vec3(arg1, &o); - return pack_vec3(glm::ldexp(o, ((vec3*)arg2)->super_type)); + glm::ivec3 o2 = ((vec3*)arg2)->super_type; + PyObject* out = pack_vec3(glm::ldexp(o, o2)); + ((vec3*)arg2)->super_type = o2; + return out; } if (PyGLM_Vec4_Check(arg1) && PyObject_TypeCheck(arg2, &vec4Type)) { glm::vec4 o; unpack_vec4(arg1, &o); - return pack_vec4(glm::ldexp(o, ((vec4*)arg2)->super_type)); + glm::ivec4 o2 = ((vec4*)arg2)->super_type; + PyObject* out = pack_vec4(glm::ldexp(o, o2)); + ((vec4*)arg2)->super_type = o2; + return out; } PyGLM_TYPEERROR_2O("invalid argument type(s) for ldexp(): ", arg1, arg2); return NULL; diff --git a/glm/glm/common.hpp b/glm/glm/common.hpp index 1f923aa..0328dc9 100644 --- a/glm/glm/common.hpp +++ b/glm/glm/common.hpp @@ -509,8 +509,8 @@ namespace glm /// /// @see GLSL frexp man page /// @see GLSL 4.20.8 specification, section 8.3 Common Functions - template - GLM_FUNC_DECL genType frexp(genType const& x, genIType& exp); + template + GLM_FUNC_DECL genType frexp(genType x, int& exp); template GLM_FUNC_DECL vec frexp(vec const& v, vec& exp); @@ -526,8 +526,8 @@ namespace glm /// /// @see GLSL ldexp man page; /// @see GLSL 4.20.8 specification, section 8.3 Common Functions - template - GLM_FUNC_DECL genType ldexp(genType const& x, genIType const& exp); + template + GLM_FUNC_DECL genType ldexp(genType const& x, int const& exp); template GLM_FUNC_DECL vec ldexp(vec const& v, vec const& exp); diff --git a/glm/glm/detail/setup.hpp b/glm/glm/detail/setup.hpp index 2983e71..d59808e 100644 --- a/glm/glm/detail/setup.hpp +++ b/glm/glm/detail/setup.hpp @@ -7,8 +7,8 @@ #define GLM_VERSION_MINOR 9 #define GLM_VERSION_PATCH 9 #define GLM_VERSION_REVISION 4 -#define GLM_VERSION 995 -#define GLM_VERSION_MESSAGE "GLM: version 0.9.9.5" +#define GLM_VERSION 996 +#define GLM_VERSION_MESSAGE "GLM: version 0.9.9.6" #define GLM_SETUP_INCLUDED GLM_VERSION diff --git a/glm/glm/detail/type_quat.hpp b/glm/glm/detail/type_quat.hpp index b49c253..28eb41b 100644 --- a/glm/glm/detail/type_quat.hpp +++ b/glm/glm/detail/type_quat.hpp @@ -101,8 +101,8 @@ namespace glm /// Explicit conversion operators # if GLM_HAS_EXPLICIT_CONVERSION_OPERATORS - GLM_FUNC_DECL explicit operator mat<3, 3, T, Q>(); - GLM_FUNC_DECL explicit operator mat<4, 4, T, Q>(); + GLM_FUNC_DECL explicit operator mat<3, 3, T, Q>() const; + GLM_FUNC_DECL explicit operator mat<4, 4, T, Q>() const; # endif /// Create a quaternion from two normalized axis diff --git a/glm/glm/detail/type_quat.inl b/glm/glm/detail/type_quat.inl index d9f63c6..ac73af7 100644 --- a/glm/glm/detail/type_quat.inl +++ b/glm/glm/detail/type_quat.inl @@ -197,13 +197,13 @@ namespace detail # if GLM_HAS_EXPLICIT_CONVERSION_OPERATORS template - GLM_FUNC_QUALIFIER qua::operator mat<3, 3, T, Q>() + GLM_FUNC_QUALIFIER qua::operator mat<3, 3, T, Q>() const { return mat3_cast(*this); } template - GLM_FUNC_QUALIFIER qua::operator mat<4, 4, T, Q>() + GLM_FUNC_QUALIFIER qua::operator mat<4, 4, T, Q>() const { return mat4_cast(*this); } diff --git a/glm/glm/ext/scalar_constants.inl b/glm/glm/ext/scalar_constants.inl index c075fbc..f97c980 100644 --- a/glm/glm/ext/scalar_constants.inl +++ b/glm/glm/ext/scalar_constants.inl @@ -12,7 +12,7 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR genType pi() { - GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'epsilon' only accepts floating-point inputs"); + GLM_STATIC_ASSERT(std::numeric_limits::is_iec559, "'pi' only accepts floating-point inputs"); return static_cast(3.14159265358979323846264338327950288); } } //namespace glm diff --git a/glm/glm/simd/platform.h b/glm/glm/simd/platform.h index c7b6afd..f74b8c7 100644 --- a/glm/glm/simd/platform.h +++ b/glm/glm/simd/platform.h @@ -60,6 +60,9 @@ #define GLM_COMPILER_VC15_5 0x01000005 #define GLM_COMPILER_VC15_6 0x01000006 #define GLM_COMPILER_VC15_7 0x01000007 +#define GLM_COMPILER_VC15_8 0x01000008 +#define GLM_COMPILER_VC15_9 0x01000009 +#define GLM_COMPILER_VC16 0x0100000A // GCC defines #define GLM_COMPILER_GCC 0x02000000 @@ -99,16 +102,16 @@ # define GLM_COMPILER GLM_COMPILER_UNKNOWN #elif defined(__INTEL_COMPILER) -# if (__INTEL_COMPILER < 1400) -# error "GLM requires ICC 2013 SP1 or newer" -# elif __INTEL_COMPILER == 1400 -# define GLM_COMPILER GLM_COMPILER_INTEL14 -# elif __INTEL_COMPILER == 1500 -# define GLM_COMPILER GLM_COMPILER_INTEL15 -# elif __INTEL_COMPILER == 1600 -# define GLM_COMPILER GLM_COMPILER_INTEL16 -# elif __INTEL_COMPILER >= 1700 +# if __INTEL_COMPILER >= 1700 # define GLM_COMPILER GLM_COMPILER_INTEL17 +# elif __INTEL_COMPILER >= 1600 +# define GLM_COMPILER GLM_COMPILER_INTEL16 +# elif __INTEL_COMPILER >= 1500 +# define GLM_COMPILER GLM_COMPILER_INTEL15 +# elif __INTEL_COMPILER >= 1400 +# define GLM_COMPILER GLM_COMPILER_INTEL14 +# elif __INTEL_COMPILER < 1400 +# error "GLM requires ICC 2013 SP1 or newer" # endif // CUDA @@ -116,14 +119,14 @@ # if !defined(CUDA_VERSION) && !defined(GLM_FORCE_CUDA) # include // make sure version is defined since nvcc does not define it itself! # endif -# if CUDA_VERSION < 7000 -# error "GLM requires CUDA 7.0 or higher" -# elif (CUDA_VERSION >= 7000 && CUDA_VERSION < 7500) -# define GLM_COMPILER GLM_COMPILER_CUDA70 -# elif (CUDA_VERSION >= 7500 && CUDA_VERSION < 8000) -# define GLM_COMPILER GLM_COMPILER_CUDA75 -# elif (CUDA_VERSION >= 8000) +# if CUDA_VERSION >= 8000 # define GLM_COMPILER GLM_COMPILER_CUDA80 +# elif CUDA_VERSION >= 7500 +# define GLM_COMPILER GLM_COMPILER_CUDA75 +# elif CUDA_VERSION >= 7000 +# define GLM_COMPILER GLM_COMPILER_CUDA70 +# elif CUDA_VERSION < 7000 +# error "GLM requires CUDA 7.0 or higher" # endif // Clang @@ -166,44 +169,50 @@ // Visual C++ #elif defined(_MSC_VER) -# if _MSC_VER < 1800 -# error "GLM requires Visual C++ 12 - 2013 or higher" -# elif _MSC_VER == 1800 -# define GLM_COMPILER GLM_COMPILER_VC12 -# elif _MSC_VER == 1900 -# define GLM_COMPILER GLM_COMPILER_VC14 -# elif _MSC_VER == 1910 -# define GLM_COMPILER GLM_COMPILER_VC15 -# elif _MSC_VER == 1911 -# define GLM_COMPILER GLM_COMPILER_VC15_3 -# elif _MSC_VER == 1912 -# define GLM_COMPILER GLM_COMPILER_VC15_5 -# elif _MSC_VER == 1913 -# define GLM_COMPILER GLM_COMPILER_VC15_6 +# if _MSC_VER >= 1920 +# define GLM_COMPILER GLM_COMPILER_VC16 +# elif _MSC_VER >= 1916 +# define GLM_COMPILER GLM_COMPILER_VC15_9 +# elif _MSC_VER >= 1915 +# define GLM_COMPILER GLM_COMPILER_VC15_8 # elif _MSC_VER >= 1914 # define GLM_COMPILER GLM_COMPILER_VC15_7 +# elif _MSC_VER >= 1913 +# define GLM_COMPILER GLM_COMPILER_VC15_6 +# elif _MSC_VER >= 1912 +# define GLM_COMPILER GLM_COMPILER_VC15_5 +# elif _MSC_VER >= 1911 +# define GLM_COMPILER GLM_COMPILER_VC15_3 +# elif _MSC_VER >= 1910 +# define GLM_COMPILER GLM_COMPILER_VC15 +# elif _MSC_VER >= 1900 +# define GLM_COMPILER GLM_COMPILER_VC14 +# elif _MSC_VER >= 1800 +# define GLM_COMPILER GLM_COMPILER_VC12 +# elif _MSC_VER < 1800 +# error "GLM requires Visual C++ 12 - 2013 or higher" # endif//_MSC_VER // G++ #elif defined(__GNUC__) || defined(__MINGW32__) -# if ((__GNUC__ == 4) && (__GNUC_MINOR__ < 6)) || (__GNUC__ < 4) -# error "GLM requires GCC 4.7 or higher" -# elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 6) -# define GLM_COMPILER (GLM_COMPILER_GCC46) -# elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 7) -# define GLM_COMPILER (GLM_COMPILER_GCC47) -# elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) -# define GLM_COMPILER (GLM_COMPILER_GCC48) -# elif (__GNUC__ == 4) && (__GNUC_MINOR__ >= 9) -# define GLM_COMPILER (GLM_COMPILER_GCC49) -# elif (__GNUC__ == 5) -# define GLM_COMPILER (GLM_COMPILER_GCC5) -# elif (__GNUC__ == 6) -# define GLM_COMPILER (GLM_COMPILER_GCC6) -# elif (__GNUC__ == 7) -# define GLM_COMPILER (GLM_COMPILER_GCC7) -# elif (__GNUC__ >= 8) -# define GLM_COMPILER (GLM_COMPILER_GCC8) +# if __GNUC__ >= 8 +# define GLM_COMPILER GLM_COMPILER_GCC8 +# elif __GNUC__ >= 7 +# define GLM_COMPILER GLM_COMPILER_GCC7 +# elif __GNUC__ >= 6 +# define GLM_COMPILER GLM_COMPILER_GCC6 +# elif __GNUC__ >= 5 +# define GLM_COMPILER GLM_COMPILER_GCC5 +# elif __GNUC__ == 4 && __GNUC_MINOR__ >= 9 +# define GLM_COMPILER GLM_COMPILER_GCC49 +# elif __GNUC__ == 4 && __GNUC_MINOR__ >= 8 +# define GLM_COMPILER GLM_COMPILER_GCC48 +# elif __GNUC__ == 4 && __GNUC_MINOR__ >= 7 +# define GLM_COMPILER GLM_COMPILER_GCC47 +# elif __GNUC__ == 4 && __GNUC_MINOR__ >= 6 +# define GLM_COMPILER GLM_COMPILER_GCC46 +# elif ((__GNUC__ == 4) && (__GNUC_MINOR__ < 6)) || (__GNUC__ < 4) +# error "GLM requires GCC 4.6 or higher" # endif #else diff --git a/setup.py b/setup.py index 9fb7101..e18bcdd 100644 --- a/setup.py +++ b/setup.py @@ -35,7 +35,7 @@ # Versions should comply with PEP440. For a discussion on single-sourcing # the version across setup.py and the project code, see # https://packaging.python.org/en/latest/single_source_version.html - version='0.5.2b1', + version='0.5.3b1', description='OpenGL Mathematics library for Python', long_description=long_description,