Merge branch 'blender-v3.3-release'

This commit is contained in:
Campbell Barton 2022-08-24 16:09:13 +10:00
commit f39c9d1596
1 changed files with 9 additions and 3 deletions

View File

@ -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);
}