diff options
author | Campbell Barton <campbell@blender.org> | 2022-08-24 09:09:13 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-08-24 09:09:13 +0300 |
commit | f39c9d1596f7e2efae2cac30e09dc87989485c6f (patch) | |
tree | b10fe00888015629b9498e5a4795420273a5192e /source/blender/python | |
parent | be81690b73ad1e1a54da43b38b791d7c866ec0e1 (diff) | |
parent | 10a4726a5b770a6c916c0ee444808d86c63802e2 (diff) |
Merge branch 'blender-v3.3-release'
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/mathutils/mathutils_Matrix.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 1e85ece124d..de42b11c70b 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -1243,13 +1243,19 @@ static PyObject *Matrix_to_quaternion(MatrixObject *self) "inappropriate matrix size - expects 3x3 or 4x4 matrix"); return NULL; } + float mat3[3][3]; if (self->row_num == 3) { - mat3_to_quat(quat, (float(*)[3])self->matrix); + copy_m3_m3(mat3, (const float(*)[3])self->matrix); } else { - mat4_to_quat(quat, (const float(*)[4])self->matrix); + copy_m3_m4(mat3, (const float(*)[4])self->matrix); } - + normalize_m3(mat3); + if (is_negative_m3(mat3)) { + /* Without this, the results are invalid, see: T94231. */ + negate_m3(mat3); + } + mat3_normalized_to_quat(quat, mat3); return Quaternion_CreatePyObject(quat, NULL); } |