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:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user