BLI_math: assert mat3_normalized_to_quat doesn't use a negative matrix
Add an assert to ensure callers don't pass in negative matrices as the resulting quaternion is invalid.
This commit is contained in:
parent
489aeda034
commit
be0a68f0d1
|
@ -272,6 +272,10 @@ void quat_to_mat4(float m[4][4], const float q[4])
|
|||
void mat3_normalized_to_quat(float q[4], const float mat[3][3])
|
||||
{
|
||||
BLI_ASSERT_UNIT_M3(mat);
|
||||
/* Callers must ensure matrices have a positive determinant for valid results, see: T94231. */
|
||||
BLI_assert_msg(!is_negative_m3(mat),
|
||||
"Matrix 'mat' must not be negative, the resulting quaternion will be invalid. "
|
||||
"The caller should call negate_m3(mat) if is_negative_m3(mat) returns true.");
|
||||
|
||||
/* Check the trace of the matrix - bad precision if close to -1. */
|
||||
const float trace = mat[0][0] + mat[1][1] + mat[2][2];
|
||||
|
|
Loading…
Reference in New Issue