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:
authorPi Lanningham <Quantumplation>2021-01-05 00:10:21 +0300
committerHans Goudey <h.goudey@me.com>2021-01-05 00:13:08 +0300
commit5a498e6a7bfb28ed1bbea21cec31d323f4bed592 (patch)
treec50a6eea4b9d2acdb1534387b1b874c00be51b7a /source/blender/editors/interface
parent54ee4109143b6fdabf749d2fde183907469cfa3b (diff)
Fix T84183: Dark area in the bevel custom profile widget
If there was a control point at an extreme position when drawing a curve profile (in the bottom corner), the fill's trianglulation could fail, giving a misleading view of the curve. This is because the extra points added to create a closed shape were exactly on the border of the view. This commit adds a small margin to those points, so the triangulation doesn't fail because the line overlaps itself. Another possible solution is to use a different algorithm to fill the polygon, such as scanfill, which is used by curve objects. This seemed simpler, and seems to work fairly robustly. Differential Revision: https://developer.blender.org/D9989
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface_draw.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index d9571dc98bd..5bb6b0f21e7 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -2245,33 +2245,36 @@ void ui_draw_but_CURVEPROFILE(ARegion *region,
table_coords[i][0] = pts[i].x;
table_coords[i][1] = pts[i].y;
}
+ /* Using some extra margin (-1.0f) for the coordinates used to complete the polygon
+ * avoids the profile line crossing itself in some common situations, which can lead to
+ * incorrect triangulation. See T841183. */
if (add_left_tri && add_bottom_tri) {
/* Add left side, bottom left corner, and bottom side points. */
- table_coords[tot_points - 3][0] = profile->view_rect.xmin;
+ table_coords[tot_points - 3][0] = profile->view_rect.xmin - 1.0f;
table_coords[tot_points - 3][1] = 1.0f;
- table_coords[tot_points - 2][0] = profile->view_rect.xmin;
- table_coords[tot_points - 2][1] = profile->view_rect.ymin;
+ table_coords[tot_points - 2][0] = profile->view_rect.xmin - 1.0f;
+ table_coords[tot_points - 2][1] = profile->view_rect.ymin - 1.0f;
table_coords[tot_points - 1][0] = 1.0f;
- table_coords[tot_points - 1][1] = profile->view_rect.ymin;
+ table_coords[tot_points - 1][1] = profile->view_rect.ymin - 1.0f;
}
else if (add_left_tri) {
/* Add the left side and bottom left corner points. */
- table_coords[tot_points - 2][0] = profile->view_rect.xmin;
+ table_coords[tot_points - 2][0] = profile->view_rect.xmin - 1.0f;
table_coords[tot_points - 2][1] = 1.0f;
- table_coords[tot_points - 1][0] = profile->view_rect.xmin;
- table_coords[tot_points - 1][1] = 0.0f;
+ table_coords[tot_points - 1][0] = profile->view_rect.xmin - 1.0f;
+ table_coords[tot_points - 1][1] = -1.0f;
}
else if (add_bottom_tri) {
/* Add the bottom side and bottom left corner points. */
- table_coords[tot_points - 2][0] = 0.0f;
- table_coords[tot_points - 2][1] = profile->view_rect.ymin;
+ table_coords[tot_points - 2][0] = -1.0f;
+ table_coords[tot_points - 2][1] = profile->view_rect.ymin - 1.0f;
table_coords[tot_points - 1][0] = 1.0f;
- table_coords[tot_points - 1][1] = profile->view_rect.ymin;
+ table_coords[tot_points - 1][1] = profile->view_rect.ymin - 1.0f;
}
else {
/* Just add the bottom corner point. Side points would be redundant anyway. */
- table_coords[tot_points - 1][0] = 0.0f;
- table_coords[tot_points - 1][1] = 0.0f;
+ table_coords[tot_points - 1][0] = -1.0f;
+ table_coords[tot_points - 1][1] = -1.0f;
}
/* Calculate the table point indices of the triangles for the profile's fill. */
@@ -2427,7 +2430,6 @@ void ui_draw_but_CURVEPROFILE(ARegion *region,
immUniformColor3ubv((const uchar *)wcol->outline);
imm_draw_box_wire_2d(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
-
immUnbindProgram();
}