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:
authorCampbell Barton <ideasman42@gmail.com>2016-05-09 16:46:36 +0300
committerCampbell Barton <ideasman42@gmail.com>2016-05-09 16:47:57 +0300
commit6172bdbde86642dbbfdc3c119de6eaf7db7e5993 (patch)
tree96460d3fb74e510ae14168b52972ea4effa7bf0a /source/blender/editors/gpencil/drawgpencil.c
parent8b13555b24ab159489b05ae9120d96dfbd7972a2 (diff)
Remove redundant error checks in grease-pencil tessellation
Diffstat (limited to 'source/blender/editors/gpencil/drawgpencil.c')
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index 7715169cafb..c364f89dc9f 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -378,9 +378,10 @@ static void gp_stroke_2d_flat(bGPDspoint *points, int totpoints, float(*points2d
static void gp_triangulate_stroke_fill(bGPDstroke *gps)
{
BLI_assert(gps->totpoints >= 3);
-
+ gps->tot_triangles = gps->totpoints - 2;
+
/* allocate memory for temporary areas */
- unsigned int (*tmp_triangles)[3] = MEM_mallocN(sizeof(*tmp_triangles) * gps->totpoints, "GP Stroke temp triangulation");
+ unsigned int (*tmp_triangles)[3] = MEM_mallocN(sizeof(*tmp_triangles) * gps->tot_triangles, "GP Stroke temp triangulation");
float (*points2d)[2] = MEM_mallocN(sizeof(*points2d) * gps->totpoints, "GP Stroke temp 2d points");
int direction = 0;
@@ -388,24 +389,7 @@ static void gp_triangulate_stroke_fill(bGPDstroke *gps)
/* convert to 2d and triangulate */
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, 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) &&
- (tmp_triangles[i][1] >= 0) && (tmp_triangles[i][1] < gps->totpoints) &&
- (tmp_triangles[i][2] >= 0) && (tmp_triangles[i][2] < gps->totpoints))
- {
- 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 */
if (gps->tot_triangles > 0) {
if (gps->triangles == NULL) {