Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-08-25 05:45:43 +0300
committerCampbell Barton <campbell@blender.org>2022-08-25 06:48:31 +0300
commita7650c6206908a8865d6140a310809ec5ab0c770 (patch)
tree63137fb4cb772daafe5683a86b5496361e83deae /source/blender/editors/space_view3d/view3d_view.c
parent8593228a13d38057a5d849f46d5cc0ab23fb1405 (diff)
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.
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_view.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 05922ba7a95..b8042a9f215 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -369,11 +369,7 @@ static void obmat_to_viewmat(RegionView3D *rv3d, Object *ob)
invert_m4_m4(rv3d->viewmat, bmat);
/* view quat calculation, needed for add object */
- copy_m4_m4(bmat, rv3d->viewmat);
- if (is_negative_m4(bmat)) {
- negate_m4(bmat);
- }
- mat4_normalized_to_quat(rv3d->viewquat, bmat);
+ mat4_normalized_to_quat(rv3d->viewquat, rv3d->viewmat);
}
void view3d_viewmatrix_set(Depsgraph *depsgraph,