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
This commit is contained in:
Philipp Oeser 2019-04-23 13:13:11 +02:00
parent b4c14faeaf
commit 56b0cd1db6
Notes: blender-bot 2023-02-14 03:52:45 +01:00
Referenced by commit 11b994e26e, Fix T67671: Blender crashes when resizing sidebar with a colorbamp
Referenced by issue #63605, Assert error squeezing a template_curve_mapping in a panel to almost zero horizontally
2 changed files with 14 additions and 9 deletions

View File

@ -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 */

View File

@ -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, "");