From c68d5325d0706305937372e42bd981197440de24 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 19 Feb 2013 04:37:28 +0000 Subject: fix for [#34283] wasn't working in my tests (attached to original report), made bone roll get compatible angle values with the original roll. --- source/blender/blenlib/BLI_math_rotation.h | 2 ++ source/blender/blenlib/intern/math_rotation.c | 6 ++++++ source/blender/editors/transform/transform_generics.c | 4 +++- 3 files changed, 11 insertions(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/blenlib/BLI_math_rotation.h b/source/blender/blenlib/BLI_math_rotation.h index e349a05ac23..5ba37d70ca5 100644 --- a/source/blender/blenlib/BLI_math_rotation.h +++ b/source/blender/blenlib/BLI_math_rotation.h @@ -186,6 +186,8 @@ float fov_to_focallength(float fov, float sensor); float angle_wrap_rad(float angle); float angle_wrap_deg(float angle); +float angle_compat_rad(float angle, float angle_compat); + int mat3_from_axis_conversion(int from_forward, int from_up, int to_forward, int to_up, float r_mat[3][3]); diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index c0ea817ae4a..26576b2dcb2 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -1740,6 +1740,12 @@ float angle_wrap_deg(float angle) return mod_inline(angle + 180.0f, 360.0f) - 180.0f; } +/* returns an angle compatible with angle_compat */ +float angle_compat_rad(float angle, float angle_compat) +{ + return angle + (floorf(((angle_compat - angle) / (float)M_PI) + 0.5f)) * (float)M_PI; +} + /* axis conversion */ static float _axis_convert_matrix[23][3][3] = { {{-1.0, 0.0, 0.0}, {0.0, -1.0, 0.0}, {0.0, 0.0, 1.0}}, diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 76ca9d8959a..aa32518b489 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -809,6 +809,7 @@ static void recalcData_view3d(TransInfo *t) if (td->extra) { float vec[3], up_axis[3]; float qrot[4]; + float roll; bool ztrans_hack = false; ebo = td->extra; @@ -842,7 +843,8 @@ static void recalcData_view3d(TransInfo *t) ztrans_hack = compare_v3v3(tdelta, ZAXIS_REF, 0.1f); } - ebo->roll = ED_rollBoneToVector(ebo, up_axis, ztrans_hack); + roll = ED_rollBoneToVector(ebo, up_axis, ztrans_hack); + ebo->roll = angle_compat_rad(roll, ebo->roll); } } } -- cgit v1.2.3