diff options
author | Campbell Barton <campbell@blender.org> | 2022-08-25 05:38:04 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-08-25 05:38:04 +0300 |
commit | 9f1c05d5cbaaebcd6254d99cd59a78d3a2f99a04 (patch) | |
tree | 70d541b32ae540b8124a97956ca3552eaf192a95 /source | |
parent | a604ed0068a0e23c133f3aad5cf0d697336192c1 (diff) |
Fix matrix/quaternion conversion with negative scaled cameras
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_utils.c | 11 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_view.c | 6 |
2 files changed, 12 insertions, 5 deletions
diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c index cb716391fb2..5154c2d4f52 100644 --- a/source/blender/editors/space_view3d/view3d_utils.c +++ b/source/blender/editors/space_view3d/view3d_utils.c @@ -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]); } + 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); } - - if (ofs && dist) { - madd_v3_v3fl(ofs, nmat[2], *dist); - } } void ED_view3d_to_m4(float mat[4][4], const float ofs[3], const float quat[4], const float dist) diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index b8042a9f215..05922ba7a95 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -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, |