[Bf-blender-cvs] [823bb18425a] greasepencil-object: Merge branch 'blender2.8' into greasepencil-object

Antonio Vazquez noreply at git.blender.org
Thu Jun 28 17:46:16 CEST 2018


Commit: 823bb18425a7ad1a400e2b2e2279922732398972
Author: Antonio Vazquez
Date:   Thu Jun 28 17:33:55 2018 +0200
Branches: greasepencil-object
https://developer.blender.org/rB823bb18425a7ad1a400e2b2e2279922732398972

Merge branch 'blender2.8' into greasepencil-object

 Conflicts:
	release/datafiles/userdef/userdef_default_theme.c
	release/scripts/startup/bl_ui/properties_scene.py
	source/blender/editors/gpencil/drawgpencil.c
	source/blender/editors/gpencil/gpencil_brush.c
	source/blender/editors/gpencil/gpencil_paint.c

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



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

diff --cc release/scripts/startup/bl_ui/properties_scene.py
index 3b0d1ba57b4,1394a9388d0..1fbd06e9fcd
--- a/release/scripts/startup/bl_ui/properties_scene.py
+++ b/release/scripts/startup/bl_ui/properties_scene.py
@@@ -548,7 -539,8 +569,9 @@@ classes = 
      SCENE_PT_rigid_body_cache,
      SCENE_PT_rigid_body_field_weights,
      SCENE_PT_simplify,
+     SCENE_PT_simplify_viewport,
+     SCENE_PT_simplify_render,
 +    SCENE_PT_gp_simplify,
      SCENE_PT_custom_props,
  )
  
diff --cc source/blender/blenloader/intern/versioning_280.c
index fd61b1c4d33,3fa059989a3..8552096bc81
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@@ -65,9 -64,9 +66,10 @@@
  #include "BKE_image.h"
  #include "BKE_layer.h"
  #include "BKE_main.h"
 +#include "BKE_material.h"
  #include "BKE_mesh.h"
  #include "BKE_node.h"
+ #include "BKE_pointcache.h"
  #include "BKE_report.h"
  #include "BKE_scene.h"
  #include "BKE_screen.h"
diff --cc source/blender/editors/gpencil/drawgpencil.c
index 347d0120650,a79a5052eb8..6b0e92c81e7
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@@ -721,81 -601,87 +722,81 @@@ static void gp_draw_stroke_point
  	immUnbindProgram();
  }
  
 -/* draw a given stroke in 3d (i.e. in 3d-space), using simple ogl lines */
 -static void gp_draw_stroke_3d(const bGPDspoint *points, int totpoints, short thickness, bool UNUSED(debug),
 -                              short UNUSED(sflag), const float diff_mat[4][4], const float ink[4], bool cyclic)
 +/* draw a given stroke in 3d (i.e. in 3d-space) */
 +static void gp_draw_stroke_3d(tGPDdraw *tgpw, short thickness, const float ink[4], bool cyclic)
  {
 +	bGPDspoint *points = tgpw->gps->points;
 +	int totpoints = tgpw->gps->totpoints;
 +
 +	const float viewport[2] = { (float)tgpw->winx, (float)tgpw->winy };
  	float curpressure = points[0].pressure;
  	float fpt[3];
 -	float cyclic_fpt[3];
 -	int draw_points = 0;
 -
 -	/* if cyclic needs one vertex more */
 -	int cyclic_add = 0;
 -	if (cyclic) {
 -		++cyclic_add;
 -	}
  
 +	/* if cyclic needs more vertex */
 +	int cyclic_add = (cyclic) ? 1 : 0;
  
  	Gwn_VertFormat *format = immVertexFormat();
 -	unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
 -	unsigned int color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
 -
 -	immBindBuiltinProgram(GPU_SHADER_3D_SMOOTH_COLOR);
 -
 -	/* TODO: implement this with a geometry shader to draw one continuous tapered stroke */
 +	unsigned pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
 +	unsigned color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT);
 +	unsigned thickattrib = GWN_vertformat_attr_add(format, "thickness", GWN_COMP_F32, 1, GWN_FETCH_FLOAT);
 +
 +	immBindBuiltinProgram(GPU_SHADER_GPENCIL_STROKE);
 +	immUniform2fv("Viewport", viewport);
 +	immUniform1f("pixsize", tgpw->rv3d->pixsize);
 +	immUniform1f("pixelsize", U.pixelsize);
 +	float obj_scale = (tgpw->ob->size[0] + tgpw->ob->size[1] + tgpw->ob->size[2]) / 3.0f;
 +
 +	immUniform1f("objscale", obj_scale);
 +	int keep_size = (int)((tgpw->gpd) && (tgpw->gpd->flag & GP_DATA_STROKE_KEEPTHICKNESS));
 +	immUniform1i("keep_size", keep_size);
 +	immUniform1i("pixfactor", tgpw->gpd->pixfactor);
 +	immUniform1i("xraymode", tgpw->gpd->xray_mode);
  
  	/* draw stroke curve */
