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

Campbell Barton noreply at git.blender.org
Tue Apr 11 03:03:29 CEST 2017


Commit: c8e2436734466841c2004263f13421b9c1d73b85
Author: Campbell Barton
Date:   Tue Apr 11 10:59:31 2017 +1000
Branches: blender2.8
https://developer.blender.org/rBc8e2436734466841c2004263f13421b9c1d73b85

Merge branch 'master' into blender2.8

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



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

diff --cc source/blender/editors/space_view3d/drawobject.c
index ff8f4e71818,335d0649729..4d00db871da
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@@ -4642,657 -4338,169 +4641,656 @@@ static bool draw_mesh_object(Scene *sce
  	return retval;
  }
  
 -/* ************** DRAW DISPLIST ****************** */
 -
 -
 -/**
 - * \param dl_type_mask Only draw types matching this mask.
 - * \return true when nothing was drawn
 - */
 -static bool drawDispListwire_ex(ListBase *dlbase, unsigned int dl_type_mask)
 +static void make_color_variations(const unsigned char base_ubyte[4], float low[4], float med[4], float high[4], const bool other_obedit)
  {
 -	if (dlbase == NULL) return true;
 -	
 -	glEnableClientState(GL_VERTEX_ARRAY);
 -	glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
 +	/* original idea: nice variations (lighter & darker shades) of base color
 +	 * current implementation uses input color as high; med & low get closer to background color
 +	 */
  
 -	for (DispList *dl = dlbase->first; dl; dl = dl->next) {
 -		if (dl->parts == 0 || dl->nr == 0) {
 -			continue;
 -		}
 +	float bg[3];
 +	UI_GetThemeColor3fv(TH_BACK, bg);
  
 -		if ((dl_type_mask & (1 << dl->type)) == 0) {
 -			continue;
 -		}
 -		
 -		const float *data = dl->verts;
 -		int parts;
 +	float base[4];
 +	rgba_uchar_to_float(base, base_ubyte);
  
 -		switch (dl->type) {
 -			case DL_SEGM:
 +	if (other_obedit) {
 +		/* this object should fade away so user can focus on the object being edited */
 +		interp_v3_v3v3(low, bg, base, 0.1f);
 +		interp_v3_v3v3(med, bg, base, 0.2f);
 +		interp_v3_v3v3(high, bg, base, 0.25f);
 +	}
 +	else {
 +		interp_v3_v3v3(low, bg, base, 0.333f);
 +		interp_v3_v3v3(med, bg, base, 0.667f);
 +		copy_v3_v3(high, base);
 +	}
 +
 +	/* use original alpha */
 +	low[3] = base[3];
 +	med[3] = base[3];
 +	high[3] = base[3];
 +}
  
 -				glVertexPointer(3, GL_FLOAT, 0, data);
 +static void draw_mesh_fancy_new(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base,
 +                                const char dt, const unsigned char ob_wire_col[4], const short dflag, const bool other_obedit)
 +{
 +	if (dflag & (DRAW_PICKING | DRAW_CONSTCOLOR)) {
 +		/* too complicated! use existing methods */
 +		/* TODO: move this into a separate depth pre-pass */
 +		draw_mesh_fancy(scene, sl, ar, v3d, rv3d, base, dt, ob_wire_col, dflag);
 +		return;
 +	}
  
 -				for (parts = 0; parts < dl->parts; parts++)
 -					glDrawArrays(GL_LINE_STRIP, parts * dl->nr, dl->nr);
 -				
 -				break;
 -			case DL_POLY:
 +#ifdef WITH_GAMEENGINE
 +	Object *ob = (rv3d->rflag & RV3D_IS_GAME_ENGINE) ? BKE_object_lod_meshob_get(base->object, sl) : base->object;
 +#else
 +	Object *ob = base->object;
 +#endif
 +	Mesh *me = ob->data;
 +	eWireDrawMode draw_wire = OBDRAW_WIRE_OFF; /* could be bool draw_wire_overlay */
 +	bool no_edges, no_faces;
 +	DerivedMesh *dm = mesh_get_derived_final(scene, ob, scene->customdata_mask);
 +	const bool is_obact = (ob == OBACT_NEW);
 +	int draw_flags = (is_obact && BKE_paint_select_face_test(ob)) ? DRAW_FACE_SELECT : 0;
  
 -				glVertexPointer(3, GL_FLOAT, 0, data);
 +	if (!dm)
 +		return;
  
 -				for (parts = 0; parts < dl->parts; parts++)
 -					glDrawArrays(GL_LINE_LOOP, parts * dl->nr, dl->nr);
 +	const bool solid = dt >= OB_SOLID;
 +	if (solid) {
 +		DM_update_materials(dm, ob);
 +	}
  
 -				break;
 -			case DL_SURF:
 +	/* Check to draw dynamic paint colors (or weights from WeightVG modifiers).
 +	 * Note: Last "preview-active" modifier in stack will win! */
 +	if (DM_get_loop_data_layer(dm, CD_PREVIEW_MLOOPCOL) && modifiers_isPreview(ob))
 +		draw_flags |= DRAW_MODIFIERS_PREVIEW;
  
 -				glVertexPointer(3, GL_FLOAT, 0, data);
 +	/* Unwanted combination */
 +	if (draw_flags & DRAW_FACE_SELECT) {
 +		draw_wire = OBDRAW_WIRE_OFF;
 +	}
 +	else if (ob->dtx & OB_DRAWWIRE) {
 +		draw_wire = OBDRAW_WIRE_ON;
 +	}
  
 -				for (parts = 0; parts < dl->parts; parts++) {
 -					if (dl->flag & DL_CYCL_U)
 -						glDrawArrays(GL_LINE_LOOP, parts * dl->nr, dl->nr);
 -					else
 -						glDrawArrays(GL_LINE_STRIP, parts * dl->nr, dl->nr);
 -				}
 +	/* check polys instead of tessfaces because of dyntopo where tessfaces don't exist */
 +	if (dm->type == DM_TYPE_CCGDM) {
 +		no_edges = !subsurf_has_edges(dm);
 +		no_faces = !subsurf_has_faces(dm);
 +	}
 +	else {
 +		no_edges = (dm->getNumEdges(dm) == 0);
 +		no_faces = (dm->getNumPolys(dm) == 0);
 +	}
  
 -				for (int nr = 0; nr < dl->nr; nr++) {
 -					int ofs = 3 * dl->nr;
 +	if (solid) {
 +		/* vertexpaint, faceselect wants this, but it doesnt work for shaded? */
 +		glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW);
 +	}
  
 -					data = (dl->verts) + 3 * nr;
 -					parts = dl->parts;
 +	if (dt == OB_BOUNDBOX) {
 +		if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && v3d->drawtype >= OB_WIRE) == 0)
 +			draw_bounding_volume(ob, ob->boundtype, ob_wire_col);
 +	}
 +	else if ((no_faces && no_edges) ||
 +	         ((!is_obact || (ob->mode == OB_MODE_OBJECT)) && object_is_halo(scene, ob)))
 +	{
 +		glPointSize(1.5f);
 +		// dm->drawVerts(dm);
 +		// TODO: draw smooth round points as a batch
 +	}
 +	else if ((dt == OB_WIRE) || no_faces) {
 +		draw_wire = OBDRAW_WIRE_ON;
  
 -					if (dl->flag & DL_CYCL_V) glBegin(GL_LINE_LOOP);
 -					else glBegin(GL_LINE_STRIP);
 +		/* enable depth for wireframes */
 +		glEnable(GL_DEPTH_TEST);
 +		glDepthFunc(GL_LESS);
  
 -					while (parts--) {
 -						glVertex3fv(data);
 -						data += ofs;
 -					}
 -					glEnd();
 +		glLineWidth(1.0f);
  
 -#if 0
 -				/* (ton) this code crashes for me when resolv is 86 or higher... no clue */
 -				glVertexPointer(3, GL_FLOAT, sizeof(float) * 3 * dl->nr, data + 3 * nr);
 -				if (dl->flag & DL_CYCL_V)
 -					glDrawArrays(GL_LINE_LOOP, 0, dl->parts);
 -				else
 -					glDrawArrays(GL_LINE_STRIP, 0, dl->parts);
 -#endif
 -				}
 -				break;
 +#if 1 /* fancy wireframes */
  
 -			case DL_INDEX3:
 -				glVertexPointer(3, GL_FLOAT, 0, dl->verts);
 -				glDrawElements(GL_TRIANGLES, 3 * dl->parts, GL_UNSIGNED_INT, dl->index);
 -				break;
 +		Batch *fancy_edges = BKE_mesh_batch_cache_get_fancy_edges(me);
  
 -			case DL_INDEX4:
 -				glVertexPointer(3, GL_FLOAT, 0, dl->verts);
 -				glDrawElements(GL_QUADS, 4 * dl->parts, GL_UNSIGNED_INT, dl->index);
 -				break;
 +		if (rv3d->persp == RV3D_ORTHO) {
 +			Batch_set_builtin_program(fancy_edges, GPU_SHADER_EDGES_FRONT_BACK_ORTHO);
 +			/* set eye vector, transformed to object coords */
 +			float eye[3] = { 0.0f, 0.0f, 1.0f }; /* looking into the screen */
 +			mul_m3_v3((float (*)[3])gpuGetNormalMatrixInverse(NULL), eye);
 +			Batch_Uniform3fv(fancy_edges, "eye", eye);
 +		}
 +		else {
 +			Batch_set_builtin_program(fancy_edges, GPU_SHADER_EDGES_FRONT_BACK_PERSP);
  		}
 -	}
 -	
 -	glDisableClientState(GL_VERTEX_ARRAY);
 -	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
 -	
 -	return false;
 -}
 -
 -static bool drawDispListwire(ListBase *dlbase, const short ob_type)
 -{
 -	unsigned int dl_mask = 0xffffffff;
  
 -	/* skip fill-faces for curves & fonts */
 -	if (ELEM(ob_type, OB_FONT, OB_CURVE)) {
 -		dl_mask &= ~((1 << DL_INDEX3) | (1 << DL_INDEX4));
 -	}
 +		float frontColor[4];
 +		float backColor[4];
 +		float outlineColor[4];
 +		make_color_variations(ob_wire_col, backColor, frontColor, outlineColor, other_obedit);
  
 -	return drawDispListwire_ex(dlbase, dl_mask);
 -}
 +		Batch_Uniform4fv(fancy_edges, "frontColor", frontColor);
 +		Batch_Uniform4fv(fancy_edges, "backColor", backColor);
 +		Batch_Uniform1b(fancy_edges, "drawFront", true);
 +		Batch_Uniform1b(fancy_edges, "drawBack", true); /* false here = backface cull */
 +		Batch_Uniform1b(fancy_edges, "drawSilhouette", false);
  
 -static bool index3_nors_incr = true;
 +		Batch_draw(fancy_edges);
  
 -static void drawDispListsolid(ListBase *lb, Object *ob, const short dflag,
 -                              const unsigned char ob_wire_col[4], const bool use_glsl)
 -{
 -	GPUVertexAttribs gattribs;
 -	
 -	if (lb == NULL) return;
 +		/* extra oomph for the silhouette contours */
 +		glLineWidth(2.0f);
 +		Batch_use_program(fancy_edges); /* hack to make the following uniforms stick */
 +		Batch_Uniform1b(fancy_edges, "drawFront", false);
 +		Batch_Uniform1b(fancy_edges, "drawBack", false);
 +		Batch_Uniform1b(fancy_edges, "drawSilhouette", true);
 +		Batch_Uniform4fv(fancy_edges, "silhouetteColor", outlineColor);
  
 -	glEnableClientState(GL_VERTEX_ARRAY);
 +		Batch_draw(fancy_edges);
  
 -	/* track current material, -1 for none (needed for lines) */
 -	short col = -1;
 -	
 -	DispList *dl = lb->first;
 -	while (dl) {
 -		const float *data = dl->verts;
 -		const float *ndata = dl->nors;
 +#else /* simple wireframes */
  
 -		switch (dl->type) {
 -			case DL_SEGM:
 -				if (ob->type == OB_SURF) {
 -					if (col != -1) {
 -						GPU_object_material_unbind();
 -						col = -1;
 -					}
 +		Batch *batch = MBC_get_all_edges(dm);
 +		Batch_set_builtin_program(batch, GPU_SHADER_3D_UNIFORM_COLOR);
  
 -					if ((dflag & DRAW_CONSTCOLOR) == 0)
 -						glColor3ubv(ob_wire_col);
 +		float color[4];
 +		rgba_uchar_to_float(color, ob_wire_col);
  
 -					// glVertexPointer(3, GL_FLOAT, 0, dl->verts);
 -					// glDrawArrays(GL_LINE_STRIP, 0, dl->nr);
 -					glBegin(GL_LINE_STRIP);
 -					for (int nr = dl->nr; nr; nr--, data += 3)
 -						glVertex3fv(data);
 -					glEnd();
 -				}
 -				break;
 -			case DL_POLY:
 -				if (ob->type == OB_SURF) {
 -					if (col != -1) {
 -						GPU_object_material_unbind();
 -						col = -1;
 -					}
 +		Batch_Uniform4fv(batch, "color", color);
  
 -					/* for some reason glDrawArrays crashes here in half of the platforms (not osx) */
 -					//glVertexPointer(3, GL_FLOAT, 0, dl->verts);
 -					//glDrawArrays(GL_LINE_LOOP, 0, dl->nr);
 +		Batch_draw(batch);
 +#endif
 +	}
 +	else if (((is_obact && ob->mode & OB_MODE_TEXTURE_PAINT)) ||
 +	         check_object_draw_texture(scene, v3d, dt))
 +	{
 +		bool draw_loose = true;
 +
 +		if ((v3d->flag & V3D_SELECT_OUTLINE) &&
 +		    ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) &&
 +		    (base->flag & BASE_SELECTED) &&
 +		    !(G.f & G_PICKSEL || (draw_flags & DRAW_FACE_SELECT)) &&
 +		    (draw_wire == OBDRAW_WIRE_OFF))
 +		{


@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list