[Bf-blender-cvs] [b2c97c978ca] greasepencil-object: Cleanup: Replace duplicate lines by helper function
Antonio Vazquez
noreply at git.blender.org
Sat Apr 22 19:04:32 CEST 2017
Commit: b2c97c978cad5bd336b539bf4333a020838ae9e5
Author: Antonio Vazquez
Date: Sat Apr 22 18:15:46 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rBb2c97c978cad5bd336b539bf4333a020838ae9e5
Cleanup: Replace duplicate lines by helper function
===================================================================
M source/blender/draw/engines/gpencil/gpencil_draw.c
===================================================================
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw.c b/source/blender/draw/engines/gpencil/gpencil_draw.c
index b4f45767f6b..4e43b9ad655 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw.c
@@ -122,7 +122,7 @@ Batch *gpencil_get_stroke_geom(bGPDstroke *gps, short thickness, const float ink
}
/* helper to convert 2d to 3d for simple drawing buffer */
-static void gpencil_stroke_convertcoords(Scene *scene, ARegion *ar, ScrArea *sa, tGPspoint *point2D, float out[3], float *depth)
+static void gpencil_stroke_convertcoords(Scene *scene, ARegion *ar, ScrArea *sa, const tGPspoint *point2D, float out[3], float *depth)
{
float mval_f[2] = { point2D->x, point2D->y };
float mval_prj[2];
@@ -147,6 +147,16 @@ static void gpencil_stroke_convertcoords(Scene *scene, ARegion *ar, ScrArea *sa,
zero_v3(out);
}
}
+void gpencil_tpoint_to_point(Scene *scene, ARegion *ar, ScrArea *sa, const tGPspoint *tpt, bGPDspoint *pt)
+{
+ float p3d[3];
+ /* conversion to 3d format */
+ gpencil_stroke_convertcoords(scene, ar, sa, tpt, p3d, NULL);
+ copy_v3_v3(&pt->x, p3d);
+
+ pt->pressure = tpt->pressure;
+ pt->strength = tpt->strength;
+}
/* create batch geometry data for current buffer stroke shader */
Batch *gpencil_get_buffer_stroke_geom(bGPdata *gpd, short thickness)
@@ -174,17 +184,9 @@ Batch *gpencil_get_buffer_stroke_geom(bGPdata *gpd, short thickness)
const tGPspoint *tpt = points;
bGPDspoint pt;
int idx = 0;
- float p3d[3];
-
- float viewinvmat[4][4];
- DRW_viewport_matrix_get(viewinvmat, DRW_MAT_VIEWINV);
for (int i = 0; i < totpoints; i++, tpt++) {
- /* need conversion to 3d format */
- gpencil_stroke_convertcoords(scene, ar, sa, tpt, p3d, NULL);
- copy_v3_v3(&pt.x, p3d);
- pt.pressure = tpt->pressure;
- pt.strength = tpt->strength;
+ gpencil_tpoint_to_point(scene, ar, sa, tpt, &pt);
/* first point for adjacency (not drawn) */
if (i == 0) {
@@ -247,38 +249,22 @@ Batch *gpencil_get_buffer_fill_geom(const tGPspoint *points, int totpoints, floa
bGPDspoint pt;
int idx = 0;
- float p3d[3];
for (int i = 0; i < tot_triangles; i++) {
/* vertex 1 */
tpt = &points[tmp_triangles[i][0]];
- /* need conversion to 3d format */
- gpencil_stroke_convertcoords(scene, ar, sa, tpt, p3d, NULL);
- copy_v3_v3(&pt.x, p3d);
- pt.pressure = tpt->pressure;
- pt.strength = tpt->strength;
-
+ gpencil_tpoint_to_point(scene, ar, sa, tpt, &pt);
VertexBuffer_set_attrib(vbo, pos_id, idx, &pt.x);
VertexBuffer_set_attrib(vbo, color_id, idx, ink);
++idx;
/* vertex 2 */
tpt = &points[tmp_triangles[i][1]];
- /* need conversion to 3d format */
- gpencil_stroke_convertcoords(scene, ar, sa, tpt, p3d, NULL);
- copy_v3_v3(&pt.x, p3d);
- pt.pressure = tpt->pressure;
- pt.strength = tpt->strength;
-
+ gpencil_tpoint_to_point(scene, ar, sa, tpt, &pt);
VertexBuffer_set_attrib(vbo, pos_id, idx, &pt.x);
VertexBuffer_set_attrib(vbo, color_id, idx, ink);
++idx;
/* vertex 3 */
tpt = &points[tmp_triangles[i][2]];
- /* need conversion to 3d format */
- gpencil_stroke_convertcoords(scene, ar, sa, tpt, p3d, NULL);
- copy_v3_v3(&pt.x, p3d);
- pt.pressure = tpt->pressure;
- pt.strength = tpt->strength;
-
+ gpencil_tpoint_to_point(scene, ar, sa, tpt, &pt);
VertexBuffer_set_attrib(vbo, pos_id, idx, &pt.x);
VertexBuffer_set_attrib(vbo, color_id, idx, ink);
++idx;
More information about the Bf-blender-cvs
mailing list