Commit: 6c8db7c22ba48c49df0de0ab655b79342d866281
Author: Chris Blackbourn
Date:   Fri Jan 27 17:05:15 2023 +1300
Branches: master
https://developer.blender.org/rB6c8db7c22ba48c49df0de0ab655b79342d866281

Fix T103868: render uv transform gizmo even if it has zero area

Change the 2D Gizmo drawing function to provide a usable transform matrix,
if it would otherwise be degenerate.

Differential Revision: https://developer.blender.org/D17113

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

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

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

diff --git a/source/blender/editors/transform/transform_gizmo_2d.c 
b/source/blender/editors/transform/transform_gizmo_2d.c
index a6eb25975e9..b99a650c3c0 100644
--- a/source/blender/editors/transform/transform_gizmo_2d.c
+++ b/source/blender/editors/transform/transform_gizmo_2d.c
@@ -604,8 +604,11 @@ static void gizmo2d_xform_draw_prepare(const bContext *C, 
wmGizmoGroup *gzgroup)
   UI_view2d_view_to_region_m4(&region->v2d, ggd->cage->matrix_space);
   /* Define the bounding box of the gizmo in the offset transform matrix. */
   unit_m4(ggd->cage->matrix_offset);
-  ggd->cage->matrix_offset[0][0] = (ggd->max[0] - ggd->min[0]);
-  ggd->cage->matrix_offset[1][1] = (ggd->max[1] - ggd->min[1]);
+  const float min_gizmo_pixel_size = 0.001f; /* Draw Gizmo larger than this 
many pixels. */
+  const float min_scale_axis_x = min_gizmo_pixel_size / 
ggd->cage->matrix_space[0][0];
+  const float min_scale_axis_y = min_gizmo_pixel_size / 
ggd->cage->matrix_space[1][1];
+  ggd->cage->matrix_offset[0][0] = max_ff(min_scale_axis_x, ggd->max[0] - 
ggd->min[0]);
+  ggd->cage->matrix_offset[1][1] = max_ff(min_scale_axis_y, ggd->max[1] - 
ggd->min[1]);
 
   ScrArea *area = CTX_wm_area(C);

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to