[Bf-blender-cvs] [a108532] master: Fix for mathutils.Euler on big endian systems

Campbell Barton noreply at git.blender.org
Thu Aug 7 18:12:09 CEST 2014


Commit: a108532eb93d96a2c8dea7e21533d953d0eee2c3
Author: Campbell Barton
Date:   Fri Aug 8 02:07:56 2014 +1000
Branches: master
https://developer.blender.org/rBa108532eb93d96a2c8dea7e21533d953d0eee2c3

Fix for mathutils.Euler on big endian systems

D719 from jrestemeier with edits

===================================================================

M	source/blender/python/mathutils/mathutils_Euler.c

===================================================================

diff --git a/source/blender/python/mathutils/mathutils_Euler.c b/source/blender/python/mathutils/mathutils_Euler.c
index 56ed4e1..f6d1249 100644
--- a/source/blender/python/mathutils/mathutils_Euler.c
+++ b/source/blender/python/mathutils/mathutils_Euler.c
@@ -83,14 +83,23 @@ static const char *euler_order_str(EulerObject *self)
 short euler_order_from_string(const char *str, const char *error_prefix)
 {
 	if ((str[0] && str[1] && str[2] && str[3] == '\0')) {
+
+#ifdef __LITTLE_ENDIAN__
+#  define MAKE_ID3(a, b, c)  (((a)) | ((b) << 8) | ((c) << 16))
+#else
+#  define MAKE_ID3(a, b, c)  (((a) << 24) | ((b) << 16) | ((c) << 8))
+#endif
+
 		switch (*((PY_INT32_T *)str)) {
-			case 'X' | 'Y' << 8 | 'Z' << 16:    return EULER_ORDER_XYZ;
-			case 'X' | 'Z' << 8 | 'Y' << 16:    return EULER_ORDER_XZY;
-			case 'Y' | 'X' << 8 | 'Z' << 16:    return EULER_ORDER_YXZ;
-			case 'Y' | 'Z' << 8 | 'X' << 16:    return EULER_ORDER_YZX;
-			case 'Z' | 'X' << 8 | 'Y' << 16:    return EULER_ORDER_ZXY;
-			case 'Z' | 'Y' << 8 | 'X' << 16:    return EULER_ORDER_ZYX;
+			case MAKE_ID3('X', 'Y', 'Z'): return EULER_ORDER_XYZ;
+			case MAKE_ID3('X', 'Z', 'Y'): return EULER_ORDER_XZY;
+			case MAKE_ID3('Y', 'X', 'Z'): return EULER_ORDER_YXZ;
+			case MAKE_ID3('Y', 'Z', 'X'): return EULER_ORDER_YZX;
+			case MAKE_ID3('Z', 'X', 'Y'): return EULER_ORDER_ZXY;
+			case MAKE_ID3('Z', 'Y', 'X'): return EULER_ORDER_ZYX;
 		}
+
+#undef MAKE_ID3
 	}
 
 	PyErr_Format(PyExc_ValueError,




More information about the Bf-blender-cvs mailing list