[Bf-blender-cvs] [aa7e76b2e35] blender2.8: Merge branch 'master' into blender2.8

Campbell Barton noreply at git.blender.org
Fri Oct 20 00:37:49 CEST 2017


Commit: aa7e76b2e35c6ff6c58ccd4373b68dde8283a3a3
Author: Campbell Barton
Date:   Fri Oct 20 09:40:08 2017 +1100
Branches: blender2.8
https://developer.blender.org/rBaa7e76b2e35c6ff6c58ccd4373b68dde8283a3a3

Merge branch 'master' into blender2.8

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



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

diff --cc source/blender/editors/gpencil/drawgpencil.c
index 63c15744388,bba7137c3ee..659c0c99fcb
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@@ -473,12 -438,10 +473,9 @@@ static void gp_triangulate_stroke_fill(
  		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];
- 			stroke_triangle->v2 = tmp_triangles[i][1];
- 			stroke_triangle->v3 = tmp_triangles[i][2];
 -			memcpy(stroke_triangle->verts, tmp_triangles[i], sizeof(uint[3]));
++			memcpy(gps->triangles[i].verts, tmp_triangles[i], sizeof(uint[3]));
  		}
  	}
  	else {
@@@ -517,64 -485,59 +514,50 @@@ static void gp_draw_stroke_fill
  		if ((gps->flag & GP_STROKE_RECALC_CACHES) || (gps->tot_triangles == 0) || (gps->triangles == NULL)) {
  			gp_triangulate_stroke_fill(gps);
  		}
 -		/* Draw all triangles for filling the polygon (cache must be calculated before) */
  		BLI_assert(gps->tot_triangles >= 1);
 -		glBegin(GL_TRIANGLES);
 +
 +		unsigned int pos;
  		if (gps->flag & GP_STROKE_3DSPACE) {
 -			for (i = 0, stroke_triangle = gps->triangles; i < gps->tot_triangles; i++, stroke_triangle++) {
 +			pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
 +			immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
 +		}
 +		else {
 +			pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
 +			immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 +		}
 +
 +		immUniformColor4fv(color);
 +
 +		/* Draw all triangles for filling the polygon (cache must be calculated before) */
 +		immBegin(GWN_PRIM_TRIS, gps->tot_triangles * 3);
 +		/* TODO: use batch instead of immediate mode, to share vertices */
 +
 +		bGPDtriangle *stroke_triangle = gps->triangles;
 +		bGPDspoint *pt;
 +
- 		for (int i = 0; i < gps->tot_triangles; i++, stroke_triangle++) {
- 			if (gps->flag & GP_STROKE_3DSPACE) {
- 				/* vertex 1 */
- 				pt = &gps->points[stroke_triangle->v1];
- 				mul_v3_m4v3(fpt, diff_mat, &pt->x);
- 				immVertex3fv(pos, fpt);
- 				/* vertex 2 */
- 				pt = &gps->points[stroke_triangle->v2];
- 				mul_v3_m4v3(fpt, diff_mat, &pt->x);
- 				immVertex3fv(pos, fpt);
- 				/* vertex 3 */
- 				pt = &gps->points[stroke_triangle->v3];
- 				mul_v3_m4v3(fpt, diff_mat, &pt->x);
- 				immVertex3fv(pos, fpt);
++		if (gps->flag & GP_STROKE_3DSPACE) {
++			for (int i = 0; i < gps->tot_triangles; i++, stroke_triangle++) {
+ 				for (int j = 0; j < 3; j++) {
+ 					pt = &gps->points[stroke_triangle->verts[j]];
+ 					mul_v3_m4v3(fpt, diff_mat, &pt->x);
 -					glVertex3fv(fpt);
++					immVertex3fv(pos, fpt);
+ 				}
  			}
- 			else {
- 				float co[2];
- 				/* vertex 1 */
- 				pt = &gps->points[stroke_triangle->v1];
- 				mul_v3_m4v3(fpt, diff_mat, &pt->x);
- 				gp_calc_2d_stroke_fxy(fpt, gps->flag, offsx, offsy, winx, winy, co);
- 				immVertex2fv(pos, co);
- 				/* vertex 2 */
- 				pt = &gps->points[stroke_triangle->v2];
- 				mul_v3_m4v3(fpt, diff_mat, &pt->x);
- 				gp_calc_2d_stroke_fxy(fpt, gps->flag, offsx, offsy, winx, winy, co);
- 				immVertex2fv(pos, co);
- 				/* vertex 3 */
- 				pt = &gps->points[stroke_triangle->v3];
- 				mul_v3_m4v3(fpt, diff_mat, &pt->x);
- 				gp_calc_2d_stroke_fxy(fpt, gps->flag, offsx, offsy, winx, winy, co);
- 				immVertex2fv(pos, co);
+ 		}
+ 		else {
 -			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++) {
+ 				for (int j = 0; j < 3; j++) {
+ 					float co[2];
+ 					pt = &gps->points[stroke_triangle->verts[j]];
+ 					mul_v3_m4v3(fpt, diff_mat, &pt->x);
+ 					gp_calc_2d_stroke_fxy(fpt, gps->flag, offsx, offsy, winx, winy, co);
 -					glVertex2fv(co);
++					immVertex3fv(pos, fpt);
+ 				}
  			}
  		}
 -		glEnd();
 -	}
 -	else {
 -		/* As an initial implementation, we use the OpenGL filled polygon drawing
 -		 * here since it's the easiest option to implement for this case. It does
 -		 * come with limitations (notably for concave shapes), though it shouldn't
 -		 * be much of an issue in most cases.
 -		 *
 -		 * We keep this legacy implementation around despite now having the high quality
 -		 * fills, as this is necessary for keeping everything working nicely for files
 -		 * created using old versions of Blender which may have depended on the artifacts
 -		 * the old fills created.
 -		 */
 -		bGPDspoint *pt;
 -
 -		glBegin(GL_POLYGON);
 -		for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
 -			if (gps->flag & GP_STROKE_3DSPACE) {
 -				mul_v3_m4v3(fpt, diff_mat, &pt->x);
 -				glVertex3fv(fpt);
 -			}
 -			else {
 -				float co[2];
 -				mul_v3_m4v3(fpt, diff_mat, &pt->x);
 -				gp_calc_2d_stroke_fxy(fpt, gps->flag, offsx, offsy, winx, winy, co);
 -				glVertex2fv(co);
 -			}
 -		}
  
 -		glEnd();
 +		immEnd();
 +		immUnbindProgram();
  	}
  }



More information about the Bf-blender-cvs mailing list