BLI_math: ensure non-negative matrices for mat3_to_quat calculations
Making the callers responsible for this isn't practical as matrices are often passed indirectly to a functions such as mat3_to_axis_angle, BKE_object_mat3_to_rot & BKE_pchan_mat3_to_rot. Or the matrix is combined from other matrices which could be negative. Given quaternions calculated from negative matrices are completely invalid and checking only needs to negate matrices with a negative determinant, move the check into mat3_to_quat and related functions. Add mat3_normalized_to_quat_fast for cases no error checking on the input matrix is needed such as blending rotations.
This commit is contained in:
@@ -454,8 +454,20 @@ void rescale_m4(float mat[4][4], const float scale[3]);
|
||||
*/
|
||||
void transform_pivot_set_m4(float mat[4][4], const float pivot[3]);
|
||||
|
||||
/**
|
||||
* \param rot: A 3x3 rotation matrix, normalized never negative.
|
||||
*/
|
||||
void mat4_to_rot(float rot[3][3], const float wmat[4][4]);
|
||||
|
||||
/**
|
||||
* \param rot: A 3x3 rotation matrix, normalized never negative.
|
||||
* \param size: The scale, negative if `mat3` is negative.
|
||||
*/
|
||||
void mat3_to_rot_size(float rot[3][3], float size[3], const float mat3[3][3]);
|
||||
/**
|
||||
* \param rot: A 3x3 rotation matrix, normalized never negative.
|
||||
* \param size: The scale, negative if `mat3` is negative.
|
||||
*/
|
||||
void mat4_to_loc_rot_size(float loc[3], float rot[3][3], float size[3], const float wmat[4][4]);
|
||||
void mat4_to_loc_quat(float loc[3], float quat[4], const float wmat[4][4]);
|
||||
void mat4_decompose(float loc[3], float quat[4], float size[3], const float wmat[4][4]);
|
||||
|
||||
Reference in New Issue
Block a user