[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60882] trunk/blender/source/blender/ editors/space_view3d/drawobject.c: Partial fix for [#37159] Particle Emitter set to not render still appears in 3D view, when display set to rendered only.

Bastien Montagne montagne29 at wanadoo.fr
Mon Oct 21 17:44:09 CEST 2013


Revision: 60882
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60882
Author:   mont29
Date:     2013-10-21 15:44:09 +0000 (Mon, 21 Oct 2013)
Log Message:
-----------
Partial fix for [#37159] Particle Emitter set to not render still appears in 3D view, when display set to rendered only. Emitter also appears in all GL Renders and some F12 renders.

Fixed OpenGL part: in draw_object, when object has some particle systems and none of them render the emitter, and display option is set to show only rendered objects, skip this object.

Note: Cycles matter I did not investigate, looks like a render-engine issue.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_view3d/drawobject.c

Modified: trunk/blender/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/drawobject.c	2013-10-21 15:00:22 UTC (rev 60881)
+++ trunk/blender/source/blender/editors/space_view3d/drawobject.c	2013-10-21 15:44:09 UTC (rev 60882)
@@ -6581,6 +6581,8 @@
 	char  dt;
 	short zbufoff = 0;
 	const bool is_obact = (ob == OBACT);
+	const bool render_override = (v3d->flag2 & V3D_RENDER_OVERRIDE) != 0;
+	bool particle_skip_object = false;  /* Draw particles but not their emitter object. */
 
 	/* only once set now, will be removed too, should become a global standard */
 	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -6589,17 +6591,32 @@
 		if (ob->restrictflag & OB_RESTRICT_VIEW) {
 			return;
 		}
-		else if ((ob->restrictflag & OB_RESTRICT_RENDER) &&
-		         (v3d->flag2 & V3D_RENDER_OVERRIDE))
+		else if ((ob->restrictflag & OB_RESTRICT_RENDER) && render_override)
 		{
 			return;
 		}
 	}
 
-	/* XXX particles are not safe for simultaneous threaded render */
-	if (G.is_rendering && ob->particlesystem.first)
-		return;
+	if (ob->particlesystem.first) {
+		/* XXX particles are not safe for simultaneous threaded render */
+		if (G.is_rendering) {
+			return;
+		}
 
+		if (ob->mode == OB_MODE_OBJECT) {
+			ParticleSystem *psys;
+
+			particle_skip_object = render_override;
+			for (psys = ob->particlesystem.first; psys; psys = psys->next) {
+				/* Once we have found a psys which renders its emitter object, we are done. */
+				if (psys->part->draw & PART_DRAW_EMITTER) {
+					particle_skip_object = false;
+					break;
+				}
+			}
+		}
+	}
+
 	/* xray delay? */
 	if ((dflag & DRAW_PICKING) == 0 && (base->flag & OB_FROMDUPLI) == 0 && (v3d->flag2 & V3D_RENDER_SHADOW) == 0) {
 		/* don't do xray in particle mode, need the z-buffer */
@@ -6624,7 +6641,7 @@
 	view3d_cached_text_draw_begin();
 	
 	/* draw motion paths (in view space) */
-	if (ob->mpath && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
+	if (ob->mpath && !render_override) {
 		bAnimVizSettings *avs = &ob->avs;
 		
 		/* setup drawing environment for paths */
@@ -6665,7 +6682,7 @@
 
 	/* faceselect exception: also draw solid when (dt == wire), except in editmode */
 	if (is_obact && (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT))) {
-		if (ob->type == OB_MESH) {			
+		if (ob->type == OB_MESH) {
 			if (dt < OB_SOLID) {
 				zbufoff = 1;
 				dt = OB_SOLID;
@@ -6688,7 +6705,6 @@
 	
 	/* draw-extra supported for boundbox drawmode too */
 	if (dt >= OB_BOUNDBOX) {
-
 		dtx = ob->dtx;
 		if (ob->mode & OB_MODE_EDIT) {
 			// the only 2 extra drawtypes alowed in editmode
@@ -6697,240 +6713,241 @@
 
 	}
 
-	/* bad exception, solve this! otherwise outline shows too late */
-	if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
-		/* still needed for curves hidden in other layers. depgraph doesnt handle that yet */
-		if (ELEM(NULL, ob->curve_cache, ob->curve_cache->disp.first)) {
-			BKE_displist_make_curveTypes(scene, ob, 0);
+	if (!particle_skip_object) {
+		/* bad exception, solve this! otherwise outline shows too late */
+		if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
+			/* still needed for curves hidden in other layers. depgraph doesnt handle that yet */
+			if (ELEM(NULL, ob->curve_cache, ob->curve_cache->disp.first)) {
+				BKE_displist_make_curveTypes(scene, ob, 0);
+			}
 		}
-	}
-	
-	/* draw outline for selected objects, mesh does itself */
-	if ((v3d->flag & V3D_SELECT_OUTLINE) && ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) && ob->type != OB_MESH) {
-		if (dt > OB_WIRE && (ob->mode & OB_MODE_EDIT) == 0 && (dflag & DRAW_SCENESET) == 0) {
-			if (!(ob->dtx & OB_DRAWWIRE) && (ob->flag & SELECT) && !(dflag & (DRAW_PICKING | DRAW_CONSTCOLOR))) {
-				drawObjectSelect(scene, v3d, ar, base, ob_wire_col);
+		
+		/* draw outline for selected objects, mesh does itself */
+		if ((v3d->flag & V3D_SELECT_OUTLINE) && !render_override && ob->type != OB_MESH) {
+			if (dt > OB_WIRE && (ob->mode & OB_MODE_EDIT) == 0 && (dflag & DRAW_SCENESET) == 0) {
+				if (!(ob->dtx & OB_DRAWWIRE) && (ob->flag & SELECT) && !(dflag & (DRAW_PICKING | DRAW_CONSTCOLOR))) {
+					drawObjectSelect(scene, v3d, ar, base, ob_wire_col);
+				}
 			}
 		}
-	}
 
-	switch (ob->type) {
-		case OB_MESH:
-			empty_object = draw_mesh_object(scene, ar, v3d, rv3d, base, dt, ob_wire_col, dflag);
-			if (dflag != DRAW_CONSTCOLOR) dtx &= ~OB_DRAWWIRE;  // mesh draws wire itself
+		switch (ob->type) {
+			case OB_MESH:
+				empty_object = draw_mesh_object(scene, ar, v3d, rv3d, base, dt, ob_wire_col, dflag);
+				if (dflag != DRAW_CONSTCOLOR) dtx &= ~OB_DRAWWIRE;  // mesh draws wire itself
 
-			break;
-		case OB_FONT:
-			cu = ob->data;
-			if (cu->editfont) {
-				draw_textcurs(rv3d, cu->editfont->textcurs);
+				break;
+			case OB_FONT:
+				cu = ob->data;
+				if (cu->editfont) {
+					draw_textcurs(rv3d, cu->editfont->textcurs);
 
-				if (cu->flag & CU_FAST) {
-					cpack(0xFFFFFF);
-					set_inverted_drawing(1);
-					drawDispList(scene, v3d, rv3d, base, OB_WIRE, dflag, ob_wire_col);
-					set_inverted_drawing(0);
-				}
-				else {
-					drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
-				}
+					if (cu->flag & CU_FAST) {
+						cpack(0xFFFFFF);
+						set_inverted_drawing(1);
+						drawDispList(scene, v3d, rv3d, base, OB_WIRE, dflag, ob_wire_col);
+						set_inverted_drawing(0);
+					}
+					else {
+						drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
+					}
 
-				if (cu->linewidth != 0.0f) {
-					UI_ThemeColor(TH_WIRE_EDIT);
-					copy_v3_v3(vec1, ob->orig);
-					copy_v3_v3(vec2, ob->orig);
-					vec1[0] += cu->linewidth;
-					vec2[0] += cu->linewidth;
-					vec1[1] += cu->linedist * cu->fsize;
-					vec2[1] -= cu->lines * cu->linedist * cu->fsize;
-					setlinestyle(3);
-					glBegin(GL_LINE_STRIP);
-					glVertex2fv(vec1);
-					glVertex2fv(vec2);
-					glEnd();
-					setlinestyle(0);
-				}
-
-				setlinestyle(3);
-				for (i = 0; i < cu->totbox; i++) {
-					if (cu->tb[i].w != 0.0f) {
-						UI_ThemeColor(i == (cu->actbox - 1) ? TH_ACTIVE : TH_WIRE);
-						vec1[0] = (cu->xof * cu->fsize) + cu->tb[i].x;
-						vec1[1] = (cu->yof * cu->fsize) + cu->tb[i].y + cu->fsize;
-						vec1[2] = 0.001;
+					if (cu->linewidth != 0.0f) {
+						UI_ThemeColor(TH_WIRE_EDIT);
+						copy_v3_v3(vec1, ob->orig);
+						copy_v3_v3(vec2, ob->orig);
+						vec1[0] += cu->linewidth;
+						vec2[0] += cu->linewidth;
+						vec1[1] += cu->linedist * cu->fsize;
+						vec2[1] -= cu->lines * cu->linedist * cu->fsize;
+						setlinestyle(3);
 						glBegin(GL_LINE_STRIP);
-						glVertex3fv(vec1);
-						vec1[0] += cu->tb[i].w;
-						glVertex3fv(vec1);
-						vec1[1] -= cu->tb[i].h;
-						glVertex3fv(vec1);
-						vec1[0] -= cu->tb[i].w;
-						glVertex3fv(vec1);
-						vec1[1] += cu->tb[i].h;
-						glVertex3fv(vec1);
+						glVertex2fv(vec1);
+						glVertex2fv(vec2);
 						glEnd();
+						setlinestyle(0);
 					}
-				}
-				setlinestyle(0);
 
+					setlinestyle(3);
+					for (i = 0; i < cu->totbox; i++) {
+						if (cu->tb[i].w != 0.0f) {
+							UI_ThemeColor(i == (cu->actbox - 1) ? TH_ACTIVE : TH_WIRE);
+							vec1[0] = (cu->xof * cu->fsize) + cu->tb[i].x;
+							vec1[1] = (cu->yof * cu->fsize) + cu->tb[i].y + cu->fsize;
+							vec1[2] = 0.001;
+							glBegin(GL_LINE_STRIP);
+							glVertex3fv(vec1);
+							vec1[0] += cu->tb[i].w;
+							glVertex3fv(vec1);
+							vec1[1] -= cu->tb[i].h;
+							glVertex3fv(vec1);
+							vec1[0] -= cu->tb[i].w;
+							glVertex3fv(vec1);
+							vec1[1] += cu->tb[i].h;
+							glVertex3fv(vec1);
+							glEnd();
+						}
+					}
+					setlinestyle(0);
 
-				if (BKE_vfont_select_get(ob, &selstart, &selend) && cu->selboxes) {
-					float selboxw;
 
-					cpack(0xffffff);
-					set_inverted_drawing(1);
-					for (i = 0; i <= (selend - selstart); i++) {
-						SelBox *sb = &(cu->selboxes[i]);
+					if (BKE_vfont_select_get(ob, &selstart, &selend) && cu->selboxes) {
+						float selboxw;
 
-						if (i < (selend - selstart)) {
-							if (cu->selboxes[i + 1].y == sb->y)
-								selboxw = cu->selboxes[i + 1].x - sb->x;
-							else
+						cpack(0xffffff);
+						set_inverted_drawing(1);
+						for (i = 0; i <= (selend - selstart); i++) {
+							SelBox *sb = &(cu->selboxes[i]);
+
+							if (i < (selend - selstart)) {
+								if (cu->selboxes[i + 1].y == sb->y)
+									selboxw = cu->selboxes[i + 1].x - sb->x;
+								else
+									selboxw = sb->w;
+							}
+							else {
 								selboxw = sb->w;
+							}
+							glBegin(GL_QUADS);
+							glVertex3f(sb->x, sb->y, 0.001);
+							glVertex3f(sb->x + selboxw, sb->y, 0.001);
+							glVertex3f(sb->x + selboxw, sb->y + sb->h, 0.001);
+							glVertex3f(sb->x, sb->y + sb->h, 0.001);
+							glEnd();
 						}
-						else {
-							selboxw = sb->w;
-						}
-						glBegin(GL_QUADS);
-						glVertex3f(sb->x, sb->y, 0.001);
-						glVertex3f(sb->x + selboxw, sb->y, 0.001);
-						glVertex3f(sb->x + selboxw, sb->y + sb->h, 0.001);
-						glVertex3f(sb->x, sb->y + sb->h, 0.001);
-						glEnd();
+						set_inverted_drawing(0);
 					}
-					set_inverted_drawing(0);
 				}
-			}
-			else if (dt == OB_BOUNDBOX) {
-				if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && v3d->drawtype >= OB_WIRE) == 0) {
-					draw_bounding_volume(scene, ob, ob->boundtype);
+				else if (dt == OB_BOUNDBOX) {
+					if ((render_override && v3d->drawtype >= OB_WIRE) == 0) {
+						draw_bounding_volume(scene, ob, ob->boundtype);
+					}
 				}
-			}
-			else if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb)) {
-				empty_object = drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
-			}
+				else if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb)) {
+					empty_object = drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
+				}
 
-			break;
-		case OB_CURVE:
-		case OB_SURF:
-			cu = ob->data;
+				break;
+			case OB_CURVE:
+			case OB_SURF:
+				cu = ob->data;
 
-			if (cu->editnurb) {
-				ListBase *nurbs = BKE_curve_editNurbs_get(cu);
-				drawnurb(scene, v3d, rv3d, base, nurbs->first, dt, dflag, ob_wire_col);
-			}
-			else if (dt == OB_BOUNDBOX) {
-				if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && (v3d->drawtype >= OB_WIRE)) == 0) {
-					draw_bounding_volume(scene, ob, ob->boundtype);
+				if (cu->editnurb) {
+					ListBase *nurbs = BKE_curve_editNurbs_get(cu);
+					drawnurb(scene, v3d, rv3d, base, nurbs->first, dt, dflag, ob_wire_col);
 				}
-			}

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list