[Bf-blender-cvs] [5a498e6a7bf] master: Fix T84183: Dark area in the bevel custom profile widget
Pi Lanningham
noreply at git.blender.org
Mon Jan 4 22:13:37 CET 2021
Commit: 5a498e6a7bfb28ed1bbea21cec31d323f4bed592
Author: Pi Lanningham
Date: Mon Jan 4 15:10:21 2021 -0600
Branches: master
https://developer.blender.org/rB5a498e6a7bfb28ed1bbea21cec31d323f4bed592
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
===================================================================
M source/blender/editors/interface/interface_draw.c
===================================================================
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();
}
More information about the Bf-blender-cvs
mailing list