- 	glLineWidth(max_ff(curpressure * thickness, 1.0f));
+ 	GPU_line_width(max_ff(curpressure * thickness, 1.0f));
 -	immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints + cyclic_add);
 +	immBeginAtMost(GWN_PRIM_LINE_STRIP_ADJ, totpoints + cyclic_add + 2);
  	const bGPDspoint *pt = points;
 -	for (int i = 0; i < totpoints; i++, pt++) {
 -		gp_set_point_varying_color(pt, ink, color);
  
 -		/* if there was a significant pressure change, stop the curve, change the thickness of the stroke,
 -		 * and continue drawing again (since line-width cannot change in middle of GL_LINE_STRIP)
 -		 * Note: we want more visible levels of pressures when thickness is bigger.
 -		 */
 -		if (fabsf(pt->pressure - curpressure) > 0.2f / (float)thickness) {
 -			/* if the pressure changes before get at least 2 vertices, need to repeat last point to avoid assert in immEnd() */
 -			if (draw_points < 2) {
 -				const bGPDspoint *pt2 = pt - 1;
 -				mul_v3_m4v3(fpt, diff_mat, &pt2->x);
 -				immVertex3fv(pos, fpt);
 +	for (int i = 0; i < totpoints; i++, pt++) {
 +		/* first point for adjacency (not drawn) */
 +		if (i == 0) {
 +			gp_set_point_varying_color(points, ink, color);
 +			immAttrib1f(thickattrib, max_ff(curpressure * thickness, 1.0f));
 +			if ((cyclic) && (totpoints > 2)) {
 +				mul_v3_m4v3(fpt, tgpw->diff_mat, &(points + totpoints - 1)->x);
  			}
 -			immEnd();
 -			draw_points = 0;
 -
 -			curpressure = pt->pressure;
 -			GPU_line_width(max_ff(curpressure * thickness, 1.0f));
 -			immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints - i + 1 + cyclic_add);
 -
 -			/* need to roll-back one point to ensure that there are no gaps in the stroke */
 -			if (i != 0) {
 -				const bGPDspoint *pt2 = pt - 1;
 -				mul_v3_m4v3(fpt, diff_mat, &pt2->x);
 -				gp_set_point_varying_color(pt2, ink, color);
 -				immVertex3fv(pos, fpt);
 -				++draw_points;
 +			else {
 +				mul_v3_m4v3(fpt, tgpw->diff_mat, &(points + 1)->x);
  			}
 +			mul_v3_fl(fpt, -1.0f);
 +			immVertex3fv(pos, fpt);
  		}
 -
 -		/* now the point we want */
 -		mul_v3_m4v3(fpt, diff_mat, &pt->x);
 +		/* set point */
 +		gp_set_point_varying_color(pt, ink, color);
 +		immAttrib1f(thickattrib, max_ff(curpressure * thickness, 1.0f));
 +		mul_v3_m4v3(fpt, tgpw->diff_mat, &pt->x);
  		immVertex3fv(pos, fpt);
 -		++draw_points;
  
 -		if (cyclic && i == 0) {
 -			/* save first point to use in cyclic */
 -			copy_v3_v3(cyclic_fpt, fpt);
 -		}
 +		curpressure = pt->pressure;
  	}
  
 -	if (cyclic) {
 +	if (cyclic && totpoints > 2) {
  		/* draw line to first point to complete the cycle */
 -		immVertex3fv(pos, cyclic_fpt);
 -		++draw_points;
 -	}
 +		immAttrib1f(thickattrib, max_ff(points->pressure * thickness, 1.0f));
 +		mul_v3_m4v3(fpt, tgpw->diff_mat, &points->x);
 +		immVertex3fv(pos, fpt);
  
 -	/* if less of two points, need to repeat last point to avoid assert in immEnd() */
 -	if (draw_points < 2) {
 -		const bGPDspoint *pt2 = pt - 1;
 -		mul_v3_m4v3(fpt, diff_mat, &pt2->x);
 -		gp_set_point_varying_color(pt2, ink, color);
 +		/* now add adjacency point (not drawn) */
 +		immAttrib1f(thickattrib, max_ff((points + 1)->pressure * thickness, 1.0f));
 +		mul_v3_m4v3(fpt, tgpw->diff_mat, &(points + 1)->x);
 +		immVertex3fv(pos, fpt);
 +	}
 +	/* last adjacency point (not drawn) */
 +	else {
 +		gp_set_point_varying_color(points + totpoints - 1, ink, color);
 +		immAttrib1f(thickattrib, max_ff(curpressure * thickness, 1.0f));
 +		mul_v3_m4v3(fpt, tgpw->diff_mat, &(points + totpoints - 2)->x);
 +		mul_v3_fl(fpt, -1.0f);
  		immVertex3fv(pos, fpt);
  	}
  
@@@ -1434,48 -1329,22 +1435,48 @@@ void ED_gp_draw_primitives(const bConte
  		dflag |= (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_NOSTATUS);
  	}
  
 +	tgpw.rv3d = rv3d;
 +	tgpw.depsgraph = depsgraph;
 +	tgpw.ob = obact;
 +	tgpw.gpd = tgpi->gpd;
 +	tgpw.offsx = 0;
 +	tgpw.offsy = 0;
 +	tgpw.winx = tgpi->ar->winx;
 +	tgpw.winy = tgpi->ar->winy;
 +	tgpw.dflag = dflag;
 +
  	/* turn on alpha-blending */
- 	glEnable(GL_BLEND);
 -	GPU_blend(true);
 -	for (tgpil = tgpi->ilayers.first; tgpil; tgpil = tgpil->next) {
 -		/* calculate parent position */
 -		ED_gpencil_parent_location(tgpil->gpl, diff_mat);
 -		if (tgpil->interFrame) {
 -			gp_draw_strokes(tgpi->gpd, tgpil->interFrame, offsx, offsy, winx, winy, dflag, false,
 -				tgpil->gpl->thickness, 1.0f, color, true, true, diff_mat);
++	GPU_Blend(true);
 +	/* calculate parent position */
 +	ED_gpencil_parent_location(depsgraph, obact, tgpi->gpd, tgpi->gpl, tgpw.diff_mat);
 +	if (tgpi->gpf) {
 +		tgpw.gps = tgpi->gpf->strokes.first;
 +		if (tgpw.gps->totpoints > 0) {
 +			tgpw.gpl = tgpi->gpl;
 +			tgpw.gpf = tgpi->gpf;
 +			tgpw.t_gpf = tgpi->gpf;
 +
 +			tgpw.lthick = tgpi->gpl->thickness;
 +			tgpw.opacity = 1.0;
 +			copy_v4_v4(tgpw.tintcolor, color);
 +			tgpw.onion = true;
 +			tgpw.custonion = true;
 +
 +			gp_draw_strokes(&tgpw);
  		}
  	}
- 	glDisable(GL_BLEND);
+ 	GPU_blend(false);
  }
  
 +/* wrapper to draw strokes for filling operator */
 +void ED_gp_draw_fill(tGPDdraw *tgpw)
 +{
 +	gp_draw_strokes(tgpw);
 +}
 +
  /* loop over gpencil data layers, drawing them */
 -static void gp_draw_data_layers(
 -        const bGPDbrush *brush, float alpha, bGPdata *gpd,
 +static void gp_draw_data_layers(RegionView3D *rv3d,
 +        const Brush *brush, float alpha, Object *ob, bGPdata *gpd,
          int offsx, int offsy, int winx, int winy, int cfra, int dflag)
  {
  	float diff_mat[4][4];
@@@ -1644,15 -1506,15 +1645,15 @@@ static void gp_draw_data(RegionView3D *
  	 */
  
  	/* turn on alpha-blending */
- 	glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- 	glEnable(GL_BLEND);
+ 	GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+ 	GPU_blend(true);
  
  	/* draw! */
 -	gp_draw_data_layers(brush, alpha, gpd, offsx, offsy, winx, winy, cfra, dflag);
 +	gp_draw_data_layers(rv3d, brush, alpha, ob, gpd, offsx, offsy, winx, winy, cfra, dflag);
  
  	/* turn off alpha blending, then smooth lines */
- 	glDisable(GL_BLEND); // alpha blending
- 	glDisable(GL_LINE_SMOOTH); // smooth lines
+ 	GPU_blend(false); // alpha blending
+ 	GPU_line_smooth(false); // smooth lines
  }
  
  /* if we have strokes for scenes (3d view)/clips (movie clip editor)
diff --cc source/blender/editors/gpencil/gpencil_brush.c
index 588c418dbc7,d877ea03c5d..e63810b081a
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@@ -82,10 -78,8 +82,11 @@@
  
  #include "GPU_immediate.h"
  #include "GPU_immediate_util.h"
+ #include "GPU_state.h"
  
 +#include "DEG_depsgraph.h"
 +#include "DEG_depsgraph_query.h"
 +
  #include "gpencil_intern.h"
  
  /* ************************************************ */
diff --cc sour

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list