Fix matrix/quaternion conversion with negative scaled cameras
This commit is contained in:
parent
a604ed0068
commit
9f1c05d5cb
|
@ -1485,15 +1485,18 @@ void ED_view3d_from_m4(const float mat[4][4], float ofs[3], float quat[4], const
|
|||
negate_v3_v3(ofs, mat[3]);
|
||||
}
|
||||
|
||||
/* Quat */
|
||||
if (quat) {
|
||||
mat3_normalized_to_quat(quat, nmat);
|
||||
invert_qt_normalized(quat);
|
||||
}
|
||||
|
||||
if (ofs && dist) {
|
||||
madd_v3_v3fl(ofs, nmat[2], *dist);
|
||||
}
|
||||
|
||||
/* Quat */
|
||||
if (quat) {
|
||||
if (is_negative_m3(nmat)) {
|
||||
negate_m3(nmat);
|
||||
}
|
||||
mat3_normalized_to_quat(quat, nmat);
|
||||
invert_qt_normalized(quat);
|
||||
}
|
||||
}
|
||||
|
||||
void ED_view3d_to_m4(float mat[4][4], const float ofs[3], const float quat[4], const float dist)
|
||||
|
|
|
@ -369,7 +369,11 @@ static void obmat_to_viewmat(RegionView3D *rv3d, Object *ob)
|
|||
invert_m4_m4(rv3d->viewmat, bmat);
|
||||
|
||||
/* view quat calculation, needed for add object */
|
||||
mat4_normalized_to_quat(rv3d->viewquat, rv3d->viewmat);
|
||||
copy_m4_m4(bmat, rv3d->viewmat);
|
||||
if (is_negative_m4(bmat)) {
|
||||
negate_m4(bmat);
|
||||
}
|
||||
mat4_normalized_to_quat(rv3d->viewquat, bmat);
|
||||
}
|
||||
|
||||
void view3d_viewmatrix_set(Depsgraph *depsgraph,
|
||||
|
|
Loading…
Reference in New Issue