diff options
author | Joshua Leung <aligorith@gmail.com> | 2016-04-30 03:47:07 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2016-05-08 15:53:49 +0300 |
commit | b88535ed287aca6ea283b243f0d92eddb507afa9 (patch) | |
tree | 60c59dd859cd601499d11020b51718cad015d316 /source/blender/editors/gpencil/drawgpencil.c | |
parent | af8a54bd8dd40b9a9bdad60f6d58dc920dcd0b87 (diff) |
Code Cleanup: Just a bit more tidying up comments/whitespace/etc.
There is still some instability in how the triangulations are happening,
where the triangle count of the resulting triangulation fluctuates resulting
in weird artifacts sometimes.
To reproduce, try drawing some U-shapes, and keep reloading the file.
Diffstat (limited to 'source/blender/editors/gpencil/drawgpencil.c')
-rw-r--r-- | source/blender/editors/gpencil/drawgpencil.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 2ba9a79eff3..a2ddbca9213 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -341,7 +341,7 @@ static void gp_stroke_2d_flat(bGPDspoint *points, int totpoints, float(*points2d float loc3[3]; float normal[3]; - /* local X axis (p0-p1) */ + /* local X axis (p0 -> p1) */ sub_v3_v3v3(locx, &pt1->x, &pt0->x); /* point vector at 3/4 */ @@ -369,6 +369,7 @@ static void gp_stroke_2d_flat(bGPDspoint *points, int totpoints, float(*points2d points2d[i][1] = dot_v3v3(loc, locy); } + /* Concave (-1), Convex (1), or Autodetect (0)? */ *r_direction = (int)locy[2]; } @@ -382,7 +383,7 @@ static void gp_triangulate_stroke_fill(bGPDstroke *gps) unsigned int (*tmp_triangles)[3] = MEM_mallocN(sizeof(*tmp_triangles) * gps->totpoints, "GP Stroke temp triangulation"); float (*points2d)[2] = MEM_mallocN(sizeof(*points2d) * gps->totpoints, "GP Stroke temp 2d points"); - int direction; + int direction = 0; /* convert to 2d and triangulate */ gp_stroke_2d_flat(gps->points, gps->totpoints, points2d, &direction); @@ -392,20 +393,21 @@ static void gp_triangulate_stroke_fill(bGPDstroke *gps) 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)) + (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++; } } + //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) { - gps->triangles = MEM_callocN(sizeof(bGPDtriangle) * gps->tot_triangles, "GP Stroke triangulation"); + gps->triangles = MEM_callocN(sizeof(*gps->triangles) * gps->tot_triangles, "GP Stroke triangulation"); } else { - gps->triangles = MEM_recallocN(gps->triangles, sizeof(bGPDtriangle) * gps->tot_triangles); + gps->triangles = MEM_recallocN(gps->triangles, sizeof(*gps->triangles) * gps->tot_triangles); } int triangle_index = 0; |