[Bf-blender-cvs] [a99411a1aa5] greasepencil-object: Fix cyclic wrong opacity

Antonio Vazquez noreply at git.blender.org
Sun Oct 15 18:34:04 CEST 2017


Commit: a99411a1aa5c12fb916fcff7d74e467205277818
Author: Antonio Vazquez
Date:   Sun Oct 15 18:33:41 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rBa99411a1aa5c12fb916fcff7d74e467205277818

Fix cyclic wrong opacity

When enable stroke cyclic, the opacity of the final segment of the stroke was darker.

The problem was related to the adjacency points used.

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

M	source/blender/draw/engines/gpencil/gpencil_geom.c
M	source/blender/editors/gpencil/drawgpencil.c

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

diff --git a/source/blender/draw/engines/gpencil/gpencil_geom.c b/source/blender/draw/engines/gpencil/gpencil_geom.c
index e2fd9f00f2a..af884d02fce 100644
--- a/source/blender/draw/engines/gpencil/gpencil_geom.c
+++ b/source/blender/draw/engines/gpencil/gpencil_geom.c
@@ -116,7 +116,7 @@ Gwn_Batch *DRW_gpencil_get_stroke_geom(bGPDframe *gpf, bGPDstroke *gps, short th
 	bGPDspoint *points = gps->points;
 	int totpoints = gps->totpoints;
 	/* if cyclic needs more vertex */
-	int cyclic_add = (gps->flag & GP_STROKE_CYCLIC) ? 2 : 0;
+	int cyclic_add = (gps->flag & GP_STROKE_CYCLIC) ? 1 : 0;
 
 	static Gwn_VertFormat format = { 0 };
 	static unsigned int pos_id, color_id, thickness_id;
@@ -147,11 +147,9 @@ Gwn_Batch *DRW_gpencil_get_stroke_geom(bGPDframe *gpf, bGPDstroke *gps, short th
 		/* draw line to first point to complete the cycle */
 		gpencil_set_stroke_point(vbo, gpf->viewmatrix, &points[0], idx, pos_id, color_id, thickness_id, thickness, ink);
 		++idx;
-		/* now add adjacency points using 2nd & 3rd point to get smooth transition */
+		/* now add adjacency point (not drawn) */
 		gpencil_set_stroke_point(vbo, gpf->viewmatrix, &points[1], idx, pos_id, color_id, thickness_id, thickness, ink);
 		++idx;
-		gpencil_set_stroke_point(vbo, gpf->viewmatrix, &points[2], idx, pos_id, color_id, thickness_id, thickness, ink);
-		++idx;
 	}
 	/* last adjacency point (not drawn) */
 	else {
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index 3836952947f..939e0e4df9e 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -729,7 +729,7 @@ static void gp_draw_stroke_3d(
 	UNUSED_VARS(offset);
 
 	/* if cyclic needs more vertex */
-	int cyclic_add = (cyclic) ? 2 : 0;
+	int cyclic_add = (cyclic) ? 1 : 0;
 
 	Gwn_VertFormat *format = immVertexFormat();
 	unsigned pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
@@ -769,14 +769,10 @@ static void gp_draw_stroke_3d(
 		mul_v3_m4v3(fpt, diff_mat, &points->x);
 		immVertex3fv(pos, fpt);
 
-		/* now add adjacency points using 2nd & 3rd point to get smooth transition */
+		/* now add adjacency point (not drawn) */
 		immAttrib1f(thickattrib, max_ff((points + 1)->pressure * thickness, 1.0f));
 		mul_v3_m4v3(fpt, diff_mat, &(points + 1)->x);
 		immVertex3fv(pos, fpt);
-
-		immAttrib1f(thickattrib, max_ff((points + 2)->pressure * thickness, 1.0f));
-		mul_v3_m4v3(fpt, diff_mat, &(points + 2)->x);
-		immVertex3fv(pos, fpt);
 	}
 	/* last adjacency point (not drawn) */
 	else {



More information about the Bf-blender-cvs mailing list