diff options
author | Philipp Oeser <info@graphics-engineer.com> | 2019-04-23 14:13:11 +0300 |
---|---|---|
committer | Philipp Oeser <info@graphics-engineer.com> | 2019-04-25 22:59:05 +0300 |
commit | 56b0cd1db636e94bd8eb928b53816ebf6a951cdf (patch) | |
tree | faa467507a4de084d757b43a073cfbeedd50e9fa /source/blender | |
parent | b4c14faeaf6fb4e6a7b95a1eea1fa18fa94d03e2 (diff) |
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
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/interface/interface_draw.c | 21 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 2 |
2 files changed, 14 insertions, 9 deletions
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, ""); |