[Bf-blender-cvs] [f11a5ce] GPencil_FillStrokes: Make volumetric stroke drawing a per-layer option

Joshua Leung noreply at git.blender.org
Wed Oct 29 13:45:02 CET 2014


Commit: f11a5ce8c1084b6cd1874d2f54d4e7212229b25a
Author: Joshua Leung
Date:   Thu Oct 30 01:18:00 2014 +1300
Branches: GPencil_FillStrokes
https://developer.blender.org/rBf11a5ce8c1084b6cd1874d2f54d4e7212229b25a

Make volumetric stroke drawing a per-layer option

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

M	release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M	source/blender/editors/gpencil/drawgpencil.c
M	source/blender/makesdna/DNA_gpencil_types.h
M	source/blender/makesrna/intern/rna_gpencil.c

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

diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index 3575331..9b0cdad 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -289,12 +289,18 @@ class GreasePencilDataPanel():
         col.label(text="Fill:")
         col.prop(gpl, "fill_color", text="")
         col.prop(gpl, "fill_alpha", text="Opacity", slider=True)
-		
+
         # Options
-        row = layout.row()
-        row.prop(gpl, "line_width", slider=True)
-        row.prop(gpl, "show_x_ray")
-		
+        split = layout.split(percentage=0.5)
+        split.active = not gpl.lock
+
+        col = split.column(align=True)
+        col.prop(gpl, "line_width", slider=True)
+        col.prop(gpl, "use_volumetric_strokes")
+
+        col = split.column(align=True)
+        col.prop(gpl, "show_x_ray")
+
         #if debug:
         #   layout.prop(gpl, "show_points")
 
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index 59614df..391bc81 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -76,6 +76,7 @@ typedef enum eDrawStrokeFlags {
 	GP_DRAWDATA_IEDITHACK   = (1 << 4),   /* special hack for drawing strokes in Image Editor (weird coordinates) */
 	GP_DRAWDATA_NO_XRAY     = (1 << 5),   /* don't draw xray in 3D view (which is default) */
 	GP_DRAWDATA_NO_ONIONS   = (1 << 6),	  /* no onionskins should be drawn (for animation playback) */
+	GP_DRAWDATA_VOLUMETRIC	= (1 << 7),   /* draw strokes as "volumetric" circular billbards */
 } eDrawStrokeFlags;
 
 
@@ -636,14 +637,18 @@ static void gp_draw_strokes(bGPDframe *gpf, int offsx, int offsy, int winx, int
 #endif
 			}
 			
