[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35935] trunk/blender/source/blender: xray option for grease pencil (on by default), sometimes its nicer not to have lines draw through the mesh.

Campbell Barton ideasman42 at gmail.com
Fri Apr 1 13:55:22 CEST 2011


Revision: 35935
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35935
Author:   campbellbarton
Date:     2011-04-01 11:55:21 +0000 (Fri, 01 Apr 2011)
Log Message:
-----------
xray option for grease pencil (on by default), sometimes its nicer not to have lines draw through the mesh.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/gpencil/drawgpencil.c
    trunk/blender/source/blender/editors/gpencil/gpencil_buttons.c
    trunk/blender/source/blender/makesdna/DNA_gpencil_types.h
    trunk/blender/source/blender/makesrna/intern/rna_gpencil.c

Modified: trunk/blender/source/blender/editors/gpencil/drawgpencil.c
===================================================================
--- trunk/blender/source/blender/editors/gpencil/drawgpencil.c	2011-04-01 09:00:16 UTC (rev 35934)
+++ trunk/blender/source/blender/editors/gpencil/drawgpencil.c	2011-04-01 11:55:21 UTC (rev 35935)
@@ -81,6 +81,7 @@
 	GP_DRAWDATA_ONLYV2D		= (1<<2),	/* only draw 'canvas' strokes */
 	GP_DRAWDATA_ONLYI2D		= (1<<3),	/* only draw 'image' strokes */
 	GP_DRAWDATA_IEDITHACK	= (1<<4),	/* special hack for drawing strokes in Image Editor (weird coordinates) */
+	GP_DRAWDATA_NO_XRAY		= (1<<5),	/* dont draw xray in 3D view (which is default) */
 };
 
 /* thickness above which we should use special drawing */
@@ -506,8 +507,35 @@
 		/* check which stroke-drawer to use */
 		if (gps->totpoints == 1)
 			gp_draw_stroke_point(gps->points, lthick, gps->flag, offsx, offsy, winx, winy);
-		else if (dflag & GP_DRAWDATA_ONLY3D)
+		else if (dflag & GP_DRAWDATA_ONLY3D) {
+			const int no_xray= (dflag & GP_DRAWDATA_NO_XRAY);
+			int mask_orig;
+			if(no_xray) {
+				glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig);
+				glDepthMask(0);
+				glEnable(GL_DEPTH_TEST);
+
+				/* first arg is normally rv3d->dist, but this isnt available here and seems to work quite well without */
+				bglPolygonOffset(1.0f, 1.0f);
+				/*
+				glEnable(GL_POLYGON_OFFSET_LINE);
+				glPolygonOffset(-1.0f, -1.0f);
+				*/
+			}
+
 			gp_draw_stroke_3d(gps->points, gps->totpoints, lthick, debug);
+
+			if(no_xray) {
+				glDepthMask(mask_orig);
+				glDisable(GL_DEPTH_TEST);
+
+				bglPolygonOffset(0.0, 0.0);
+				/*
+				glDisable(GL_POLYGON_OFFSET_LINE);
+				glPolygonOffset(0, 0);
+				*/
+			}
+		}
 		else if (gps->totpoints > 1)	
 			gp_draw_stroke(gps->points, gps->totpoints, lthick, dflag, gps->flag, debug, offsx, offsy, winx, winy);
 	}
@@ -556,7 +584,11 @@
 		QUATCOPY(tcolor, gpl->color); // additional copy of color (for ghosting)
 		glColor4f(color[0], color[1], color[2], color[3]);
 		glPointSize((float)(gpl->thickness + 2));
