diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2016-05-07 14:40:59 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2016-05-08 15:53:51 +0300 |
commit | dc78e47b770b33645f3cda1a4750422cd5105d6b (patch) | |
tree | c8536a585128e8e077baa06b1e87219ea91b9436 /source/blender/editors/gpencil | |
parent | 011786a3f8d5102f410416f283e0dcd1da66557a (diff) |
Fix for D1705: Update to fix the bug with extra triangles that produces glitches in some situations
Diffstat (limited to 'source/blender/editors/gpencil')
-rw-r--r-- | source/blender/editors/gpencil/drawgpencil.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index a2ddbca9213..6ccbd2777b4 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -389,7 +389,7 @@ static void gp_triangulate_stroke_fill(bGPDstroke *gps) gp_stroke_2d_flat(gps->points, gps->totpoints, points2d, &direction); BLI_polyfill_calc((const float(*)[2])points2d, (unsigned int)gps->totpoints, direction, (unsigned int(*)[3])tmp_triangles); - /* count number of valid triangles */ + /* count number of valid triangles, slower but safer */ gps->tot_triangles = 0; for (int i = 0; i < gps->totpoints; i++) { if ((tmp_triangles[i][0] >= 0) && (tmp_triangles[i][0] < gps->totpoints) && @@ -399,6 +399,11 @@ static void gp_triangulate_stroke_fill(bGPDstroke *gps) gps->tot_triangles++; } } + + if (gps->tot_triangles > gps->totpoints - 2) { + /* avoid problems with extra (unwanted) triangles getting created */ + gps->tot_triangles = gps->totpoints - 2; + } //printf("tot triangles: %d / %d - direction = %d\n", gps->tot_triangles, gps->totpoints, direction); /* save triangulation data in stroke cache */ |