[Bf-blender-cvs] [37e8dd2b94b] greasepencil-object: Add filter by View Layer when render (F12)

Antonio Vazquez noreply at git.blender.org
Thu Mar 15 12:02:40 CET 2018


Commit: 37e8dd2b94b8df9087e0f1d34f36c25d224e36c8
Author: Antonio Vazquez
Date:   Thu Mar 15 12:02:33 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rB37e8dd2b94b8df9087e0f1d34f36c25d224e36c8

Add filter by View Layer when render (F12)

Now it's possible to filter the grease pencil layers by view layer for render. The filter can be inverted.

This is an additional level of object visibility.

This is used for compositing.

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

M	release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M	source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.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 aa18af2fc4f..8c85473c9cf 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -1137,6 +1137,7 @@ class GreasePencilParentLayerPanel:
     @staticmethod
     def draw(self, context):
         layout = self.layout
+        scene = context.scene
         gpl = context.active_gpencil_layer
         row = layout.row()
 
@@ -1151,6 +1152,12 @@ class GreasePencilParentLayerPanel:
         if parent and gpl.parent_type == 'BONE' and parent.type == 'ARMATURE':
             sub.prop_search(gpl, "parent_bone", parent.data, "bones", text="")
 
+        row = layout.row()
+        row.label("Render Settings:")
+        row = layout.row(align=True)
+        row.prop_search(gpl, "view_layer", scene, "view_layers", text="View Layer")
+        row.prop(gpl, "invert_view_layer", text="", icon='ARROW_LEFTRIGHT')
+
 
 class GPENCIL_UL_vgroups(UIList):
     def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index ca5aae452e9..013014bf008 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -1171,6 +1171,26 @@ void DRW_gpencil_populate_datablock(GPENCIL_e_data *e_data, void *vedata, Scene
 		if (gpl->flag & GP_LAYER_HIDE)
 			continue;
 
+		/* don't draw layer if render (F12) and the view layer is not equal */
+		if ((!DRW_state_is_opengl_render()) && (stl->storage->is_render)) {
+			if (gpl->view_layer != NULL) {
+				/* the view layer must exist otherwise the filter is ignored */
+				ViewLayer *view = BLI_findstring(&scene->view_layers, gpl->view_layer, offsetof(ViewLayer, name));
+				if (view != NULL) {
+					if (gpl->flag & GP_LAYER_INVERT_VIEWLAYER) {
+						if (STREQ(gpl->view_layer, draw_ctx->view_layer->name)) {
+							continue;
+						}
+					}
+					else {
+						if (!STREQ(gpl->view_layer, draw_ctx->view_layer->name)) {
+							continue;
+						}
+					}
+				}
+			}
+		}
+
 		bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, CFRA, 0);
 		if (gpf == NULL)
 			continue;
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index 7db4da670d9..cb06fb9f630 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -285,6 +285,7 @@ typedef struct bGPDlayer {
 	int onion_flag;         /* Per-layer onion-skinning flags, to overide datablock settings (eGPDlayer_OnionFlag) */
 	float onion_factor;     /* onion alpha factor change */
 	
+	char view_layer[64];    /* optional view layer name for filter for render (F12) */
 	
 	struct GHash *derived_data;     /* runtime data created by modifiers */
 } bGPDlayer;
@@ -306,6 +307,8 @@ typedef enum eGPDlayer_Flag {
 	GP_LAYER_FRAMELOCK		= (1 << 6),
 	/* don't render xray (which is default) */
 	GP_LAYER_NO_XRAY		= (1 << 7),
+	/* inverse view layer filter */
+	GP_LAYER_INVERT_VIEWLAYER = (1 << 8),
 	/* "volumetric" strokes */
 	GP_LAYER_VOLUMETRIC		= (1 << 10),
 	/* Unlock color */
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index 8c77813c25e..9e63533eb9c 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -1231,6 +1231,18 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
 		"When draw new strokes in 3D view, use last stroke origin, as new stroke origin");
 	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
 	
+	/* Render View Layer */
+	prop = RNA_def_property(srna, "view_layer", PROP_STRING, PROP_NONE);
+	RNA_def_property_ui_text(prop, "View Layer", 
+		"Include this layer only in this view layer when render (empty to include in all view layers)");
+	RNA_def_struct_name_property(srna, prop);
+	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
+	prop = RNA_def_property(srna, "invert_view_layer", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_INVERT_VIEWLAYER);
+	RNA_def_property_ui_text(prop, "Invert", "Invert view layer filter");
+	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
 	/* Flags */
 	prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_HIDE);



More information about the Bf-blender-cvs mailing list