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

Campbell Barton noreply at git.blender.org
Sat Apr 29 19:06:17 CEST 2017


Commit: fbd172a00aed4546d3b4cbd0711a5ce94a4ee1b2
Author: Campbell Barton
Date:   Sun Apr 30 03:05:34 2017 +1000
Branches: blender2.8
https://developer.blender.org/rBfbd172a00aed4546d3b4cbd0711a5ce94a4ee1b2

Merge branch 'master' into blender2.8

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



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

diff --cc source/blender/editors/gpencil/drawgpencil.c
index d36122fa133,ecab37c729f..20929e4b908
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@@ -115,77 -108,14 +115,77 @@@ static void gp_set_point_uniform_color(
  {
  	float alpha = ink[3] * pt->strength;
  	CLAMP(alpha, GPENCIL_STRENGTH_MIN, 1.0f);
 -	glColor4f(ink[0], ink[1], ink[2], alpha);
 +	immUniformColor3fvAlpha(ink, alpha);
  }
  
 -/* helper function to set color and point */
 -static void gp_set_color_and_tpoint(tGPspoint *pt, float ink[4])
 +static void gp_set_point_varying_color(const bGPDspoint *pt, const float ink[4], unsigned attrib_id)
  {
 -	gp_set_tpoint_color(pt, ink);
 -	glVertex2iv(&pt->x);
 +	float alpha = ink[3] * pt->strength;
 +	CLAMP(alpha, GPENCIL_STRENGTH_MIN, 1.0f);
 +	immAttrib4ub(attrib_id, F2UB(ink[0]), F2UB(ink[1]), F2UB(ink[2]), F2UB(alpha));
 +}
 +
 +/* draw fills for buffer stroke */
 +static void gp_draw_stroke_buffer_fill(const tGPspoint *points, int totpoints, float ink[4])
 +{
 +	if (totpoints < 3) {
 +		return;
 +	}
 +	int tot_triangles = totpoints - 2;
 +	/* allocate memory for temporary areas */
 +	unsigned int(*tmp_triangles)[3] = MEM_mallocN(sizeof(*tmp_triangles) * tot_triangles, "GP Stroke buffer temp triangulation");
 +	float(*points2d)[2] = MEM_mallocN(sizeof(*points2d) * totpoints, "GP Stroke buffer temp 2d points");
 +
 +	/* Convert points to array and triangulate
- 	* Here a cache is not used because while drawing the information changes all the time, so the cache
- 	* would be recalculated constantly, so it is better to do direct calculation for each function call
- 	*/
++	 * Here a cache is not used because while drawing the information changes all the time, so the cache
++	 * would be recalculated constantly, so it is better to do direct calculation for each function call
++	 */
 +	for (int i = 0; i < totpoints; i++) {
 +		const tGPspoint *pt = &points[i];
 +		points2d[i][0] = pt->x;
 +		points2d[i][1] = pt->y;
 +	}
 +	BLI_polyfill_calc((const float(*)[2])points2d, (unsigned int)totpoints, 0, (unsigned int(*)[3])tmp_triangles);
 +
 +	/* draw triangulation data */
 +	if (tot_triangles > 0) {
 +		VertexFormat *format = immVertexFormat();
 +		unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
 +		unsigned int color = VertexFormat_add_attrib(format, "color", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT);
 +
 +		immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
 +
 +		/* Draw all triangles for filling the polygon */
 +		immBegin(PRIM_TRIANGLES, tot_triangles * 3);
 +		/* TODO: use batch instead of immediate mode, to share vertices */
 +
 +		const tGPspoint *pt;
 +		for (int i = 0; i < tot_triangles; i++) {
 +			/* vertex 1 */
 +			pt = &points[tmp_triangles[i][0]];
 +			gp_set_tpoint_varying_color(pt, ink, color);
 +			immVertex2iv(pos, &pt->x);
 +			/* vertex 2 */
 +			pt = &points[tmp_triangles[i][1]];
 +			gp_set_tpoint_varying_color(pt, ink, color);
 +			immVertex2iv(pos, &pt->x);
 +			/* vertex 3 */
 +			pt = &points[tmp_triangles[i][2]];
 +			gp_set_tpoint_varying_color(pt, ink, color);
 +			immVertex2iv(pos, &pt->x);
 +		}
 +
 +		immEnd();
 +		immUnbindProgram();
 +	}
 +
 +	/* clear memory */
 +	if (tmp_triangles) {
 +		MEM_freeN(tmp_triangles);
 +	}
 +	if (points2d) {
 +		MEM_freeN(points2d);
 +	}
  }
  
  /* draw stroke defined in buffer (simple ogl lines/points for now, as dotted lines) */
diff --cc source/blender/editors/gpencil/gpencil_utils.c
index 693defb8b1b,2b662d04f03..9ed5cf57eec
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@@ -869,8 -868,8 +869,8 @@@ bool gp_smooth_stroke_thickness(bGPDstr
  	ptc = &gps->points[after];
  
  	/* the optimal value is the corresponding to the interpolation of the pressure
--	*  at the distance of point b
--	*/
++	 *  at the distance of point b
++	 */
  	float fac = line_point_factor_v3(&ptb->x, &pta->x, &ptc->x);
  	float optimal = (1.0f - fac) * pta->pressure + fac * ptc->pressure;
  
diff --cc source/blender/editors/space_view3d/view3d_edit.c
index 42e8759c6dc,4e3f279e12e..63024b489e1
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@@ -734,8 -735,7 +733,8 @@@ static void viewops_data_create_ex
  	RegionView3D *rv3d = vod->rv3d;
  
  	/* we need the depth info before changing any viewport options */
- 	if (orbit_mode == VIEWOPS_ORBIT_DEPTH) {
+ 	if (orbit_mode & VIEWOPS_ORBIT_DEPTH) {
 +		struct Depsgraph *graph = CTX_data_depsgraph(C);
  		float fallback_depth_pt[3];
  
  		view3d_operator_needs_opengl(C); /* needed for zbuf drawing */




More information about the Bf-blender-cvs mailing list