diff options
Diffstat (limited to 'source/blender/python/mathutils/mathutils_Euler.c')
-rw-r--r-- | source/blender/python/mathutils/mathutils_Euler.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/source/blender/python/mathutils/mathutils_Euler.c b/source/blender/python/mathutils/mathutils_Euler.c index 5d8252d3c72..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, @@ -203,7 +212,7 @@ static PyObject *Euler_rotate_axis(EulerObject *self, PyObject *args) return NULL; } - if (!(ELEM3(axis, 'X', 'Y', 'Z'))) { + if (!(ELEM(axis, 'X', 'Y', 'Z'))) { PyErr_SetString(PyExc_ValueError, "Euler.rotate_axis(): " "expected axis to be 'X', 'Y' or 'Z'"); |