[Bf-blender-cvs] [dcb37959d46] master: Fix roation snap failing with zero angle
Germano Cavalcante
noreply at git.blender.org
Tue Jan 17 21:22:02 CET 2023
Commit: dcb37959d467cdf3d24e7e1d7ebec7c1a5e92925
Author: Germano Cavalcante
Date: Tue Jan 17 17:21:39 2023 -0300
Branches: master
https://developer.blender.org/rBdcb37959d467cdf3d24e7e1d7ebec7c1a5e92925
Fix roation snap failing with zero angle
Due to precision issues, the cosine value calculated with
`dot_v3v3(start, end)` can be outside the -1, 1 range causing `acosf`
to return `nan(ind)`.
Use `angle_signed_on_axis_v3v3_v3` instead. It returns more accurate
values, deduplicates code, and avoids these `nan` issues.
===================================================================
M source/blender/editors/transform/transform_mode_rotate.c
===================================================================
diff --git a/source/blender/editors/transform/transform_mode_rotate.c b/source/blender/editors/transform/transform_mode_rotate.c
index 0a49fdefd83..713902f6c62 100644
--- a/source/blender/editors/transform/transform_mode_rotate.c
+++ b/source/blender/editors/transform/transform_mode_rotate.c
@@ -171,27 +171,11 @@ static float RotationBetween(TransInfo *t, const float p1[3], const float p2[3])
/* Angle around a constraint axis (error prone, will need debug). */
if (t->con.applyRot != NULL && (t->con.mode & CON_APPLY)) {
- float axis[3], tmp[3];
+ float axis[3];
t->con.applyRot(t, NULL, NULL, axis, NULL);
- project_v3_v3v3(tmp, end, axis);
- sub_v3_v3v3(end, end, tmp);
-
- project_v3_v3v3(tmp, start, axis);
- sub_v3_v3v3(start, start, tmp);
-
- normalize_v3(end);
- normalize_v3(start);
-
- cross_v3_v3v3(tmp, start, end);
-
- if (dot_v3v3(tmp, axis) < 0.0f) {
- angle = -acosf(dot_v3v3(start, end));
- }
- else {
- angle = acosf(dot_v3v3(start, end));
- }
+ angle = -angle_signed_on_axis_v3v3_v3(start, end, axis);
}
else {
float mtx[3][3];
More information about the Bf-blender-cvs
mailing list