Browse Source

Can't see values for vec or mat in the debugger #665

Groove 7 years ago
parent
commit
147d56d90c

+ 16 - 2
glm/detail/setup.hpp

@@ -445,9 +445,9 @@
 #define GLM_SWIZZLE_OPERATOR 1
 #define GLM_SWIZZLE_OPERATOR 1
 #define GLM_SWIZZLE_FUNCTION 2
 #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
 #	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
 #	define GLM_SWIZZLE GLM_SWIZZLE_FUNCTION
 #else
 #else
 #	define GLM_SWIZZLE GLM_DISABLE
 #	define GLM_SWIZZLE GLM_DISABLE
@@ -600,6 +600,15 @@ namespace glm
 #define GLM_USE_SIMD GLM_DISABLE
 #define GLM_USE_SIMD GLM_DISABLE
 #endif
 #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
 // Configure the use of anonymous structure as implementation detail
 
 
@@ -787,6 +796,11 @@ namespace glm
 #		pragma message("GLM: platform unknown")
 #		pragma message("GLM: platform unknown")
 #	else
 #	else
 #		pragma message("GLM: platform not detected")
 #		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
 #	endif
 
 
 	// Report swizzle operator support
 	// Report swizzle operator support

+ 3 - 1
glm/detail/type_vec2.hpp

@@ -24,7 +24,9 @@ namespace glm
 
 
 		// -- Data --
 		// -- Data --
 
 
-#		if GLM_USE_ANONYMOUS_STRUCT == GLM_ENABLE
+#		if GLM_USE_XYZW_ONLY
+			T x, y;
+#		elif GLM_USE_ANONYMOUS_STRUCT == GLM_ENABLE
 			union
 			union
 			{
 			{
 				struct{ T x, y; };
 				struct{ T x, y; };

+ 3 - 1
glm/detail/type_vec3.hpp

@@ -24,7 +24,9 @@ namespace glm
 
 
 		// -- Data --
 		// -- 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
 			union
 			{
 			{
 				struct{ T x, y, z; };
 				struct{ T x, y, z; };

+ 3 - 1
glm/detail/type_vec4.hpp

@@ -24,7 +24,9 @@ namespace glm
 
 
 		// -- Data --
 		// -- 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
 			union
 			{
 			{
 				struct { T x, y, z, w; };
 				struct { T x, y, z, w; };

+ 3 - 1
glm/ext/vec1.hpp

@@ -41,7 +41,9 @@ namespace glm
 
 
 		// -- Data --
 		// -- Data --
 
 
-#		if GLM_USE_ANONYMOUS_STRUCT == GLM_ENABLE
+#		if GLM_USE_XYZW_ONLY
+			T x;
+#		elif GLM_USE_ANONYMOUS_STRUCT == GLM_ENABLE
 			union
 			union
 			{
 			{
 				T x;
 				T x;

+ 1 - 1
glm/simd/platform.h

@@ -252,7 +252,7 @@
 #define GLM_ARCH_MIPS		(GLM_ARCH_MIPS_BIT)
 #define GLM_ARCH_MIPS		(GLM_ARCH_MIPS_BIT)
 #define GLM_ARCH_PPC		(GLM_ARCH_PPC_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__)
 #	if defined(__x86_64__) || defined(_M_X64) || defined(_M_IX86) || defined(__i386__)
 #		define GLM_ARCH (GLM_ARCH_X86)
 #		define GLM_ARCH (GLM_ARCH_X86)
 #	elif defined(__arm__ ) || defined(_M_ARM)
 #	elif defined(__arm__ ) || defined(_M_ARM)

+ 1 - 0
test/core/CMakeLists.txt

@@ -6,6 +6,7 @@ glmCreateTestGTC(core_force_explicit_ctor)
 glmCreateTestGTC(core_force_inline)
 glmCreateTestGTC(core_force_inline)
 glmCreateTestGTC(core_force_pure)
 glmCreateTestGTC(core_force_pure)
 glmCreateTestGTC(core_force_unrestricted_gentype)
 glmCreateTestGTC(core_force_unrestricted_gentype)
+glmCreateTestGTC(core_force_xyzw_only)
 glmCreateTestGTC(core_type_aligned)
 glmCreateTestGTC(core_type_aligned)
 glmCreateTestGTC(core_type_cast)
 glmCreateTestGTC(core_type_cast)
 glmCreateTestGTC(core_type_ctor)
 glmCreateTestGTC(core_type_ctor)

+ 49 - 0
test/core/core_force_xyzw_only.cpp

@@ -0,0 +1,49 @@
+#define GLM_FORCE_XYZW_ONLY
+
+#include <glm/ext/vec1.hpp>
+#include <glm/vec2.hpp>
+#include <glm/vec3.hpp>
+#include <glm/vec4.hpp>
+
+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;
+}
+