From 147d56d90c582615161df1ec05762035508d8838 Mon Sep 17 00:00:00 2001 From: Groove Date: Sun, 29 Jul 2018 22:11:15 +0200 Subject: [PATCH] Can't see values for vec or mat in the debugger #665 --- glm/detail/setup.hpp | 18 +++++++++-- glm/detail/type_vec2.hpp | 4 ++- glm/detail/type_vec3.hpp | 4 ++- glm/detail/type_vec4.hpp | 4 ++- glm/ext/vec1.hpp | 4 ++- glm/simd/platform.h | 2 +- test/core/CMakeLists.txt | 1 + test/core/core_force_xyzw_only.cpp | 49 ++++++++++++++++++++++++++++++ 8 files changed, 79 insertions(+), 7 deletions(-) create mode 100644 test/core/core_force_xyzw_only.cpp diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index da130b63..8284db5e 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -445,9 +445,9 @@ #define GLM_SWIZZLE_OPERATOR 1 #define GLM_SWIZZLE_FUNCTION 2 -#if defined(GLM_FORCE_SWIZZLE) && (GLM_LANG & GLM_LANG_CXXMS_FLAG) +#if defined(GLM_FORCE_SWIZZLE) && !defined(GLM_FORCE_XYZW_ONLY) && (GLM_LANG & GLM_LANG_CXXMS_FLAG) # define GLM_SWIZZLE GLM_SWIZZLE_OPERATOR -#elif defined(GLM_FORCE_SWIZZLE) +#elif defined(GLM_FORCE_SWIZZLE) && !defined(GLM_FORCE_XYZW_ONLY) # define GLM_SWIZZLE GLM_SWIZZLE_FUNCTION #else # define GLM_SWIZZLE GLM_DISABLE @@ -600,6 +600,15 @@ namespace glm #define GLM_USE_SIMD GLM_DISABLE #endif +/////////////////////////////////////////////////////////////////////////////////// +// Only use x, y, z, w as vector type components + +#ifdef GLM_FORCE_XYZW_ONLY +# define GLM_USE_XYZW_ONLY GLM_ENABLE +#else +# define GLM_USE_XYZW_ONLY GLM_DISABLE +#endif + /////////////////////////////////////////////////////////////////////////////////// // Configure the use of anonymous structure as implementation detail @@ -787,6 +796,11 @@ namespace glm # pragma message("GLM: platform unknown") # else # pragma message("GLM: platform not detected") +# endif + + // Report whether only xyzw component are used +# if defined GLM_FORCE_XYZW_ONLY +# pragma message("GLM: GLM_FORCE_XYZW_ONLY is defined. Only x, y, z and w component are available in vector type. This define disables swizzle operators and SIMD instruction sets") # endif // Report swizzle operator support diff --git a/glm/detail/type_vec2.hpp b/glm/detail/type_vec2.hpp index be97e1fb..bbee1cb3 100644 --- a/glm/detail/type_vec2.hpp +++ b/glm/detail/type_vec2.hpp @@ -24,7 +24,9 @@ namespace glm // -- Data -- -# if GLM_USE_ANONYMOUS_STRUCT == GLM_ENABLE +# if GLM_USE_XYZW_ONLY + T x, y; +# elif GLM_USE_ANONYMOUS_STRUCT == GLM_ENABLE union { struct{ T x, y; }; diff --git a/glm/detail/type_vec3.hpp b/glm/detail/type_vec3.hpp index 22505ac5..553f2f7f 100644 --- a/glm/detail/type_vec3.hpp +++ b/glm/detail/type_vec3.hpp @@ -24,7 +24,9 @@ namespace glm // -- Data -- -# if GLM_USE_ANONYMOUS_STRUCT == GLM_ENABLE +# if GLM_USE_XYZW_ONLY + T x, y, z; +# elif GLM_USE_ANONYMOUS_STRUCT == GLM_ENABLE union { struct{ T x, y, z; }; diff --git a/glm/detail/type_vec4.hpp b/glm/detail/type_vec4.hpp index e6e70cdd..fee6a440 100644 --- a/glm/detail/type_vec4.hpp +++ b/glm/detail/type_vec4.hpp @@ -24,7 +24,9 @@ namespace glm // -- Data -- -# if GLM_USE_ANONYMOUS_STRUCT == GLM_ENABLE +# if GLM_USE_XYZW_ONLY + T x, y, z, w; +# elif GLM_USE_ANONYMOUS_STRUCT == GLM_ENABLE union { struct { T x, y, z, w; }; diff --git a/glm/ext/vec1.hpp b/glm/ext/vec1.hpp index e001faa2..5d3205bf 100644 --- a/glm/ext/vec1.hpp +++ b/glm/ext/vec1.hpp @@ -41,7 +41,9 @@ namespace glm // -- Data -- -# if GLM_USE_ANONYMOUS_STRUCT == GLM_ENABLE +# if GLM_USE_XYZW_ONLY + T x; +# elif GLM_USE_ANONYMOUS_STRUCT == GLM_ENABLE union { T x; diff --git a/glm/simd/platform.h b/glm/simd/platform.h index 7e57b2b6..577265bb 100644 --- a/glm/simd/platform.h +++ b/glm/simd/platform.h @@ -252,7 +252,7 @@ #define GLM_ARCH_MIPS (GLM_ARCH_MIPS_BIT) #define GLM_ARCH_PPC (GLM_ARCH_PPC_BIT) -#if defined(GLM_FORCE_PURE) +#if defined(GLM_FORCE_PURE) || defined(GLM_FORCE_XYZW_ONLY) # if defined(__x86_64__) || defined(_M_X64) || defined(_M_IX86) || defined(__i386__) # define GLM_ARCH (GLM_ARCH_X86) # elif defined(__arm__ ) || defined(_M_ARM) diff --git a/test/core/CMakeLists.txt b/test/core/CMakeLists.txt index 1990cff1..e7ca9bc7 100644 --- a/test/core/CMakeLists.txt +++ b/test/core/CMakeLists.txt @@ -6,6 +6,7 @@ glmCreateTestGTC(core_force_explicit_ctor) glmCreateTestGTC(core_force_inline) glmCreateTestGTC(core_force_pure) glmCreateTestGTC(core_force_unrestricted_gentype) +glmCreateTestGTC(core_force_xyzw_only) glmCreateTestGTC(core_type_aligned) glmCreateTestGTC(core_type_cast) glmCreateTestGTC(core_type_ctor) diff --git a/test/core/core_force_xyzw_only.cpp b/test/core/core_force_xyzw_only.cpp new file mode 100644 index 00000000..6d66ea96 --- /dev/null +++ b/test/core/core_force_xyzw_only.cpp @@ -0,0 +1,49 @@ +#define GLM_FORCE_XYZW_ONLY + +#include +#include +#include +#include + +int test_comp() +{ + int Error = 0; + + { + glm::ivec1 const A(1); + Error += A.x == 1 ? 0 : 1; + } + + { + glm::ivec2 const A(1, 2); + Error += A.x == 1 ? 0 : 1; + Error += A.y == 2 ? 0 : 1; + } + + { + glm::ivec3 const A(1, 2, 3); + Error += A.x == 1 ? 0 : 1; + Error += A.y == 2 ? 0 : 1; + Error += A.z == 3 ? 0 : 1; + } + + { + glm::ivec4 const A(1, 2, 3, 4); + Error += A.x == 1 ? 0 : 1; + Error += A.y == 2 ? 0 : 1; + Error += A.z == 3 ? 0 : 1; + Error += A.w == 4 ? 0 : 1; + } + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_comp(); + + return Error; +} +