-		
+
+		/* apply xray layer setting */
+		if(gpl->flag & GP_LAYER_NO_XRAY)	dflag |=  GP_DRAWDATA_NO_XRAY;
+		else								dflag &= ~GP_DRAWDATA_NO_XRAY;
+
 		/* draw 'onionskins' (frame left + right) */
 		if (gpl->flag & GP_LAYER_ONIONSKIN) {
 			/* drawing method - only immediately surrounding (gstep = 0), or within a frame range on either side (gstep > 0)*/			

Modified: trunk/blender/source/blender/editors/gpencil/gpencil_buttons.c
===================================================================
--- trunk/blender/source/blender/editors/gpencil/gpencil_buttons.c	2011-04-01 09:00:16 UTC (rev 35934)
+++ trunk/blender/source/blender/editors/gpencil/gpencil_buttons.c	2011-04-01 11:55:21 UTC (rev 35935)
@@ -91,7 +91,7 @@
 /* ------- Drawing Code ------- */
 
 /* draw the controls for a given layer */
-static void gp_drawui_layer (uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl)
+static void gp_drawui_layer (uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, const short is_v3d)
 {
 	uiLayout *box=NULL, *split=NULL;
 	uiLayout *col=NULL, *subcol=NULL;
@@ -214,6 +214,10 @@
 		subcol= uiLayoutColumn(col, 1);
 			uiItemR(subcol, &ptr, "use_onion_skinning", 0, "Onion Skinning", ICON_NONE);
 			uiItemR(subcol, &ptr, "ghost_range_max", 0, "Frames", ICON_NONE); // XXX shorter name here? i.e. GStep
+
+		if(is_v3d) {
+			uiItemR(subcol, &ptr, "show_x_ray", 0, "X-Ray", ICON_NONE);
+		}
 		
 	}
 } 
@@ -232,6 +236,7 @@
 	bGPDlayer *gpl;
 	uiLayout *col, *row;
 	short v3d_stroke_opts = STROKE_OPTS_NORMAL;
+	const short is_v3d= CTX_wm_view3d(C) != NULL;
 	
 	/* make new PointerRNA for Grease Pencil block */
 	RNA_id_pointer_create((ID *)gpd, &gpd_ptr);
@@ -255,7 +260,7 @@
 	/* draw each layer --------------------------------------------- */
 	for (gpl= gpd->layers.first; gpl; gpl= gpl->next) {
 		col= uiLayoutColumn(layout, 1);
-			gp_drawui_layer(col, gpd, gpl);
+			gp_drawui_layer(col, gpd, gpl, is_v3d);
 	}
 	
 	/* draw gpd drawing settings first ------------------------------------- */
@@ -264,7 +269,7 @@
 		uiItemL(col, "Drawing Settings:", ICON_NONE);
 		
 		/* check whether advanced 3D-View drawing space options can be used */
-		if (CTX_wm_view3d(C)) {
+		if (is_v3d) {
 			if (gpd->flag & (GP_DATA_DEPTH_STROKE|GP_DATA_DEPTH_VIEW))
 				v3d_stroke_opts = STROKE_OPTS_V3D_ON;
 			else

Modified: trunk/blender/source/blender/makesdna/DNA_gpencil_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_gpencil_types.h	2011-04-01 09:00:16 UTC (rev 35934)
+++ trunk/blender/source/blender/makesdna/DNA_gpencil_types.h	2011-04-01 11:55:21 UTC (rev 35935)
@@ -119,6 +119,8 @@
 #define GP_LAYER_SELECT		(1<<5)
 	/* current frame for layer can't be changed */
 #define GP_LAYER_FRAMELOCK	(1<<6)
+	/* don't render xray (which is default) */
+#define GP_LAYER_NO_XRAY	(1<<7)
 
 
 /* Grease-Pencil Annotations - 'DataBlock' */

Modified: trunk/blender/source/blender/makesrna/intern/rna_gpencil.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_gpencil.c	2011-04-01 09:00:16 UTC (rev 35934)
+++ trunk/blender/source/blender/makesrna/intern/rna_gpencil.c	2011-04-01 11:55:21 UTC (rev 35935)
@@ -235,6 +235,12 @@
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_DRAWDEBUG);
 	RNA_def_property_ui_text(prop, "Show Points", "Draw the points which make up the strokes (for debugging purposes)");
 	RNA_def_property_update(prop, NC_SCREEN|ND_GPENCIL, NULL);
+
+	/* X-Ray */
+	prop= RNA_def_property(srna, "show_x_ray", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GP_LAYER_NO_XRAY);
+	RNA_def_property_ui_text(prop, "X Ray", "");
+	RNA_def_property_update(prop, NC_SCREEN|ND_GPENCIL, NULL);
 }
 
 static void rna_def_gpencil_data(BlenderRNA *brna)




More information about the Bf-blender-cvs mailing list