-			// if (dflag & GP_LAYER_VOLUMETRIC)
-			gp_draw_stroke_volumetric_3d(gps->points, gps->totpoints, lthick, dflag, gps->flag);
-			
-			if (gps->totpoints == 1) {
-				gp_draw_stroke_point(gps->points, lthick, dflag, gps->flag, offsx, offsy, winx, winy);
+			if (dflag & GP_DRAWDATA_VOLUMETRIC) {
+				/* volumetric stroke drawing */
+				gp_draw_stroke_volumetric_3d(gps->points, gps->totpoints, lthick, dflag, gps->flag);
 			}
 			else {
-				gp_draw_stroke_3d(gps->points, gps->totpoints, lthick, debug, gps->flag);
+				/* 3D Lines - OpenGL primitives-based */
+				if (gps->totpoints == 1) {
+					gp_draw_stroke_point(gps->points, lthick, dflag, gps->flag, offsx, offsy, winx, winy);
+				}
+				else {
+					gp_draw_stroke_3d(gps->points, gps->totpoints, lthick, debug, gps->flag);
+				}
 			}
 			
 			if (no_xray) {
@@ -658,6 +663,7 @@ static void gp_draw_strokes(bGPDframe *gpf, int offsx, int offsy, int winx, int
 			}
 		}
 		else {
+			/* 2D Strokes... */
 			if (gps->totpoints == 1) {
 				gp_draw_stroke_point(gps->points, lthick, dflag, gps->flag, offsx, offsy, winx, winy);
 			}
@@ -892,6 +898,10 @@ static void gp_draw_data(bGPdata *gpd, int offsx, int offsy, int winx, int winy,
 		if (gpl->flag & GP_LAYER_NO_XRAY) dflag |=  GP_DRAWDATA_NO_XRAY;
 		else dflag &= ~GP_DRAWDATA_NO_XRAY;
 		
+		/* apply volumetric setting */
+		if (gpl->flag & GP_LAYER_VOLUMETRIC) dflag |= GP_DRAWDATA_VOLUMETRIC;
+		else dflag &= ~GP_DRAWDATA_VOLUMETRIC;
+		
 		/* draw 'onionskins' (frame left + right) */
 		if ((gpl->flag & GP_LAYER_ONIONSKIN) && !(dflag & GP_DRAWDATA_NO_ONIONS)) {
 			/* Drawing method - only immediately surrounding (gstep = 0),
@@ -921,9 +931,17 @@ static void gp_draw_data(bGPdata *gpd, int offsx, int offsy, int winx, int winy,
 		    (gpf->flag & GP_FRAME_PAINT))
 		{
 			/* Buffer stroke needs to be drawn with a different linestyle
-			 * to help differentiate them from normal strokes. */
-			gp_draw_stroke_volumetric_buffer(gpd->sbuffer, gpd->sbuffer_size, lthick, dflag, gpd->sbuffer_sflag);
-			gp_draw_stroke_buffer(gpd->sbuffer, gpd->sbuffer_size, lthick, dflag, gpd->sbuffer_sflag);
+			 * to help differentiate them from normal strokes.
+			 * 
+			 * It should also be noted that sbuffer contains temporary point types
+			 * i.e. tGPspoints NOT bGPDspoints
+			 */
+			if (gpl->flag & GP_LAYER_VOLUMETRIC) {
+				gp_draw_stroke_volumetric_buffer(gpd->sbuffer, gpd->sbuffer_size, lthick, dflag, gpd->sbuffer_sflag);
+			}
+			else {
+				gp_draw_stroke_buffer(gpd->sbuffer, gpd->sbuffer_size, lthick, dflag, gpd->sbuffer_sflag);
+			}
 		}
 	}
 	
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index 48cc396..0786567 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -147,7 +147,9 @@ typedef enum eGPDlayer_Flag {
 	/* use custom color for ghosts before current frame */
 	GP_LAYER_GHOST_PREVCOL	= (1 << 8),
 	/* use custom color for ghosts after current frame */
-	GP_LAYER_GHOST_NEXTCOL	= (1 << 9)
+	GP_LAYER_GHOST_NEXTCOL	= (1 << 9),
+	/* "volumetric" strokes (i.e. GLU Quadric discs in 3D) */
+	GP_LAYER_VOLUMETRIC		= (1 << 10),
 } eGPDlayer_Flag;
 
 /* Grease-Pencil Annotations - 'DataBlock' */
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index d1e8aa7..c732c9f 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -596,6 +596,13 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
 	RNA_def_property_editable_func(prop, "rna_GPencilLayer_active_frame_editable");
 	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
 
+	/* Draw Style */
+	// TODO: replace these with a "draw type" combo (i.e. strokes only, filled strokes, strokes + fills, volumetric)?
+	prop = RNA_def_property(srna, "use_volumetric_strokes", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_VOLUMETRIC);
+	RNA_def_property_ui_text(prop, "Volumetric Strokes", "Draw strokes as a series of circular blobs, resulting in a volumetric effect");
+	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+	
 	/* Stroke Drawing Color */
 	prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA);
 	RNA_def_property_array(prop, 3);
@@ -614,13 +621,13 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
 	RNA_def_property_float_sdna(prop, NULL, "fill");
 	RNA_def_property_array(prop, 3);
 	RNA_def_property_range(prop, 0.0f, 1.0f);
-	RNA_def_property_ui_text(prop, "Fill Color", "Color for filling insides of strokes in this layer");
+	RNA_def_property_ui_text(prop, "Fill Color", "Color for filling region bounded by each stroke");
 	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
 	
 	prop = RNA_def_property(srna, "fill_alpha", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "fill[3]");
 	RNA_def_property_range(prop, 0.0, 1.0f);
-	RNA_def_property_ui_text(prop, "Fill Opacity", "Opacity for filling insides of strokes");
+	RNA_def_property_ui_text(prop, "Fill Opacity", "Opacity for filling region bounded by each stroke");
 	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
 	
 	/* Line Thickness */




More information about the Bf-blender-cvs mailing list