diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-08-07 20:07:56 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-08-07 20:11:54 +0400 |
commit | a108532eb93d96a2c8dea7e21533d953d0eee2c3 (patch) | |
tree | 5f54fd209c07bb2a0ec54c6f2db9ed2058125334 /source/blender | |
parent | 29eb56728832e223e78bb51de4fc28ba0523e642 (diff) |
Fix for mathutils.Euler on big endian systems
D719 from jrestemeier with edits
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/python/mathutils/mathutils_Euler.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/source/blender/python/mathutils/mathutils_Euler.c b/source/blender/python/mathutils/mathutils_Euler.c index 56ed4e157d6..f6d124938a4 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, |