[Bf-blender-cvs] [72ea37ae5fc] master: UI: align gizmo scale handles to both Y and Z axes

Campbell Barton noreply at git.blender.org
Sun Jun 5 15:43:21 CEST 2022


Commit: 72ea37ae5fca88aee03bf9354dd9329121bbe01f
Author: Campbell Barton
Date:   Sun Jun 5 23:39:21 2022 +1000
Branches: master
https://developer.blender.org/rB72ea37ae5fca88aee03bf9354dd9329121bbe01f

UI: align gizmo scale handles to both Y and Z axes

This resolves a minor inconsistency displaying the scale gizmo handles
since they're cubes it's noticeable when they're not axes aligned.

===================================================================

M	source/blender/editors/transform/transform_gizmo_3d.c

===================================================================

diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c
index 4499be66d5a..fa2e80b51db 100644
--- a/source/blender/editors/transform/transform_gizmo_3d.c
+++ b/source/blender/editors/transform/transform_gizmo_3d.c
@@ -1751,7 +1751,17 @@ static void gizmo_refresh_from_matrix(wmGizmoGroup *gzgroup,
 
         gizmo_line_range(ggd->twtype, axis_type, &start_co[2], &len);
 
-        WM_gizmo_set_matrix_rotation_from_z_axis(axis, twmat[aidx_norm]);
+        const float *z_axis = twmat[aidx_norm];
+        if (axis_type == MAN_AXES_SCALE) {
+          /* Scale handles are cubes that don't look right when not aligned with other axes.
+           * This is noticeable when the axis is rotated to something besides the global-axis. */
+          const int aidx_norm_y = (aidx_norm + 2) % 3;
+          const float *y_axis = twmat[aidx_norm_y];
+          WM_gizmo_set_matrix_rotation_from_yz_axis(axis, y_axis, z_axis);
+        }
+        else {
+          WM_gizmo_set_matrix_rotation_from_z_axis(axis, z_axis);
+        }
         RNA_float_set(axis->ptr, "length", len);
 
         if (axis_idx >= MAN_AXIS_RANGE_TRANS_START && axis_idx < MAN_AXIS_RANGE_TRANS_END) {



More information about the Bf-blender-cvs mailing list