[Bf-blender-cvs] [56b0cd1db63] master: Fix T63605: Assert squeezing a template_curve_mapping in a panel to almost zero horizontally

Philipp Oeser noreply at git.blender.org
Thu Apr 25 22:05:43 CEST 2019


Commit: 56b0cd1db636e94bd8eb928b53816ebf6a951cdf
Author: Philipp Oeser
Date:   Tue Apr 23 13:13:11 2019 +0200
Branches: master
https://developer.blender.org/rB56b0cd1db636e94bd8eb928b53816ebf6a951cdf

Fix T63605: Assert squeezing a template_curve_mapping in a panel to
almost zero horizontally

Reviewers: brecht

Maniphest Tasks: T63605

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

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

M	source/blender/editors/interface/interface_draw.c
M	source/blender/editors/interface/interface_templates.c

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

diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 671a004f9fe..e29fcfb3b43 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -1804,12 +1804,12 @@ static void ui_draw_but_curve_grid(
                       1.0f);
 
   immBegin(GPU_PRIM_LINES, (int)line_count * 2);
-  while (fx < rect->xmax) {
+  while (fx <= rect->xmax) {
     immVertex2f(pos, fx, rect->ymin);
     immVertex2f(pos, fx, rect->ymax);
     fx += dx;
   }
-  while (fy < rect->ymax) {
+  while (fy <= rect->ymax) {
     immVertex2f(pos, rect->xmin, fy);
     immVertex2f(pos, rect->xmax, fy);
     fy += dy;
@@ -1849,6 +1849,17 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, const uiWidgetColors *wcol, cons
     cumap = (CurveMapping *)but->poin;
   }
 
+  /* calculate offset and zoom */
+  float zoomx = (BLI_rcti_size_x(rect) - 2.0f) / BLI_rctf_size_x(&cumap->curr);
+  float zoomy = (BLI_rcti_size_y(rect) - 2.0f) / BLI_rctf_size_y(&cumap->curr);
+  float offsx = cumap->curr.xmin - (1.0f / zoomx);
+  float offsy = cumap->curr.ymin - (1.0f / zoomy);
+
+  /* exit early if too narrow */
+  if (zoomx == 0.0f) {
+    return;
+  }
+
   CurveMap *cuma = &cumap->cm[cumap->cur];
 
   /* need scissor test, curve can draw outside of boundary */
@@ -1867,12 +1878,6 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, const uiWidgetColors *wcol, cons
               BLI_rcti_size_x(&scissor_new),
               BLI_rcti_size_y(&scissor_new));
 
-  /* calculate offset and zoom */
-  float zoomx = (BLI_rcti_size_x(rect) - 2.0f) / BLI_rctf_size_x(&cumap->curr);
-  float zoomy = (BLI_rcti_size_y(rect) - 2.0f) / BLI_rctf_size_y(&cumap->curr);
-  float offsx = cumap->curr.xmin - (1.0f / zoomx);
-  float offsy = cumap->curr.ymin - (1.0f / zoomy);
-
   /* Do this first to not mess imm context */
   if (but->a1 == UI_GRAD_H) {
     /* magic trigger for curve backgrounds */
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index bbff2c16636..52c1390a2fd 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -4282,7 +4282,7 @@ static void curvemap_buttons_layout(uiLayout *layout,
   UI_block_funcN_set(block, rna_update_cb, MEM_dupallocN(cb), NULL);
 
   /* curve itself */
-  size = uiLayoutGetWidth(layout);
+  size = max_ii(uiLayoutGetWidth(layout), UI_UNIT_X);
   row = uiLayoutRow(layout, false);
   uiDefBut(
       block, UI_BTYPE_CURVE, 0, "", 0, 0, size, 8.0f * UI_UNIT_X, cumap, 0.0f, 1.0f, bg, 0, "");



More information about the Bf-blender-cvs mailing list