diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-11-26 09:10:53 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-11-26 09:10:53 +0400 |
commit | 8ab167d33d396a005ab301e7fda04dd55c1aae15 (patch) | |
tree | 33c4a2bc2c73fe3668214fa0f6e3b1a19f8b8e30 /source/blender/editors/gpencil | |
parent | 6736576f6d576f9a06db14a76193c0c237e5cba1 (diff) |
pass args as vectors to opengl functions where possible.
Diffstat (limited to 'source/blender/editors/gpencil')
-rw-r--r-- | source/blender/editors/gpencil/drawgpencil.c | 33 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_paint.c | 19 |
2 files changed, 21 insertions, 31 deletions
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index def6cd61370..d40831f9e87 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -107,7 +107,7 @@ static void gp_draw_stroke_buffer (tGPspoint *points, int totpoints, short thick if (totpoints == 1) { /* draw point */ glBegin(GL_POINTS); - glVertex2f(points->x, points->y); + glVertex2iv(&points->x); glEnd(); } else if (sflag & GP_STROKE_ERASER) { @@ -132,18 +132,15 @@ static void gp_draw_stroke_buffer (tGPspoint *points, int totpoints, short thick glBegin(GL_LINE_STRIP); /* need to roll-back one point to ensure that there are no gaps in the stroke */ - if (i != 0) { - pt--; - glVertex2f(pt->x, pt->y); - pt++; - } + if (i != 0) glVertex2iv(&(pt - 1)->x); + /* now the point we want... */ - glVertex2f(pt->x, pt->y); + glVertex2iv(&pt->x); oldpressure = pt->pressure; } else - glVertex2f(pt->x, pt->y); + glVertex2iv(&pt->x); } glEnd(); @@ -162,7 +159,7 @@ static void gp_draw_stroke_point (bGPDspoint *points, short thickness, short dfl /* draw point */ if (sflag & GP_STROKE_3DSPACE) { glBegin(GL_POINTS); - glVertex3f(points->x, points->y, points->z); + glVertex3fv(&points->x); glEnd(); } else { @@ -228,18 +225,16 @@ static void gp_draw_stroke_3d (bGPDspoint *points, int totpoints, short thicknes glBegin(GL_LINE_STRIP); /* need to roll-back one point to ensure that there are no gaps in the stroke */ - if (i != 0) { - pt--; - glVertex3f(pt->x, pt->y, pt->z); - pt++; - } + if (i != 0) glVertex3fv(&(pt - 1)->x); + /* now the point we want... */ - glVertex3f(pt->x, pt->y, pt->z); + glVertex3fv(&pt->x); oldpressure = pt->pressure; } - else - glVertex3f(pt->x, pt->y, pt->z); + else { + glVertex3fv(&pt->x); + } } glEnd(); @@ -247,7 +242,7 @@ static void gp_draw_stroke_3d (bGPDspoint *points, int totpoints, short thicknes if (debug) { glBegin(GL_POINTS); for (i=0, pt=points; i < totpoints && pt; i++, pt++) - glVertex3f(pt->x, pt->y, pt->z); + glVertex3fv(&pt->x); glEnd(); } } @@ -461,7 +456,7 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s glBegin(GL_POINTS); for (i=0, pt=points; i < totpoints && pt; i++, pt++) { if (sflag & GP_STROKE_2DSPACE) { - glVertex2f(pt->x, pt->y); + glVertex2fv(&pt->x); } else if (sflag & GP_STROKE_2DIMAGE) { const float x= (float)((pt->x * winx) + offsx); diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index f09797bf6f1..6c93727bf55 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -331,8 +331,7 @@ static short gp_stroke_addpoint (tGPsdata *p, const int mval[2], float pressure) pt= (tGPspoint *)(gpd->sbuffer); /* store settings */ - pt->x= mval[0]; - pt->y= mval[1]; + copy_v2_v2_int(&pt->x, mval); pt->pressure= pressure; /* increment buffer size */ @@ -345,8 +344,7 @@ static short gp_stroke_addpoint (tGPsdata *p, const int mval[2], float pressure) pt= ((tGPspoint *)(gpd->sbuffer) + 1); /* store settings */ - pt->x= mval[0]; - pt->y= mval[1]; + copy_v2_v2_int(&pt->x, mval); pt->pressure= pressure; /* if this is just the second point we've added, increment the buffer size @@ -369,8 +367,7 @@ static short gp_stroke_addpoint (tGPsdata *p, const int mval[2], float pressure) pt= ((tGPspoint *)(gpd->sbuffer) + gpd->sbuffer_size); /* store settings */ - pt->x= mval[0]; - pt->y= mval[1]; + copy_v2_v2_int(&pt->x, mval); pt->pressure= pressure; /* increment counters */ @@ -387,8 +384,7 @@ static short gp_stroke_addpoint (tGPsdata *p, const int mval[2], float pressure) pt= (tGPspoint *)(gpd->sbuffer); /* store settings */ - pt->x= mval[0]; - pt->y= mval[1]; + copy_v2_v2_int(&pt->x, mval); pt->pressure= pressure; /* if there's stroke for this poly line session add (or replace last) point @@ -475,9 +471,8 @@ static void gp_stroke_smooth (tGPsdata *p) /* second pass: apply smoothed coordinates */ for (i=0, spc=smoothArray; i < gpd->sbuffer_size; i++, spc++) { tGPspoint *pc= (((tGPspoint *)gpd->sbuffer) + i); - - pc->x = spc->x; - pc->y = spc->y; + + copy_v2_v2_int(&pc->x, &spc->x); } /* free temp array */ @@ -653,7 +648,7 @@ static void gp_stroke_newfrombuffer (tGPsdata *p) depth_arr= MEM_mallocN(sizeof(float) * gpd->sbuffer_size, "depth_points"); for (i=0, ptc=gpd->sbuffer; i < gpd->sbuffer_size; i++, ptc++, pt++) { - mval[0]= ptc->x; mval[1]= ptc->y; + copy_v2_v2_int(mval, &ptc->x); if ((ED_view3d_autodist_depth(p->ar, mval, depth_margin, depth_arr+i) == 0) && (i && (ED_view3d_autodist_depth_seg(p->ar, mval, mval_prev, depth_margin + 1, depth_arr+i) == 0)) |