Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Oeser <info@graphics-engineer.com>2019-04-23 14:13:11 +0300
committerPhilipp Oeser <info@graphics-engineer.com>2019-04-25 22:59:05 +0300
commit56b0cd1db636e94bd8eb928b53816ebf6a951cdf (patch)
treefaa467507a4de084d757b43a073cfbeedd50e9fa /source/blender/editors/interface/interface_draw.c
parentb4c14faeaf6fb4e6a7b95a1eea1fa18fa94d03e2 (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/editors/interface/interface_draw.c')
-rw-r--r--source/blender/editors/interface/interface_draw.c21
1 files changed, 13 insertions, 8 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 */