Commit: e01b1eac8482862e691ff42cebe6ccf71eee0e88
Author: Mike Erwin
Date:   Thu Oct 6 19:13:49 2016 -0400
Branches: blender2.8
https://developer.blender.org/rBe01b1eac8482862e691ff42cebe6ccf71eee0e88

cleanup: C99,  const, blank lines

===================================================================

M       source/blender/editors/gpencil/drawgpencil.c

===================================================================

diff --git a/source/blender/editors/gpencil/drawgpencil.c 
b/source/blender/editors/gpencil/drawgpencil.c
index 6901e2c..a7e30cc7 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -146,20 +146,17 @@ static void gp_set_color_and_tpoint(const tGPspoint *pt, 
const float ink[4])
 }
 
 /* draw stroke defined in buffer (simple ogl lines/points for now, as dotted 
lines) */
-static void gp_draw_stroke_buffer(tGPspoint *points, int totpoints, short 
thickness,
+static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, 
short thickness,
                                   short dflag, short sflag, float ink[4])
 {
-       tGPspoint *pt;
-       int i;
-       
        /* error checking */
        if ((points == NULL) || (totpoints <= 0))
                return;
-       
+
        /* check if buffer can be drawn */
        if (dflag & (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_ONLYV2D))
                return;
-       
+
        if (totpoints == 1) {
                /* if drawing a single point, draw it larger */
                glPointSize((float)(thickness + 2) * points->pressure);
@@ -173,14 +170,15 @@ static void gp_draw_stroke_buffer(tGPspoint *points, int 
totpoints, short thickn
        }
        else {
                float oldpressure = points[0].pressure;
-               
+
                /* draw stroke curve */
                if (G.debug & G_DEBUG) setlinestyle(2);
-               
+
                glLineWidth(max_ff(oldpressure * thickness, 1.0));
                glBegin(GL_LINE_STRIP);
-               
-               for (i = 0, pt = points; i < totpoints && pt; i++, pt++) {
+
+               const tGPspoint *pt = points;
+               for (int i = 0; i < totpoints; i++, pt++) {
                        /* if there was a significant pressure change, stop the 
curve, change the thickness of the stroke,
                         * and continue drawing again (since line-width cannot 
change in middle of GL_LINE_STRIP)
                         */
@@ -188,15 +186,15 @@ static void gp_draw_stroke_buffer(tGPspoint *points, int 
totpoints, short thickn
                                glEnd();
                                glLineWidth(max_ff(pt->pressure * thickness, 
1.0f));
                                glBegin(GL_LINE_STRIP);
-                               
+
                                /* need to roll-back one point to ensure that 
there are no gaps in the stroke */
                                if (i != 0) { 
                                        gp_set_color_and_tpoint((pt - 1), ink);
                                }
-                               
+
                                /* now the point we want... */
                                gp_set_color_and_tpoint(pt, ink);
-                               
+
                                oldpressure = pt->pressure;
                        }
                        else {
@@ -211,7 +209,7 @@ static void gp_draw_stroke_buffer(tGPspoint *points, int 
totpoints, short thickn
 
 /* --------- 2D Stroke Drawing Helpers --------- */
 /* change in parameter list */
-static void gp_calc_2d_stroke_fxy(float pt[3], short sflag, int offsx, int 
offsy, int winx, int winy, float r_co[2])
+static void gp_calc_2d_stroke_fxy(const float pt[3], short sflag, int offsx, 
int offsy, int winx, int winy, float r_co[2])
 {
        if (sflag & GP_STROKE_2DSPACE) {
                r_co[0] = pt[0];
@@ -237,8 +235,8 @@ static void gp_calc_2d_stroke_fxy(float pt[3], short sflag, 
int offsx, int offsy
 /* draw a 2D buffer stroke in "volumetric" style
  * NOTE: the stroke buffer doesn't have any coordinate offsets/transforms
  */
-static void gp_draw_stroke_volumetric_buffer(tGPspoint *points, int totpoints, 
short thickness,
-                                             short dflag, float ink[4])
+static void gp_draw_stroke_volumetric_buffer(const tGPspoint *points, int 
totpoints, short thickness,
+                                             short dflag, const float ink[4])
 {
        /* error checking */
        if ((points == NULL) || (totpoints <= 0))
@@ -257,7 +255,7 @@ static void gp_draw_stroke_volumetric_buffer(tGPspoint 
*points, int totpoints, s
        GPU_enable_program_point_size();
        immBegin(GL_POINTS, totpoints);
 
-       tGPspoint *pt = points;
+       const tGPspoint *pt = points;
        for (int i = 0; i < totpoints; i++, pt++) {
                gp_set_tpoint_varying_color(pt, ink, color);
                immAttrib1f(size, pt->pressure * thickness); /* TODO: scale 
based on view transform (zoom level) */
@@ -270,10 +268,10 @@ static void gp_draw_stroke_volumetric_buffer(tGPspoint 
*points, int totpoints, s
 }
 
 /* draw a 2D strokes in "volumetric" style */
-static void gp_draw_stroke_volumetric_2d(bGPDspoint *points, int totpoints, 
short thickness,
+static void gp_draw_stroke_volumetric_2d(const bGPDspoint *points, int 
totpoints, short thickness,
                                          short dflag, short sflag,
                                          int offsx, int offsy, int winx, int 
winy,
-                                         float diff_mat[4][4], float ink[4])
+                                         const float diff_mat[4][4], const 
float ink[4])
 {
        VertexFormat *format = immVertexFormat();
        unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
@@ -284,7 +282,7 @@ static void gp_draw_stroke_volumetric_2d(bGPDspoint 
*points, int totpoints, shor
        GPU_enable_program_point_size();
        immBegin(GL_POINTS, totpoints);
 
-       bGPDspoint *pt = points;
+       const bGPDspoint *pt = points;
        for (int i = 0; i < totpoints; i++, pt++) {
                /* transform position to 2D */
                float co[2];
@@ -305,8 +303,8 @@ static void gp_draw_stroke_volumetric_2d(bGPDspoint 
*points, int totpoints, shor
 
 /* draw a 3D stroke in "volumetric" style */
 static void gp_draw_stroke_volumetric_3d(
-        bGPDspoint *points, int totpoints, short thickness,
-        float ink[4])
+        const bGPDspoint *points, int totpoints, short thickness,
+        const float ink[4])
 {
        VertexFormat *format = immVertexFormat();
        unsigned pos = add_attrib(format, "pos", GL_FLOAT, 3, KEEP_FLOAT);
@@ -317,7 +315,7 @@ static void gp_draw_stroke_volumetric_3d(
        GPU_enable_program_point_size();
        immBegin(GL_POINTS, totpoints);
 
-       bGPDspoint *pt = points;
+       const bGPDspoint *pt = points;
        for (int i = 0; i < totpoints && pt; i++, pt++) {
                gp_set_point_varying_color(pt, ink, color);             
                immAttrib1f(size, pt->pressure * thickness); /* TODO: scale 
based on view transform */
@@ -333,45 +331,45 @@ static void gp_draw_stroke_volumetric_3d(
 /* --------------- Stroke Fills ----------------- */
 
 /* Get points of stroke always flat to view not affected by camera view or 
view position */
-static void gp_stroke_2d_flat(bGPDspoint *points, int totpoints, 
float(*points2d)[2], int *r_direction)
+static void gp_stroke_2d_flat(const bGPDspoint *points, int totpoints, 
float(*points2d)[2], int *r_direction)
 {
-       bGPDspoint *pt0 = &points[0];
-       bGPDspoint *pt1 = &points[1];
-       bGPDspoint *pt3 = &points[(int)(totpoints * 0.75)];
-       
+       const bGPDspoint *pt0 = &points[0];
+       const bGPDspoint *pt1 = &points[1];
+       const bGPDspoint *pt3 = &points[(int)(totpoints * 0.75)];
+
        float locx[3];
        float locy[3];
        float loc3[3];
        float normal[3];
-       
+
        /* local X axis (p0 -> p1) */
        sub_v3_v3v3(locx, &pt1->x, &pt0->x);
-       
+
        /* point vector at 3/4 */
        sub_v3_v3v3(loc3, &pt3->x, &pt0->x);
-       
+
        /* vector orthogonal to polygon plane */
        cross_v3_v3v3(normal, locx, loc3);
-       
+
        /* local Y axis (cross to normal/x axis) */
        cross_v3_v3v3(locy, normal, locx);
-       
+
        /* Normalize vectors */
        normalize_v3(locx);
        normalize_v3(locy);
-       
+
        /* Get all points in local space */
        for (int i = 0; i < totpoints; i++) {
-               bGPDspoint *pt = &points[i];
+               const bGPDspoint *pt = &points[i];
                float loc[3];
-               
+
                /* Get local space using first point as origin */
                sub_v3_v3v3(loc, &pt->x, &pt0->x);
-               
+
                points2d[i][0] = dot_v3v3(loc, locx);
                points2d[i][1] = dot_v3v3(loc, locy);
        }
-       
+
        /* Concave (-1), Convex (1), or Autodetect (0)? */
        *r_direction = (int)locy[2];
 }
@@ -381,14 +379,14 @@ 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);
-       
+
        /* allocate memory for temporary areas */
        gps->tot_triangles = gps->totpoints - 2;
        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;
-       
+
        /* 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);
@@ -403,7 +401,7 @@ static void gp_triangulate_stroke_fill(bGPDstroke *gps)
                else {
                        gps->triangles = MEM_recallocN(gps->triangles, 
sizeof(*gps->triangles) * gps->tot_triangles);
                }
-               
+
                for (int i = 0; i < gps->tot_triangles; i++) {
                        bGPDtriangle *stroke_triangle = &gps->triangles[i];
                        stroke_triangle->v1 = tmp_triangles[i][0];
@@ -415,15 +413,15 @@ static void gp_triangulate_stroke_fill(bGPDstroke *gps)
                /* No triangles needed - Free anything allocated previously */
                if (gps->triangles)
                        MEM_freeN(gps->triangles);
-                       
+
                gps->triangles = NULL;
        }
-       
+
        /* disable recalculation flag */
        if (gps->flag & GP_STROKE_RECALC_CACHES) {
                gps->flag &= ~GP_STROKE_RECALC_CACHES;
        }
-       
+
        /* clear memory */
        if (tmp_triangles) MEM_freeN(tmp_triangles);
        if (points2d) MEM_freeN(points2d);
@@ -433,10 +431,9 @@ static void gp_triangulate_stroke_fill(bGPDstroke *gps)
 /* draw fills for shapes */
 static void gp_draw_stroke_fill(
         bGPdata *gpd, bGPDstroke *gps,
-        int offsx, int offsy, int winx, int winy, float diff_mat[4][4])
+        int offsx, int offsy, int winx, int winy, const float diff_mat[4][4])
 {
        bGPDpalettecolor *palcolor;
-       int i;
        float fpt[3];
 
        BLI_assert(gps->totpoints >= 3);
@@ -445,7 +442,7 @@ static void gp_draw_stroke_fill(
 
        /* Triangulation fill if high quality flag is enabled */
        if (palcolor->flag & PC_COLOR_HQ_FILL) {
-               bGPDtriangle *stroke_triangle;
+               bGPDtriangle *stroke_triangle = gps->triangles;
                bGPDspoint *pt;
 
                /* Calculate triangles cache for filling area (must be done 
only after changes) */
@@ -455,7 +452,7 @@ static void gp_draw_stroke_fill(
                /* Draw all triangles for filling the polygon (cache must be 
calculated before) */
                BLI_assert(gps->tot_triangles >= 1);
                glBegin(GL_TRIANGLES);
-               for (i = 0, stroke_triangle = gps->triangles; i < 
gps->tot_triangles; i++, stroke_triangle++) {
+               for (int i = 0; i < gps->tot_triangles; i++, stroke_triangle++) 
{
                        if (gps->flag & GP_STROKE_3DSPACE) {
                                /* vertex 1 */
                                pt = &gps->points[stroke

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to