[Bf-blender-cvs] [34d4c7c] GPencil_Editing_Stage3: GPencil Dopesheet: Filtering option to only include GPencil layers related to the active scene

Joshua Leung noreply at git.blender.org
Thu Dec 3 10:08:02 CET 2015


Commit: 34d4c7c85f58e5891e6c12a9b4895dc36ea0227d
Author: Joshua Leung
Date:   Thu Dec 3 21:59:24 2015 +1300
Branches: GPencil_Editing_Stage3
https://developer.blender.org/rB34d4c7c85f58e5891e6c12a9b4895dc36ea0227d

GPencil Dopesheet: Filtering option to only include GPencil layers related to the active scene

As requested by the Caminandes team, in the "Grease Pencil" mode of the dopesheet,
it is now possible to view only the Grease Pencil blocks+layers which come from the
active scene and/or the objects in that scene. This is useful when working with
multiple scenes, or when there are many other GPencil datablocks in the file for
various editors that aren't visible.

To use, enable the 'Active Only' toggle with the scene icon (located beside the
Summary toggle). By default, this is not enabled, so that backwards comptability
with old files is not affected (i.e. users are less likely to why they are no longer
able to see keyframes that would've previously been easily visible).

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

M	release/scripts/startup/bl_ui/space_dopesheet.py
M	source/blender/editors/animation/anim_filter.c
M	source/blender/makesdna/DNA_action_types.h
M	source/blender/makesrna/intern/rna_action.c

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

diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py
index a73908a..4777525 100644
--- a/release/scripts/startup/bl_ui/space_dopesheet.py
+++ b/release/scripts/startup/bl_ui/space_dopesheet.py
@@ -140,6 +140,14 @@ class DOPESHEET_HT_header(Header):
             dopesheet_filter(layout, context, genericFiltersOnly=True)
         elif st.mode == 'GPENCIL':
             row = layout.row(align=True)
+            row.prop(st.dopesheet, "show_gpencil_3d_only", text="Active Only")
+
+            if st.dopesheet.show_gpencil_3d_only:
+                row = layout.row(align=True)
+                row.prop(st.dopesheet, "show_only_selected", text="")
+                row.prop(st.dopesheet, "show_hidden", text="")
+
+            row = layout.row(align=True)
             row.prop(st.dopesheet, "use_filter_text", text="")
             if st.dopesheet.use_filter_text:
                 row.prop(st.dopesheet, "filter_text", text="")
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index e5837a4..51b5a36 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -1582,18 +1582,73 @@ static size_t animdata_filter_gpencil_data(ListBase *anim_data, bDopeSheet *ads,
 static size_t animdata_filter_gpencil(bAnimContext *ac, ListBase *anim_data, void *UNUSED(data), int filter_mode)
 {
 	bDopeSheet *ads = ac->ads;
-	bGPdata *gpd;
 	size_t items = 0;
 	
-	/* for now, grab grease pencil datablocks directly from main */
-	// XXX: this is not good...
-	for (gpd = G.main->gpencil.first; gpd; gpd = gpd->id.next) {
-		/* only show if gpd is used by something... */
-		if (ID_REAL_USERS(gpd) < 1)
-			continue;
+	if (ads->filterflag & ADS_FILTER_GP_3DONLY) {
+		Scene *scene = (Scene *)ads->source;
+		Base *base;
+		
+		/* Active scene's GPencil block first - No parent item needed... */
+		if (scene->gpd) {
+			items += animdata_filter_gpencil_data(anim_data, ads, scene->gpd, filter_mode);
+		}
 		
-		/* add GP frames from this datablock */
-		items += animdata_filter_gpencil_data(anim_data, ads, gpd, filter_mode);
+		/* Objects in the scene */
+		for (base = scene->base.first; base; base = base->next) {
+			/* Only consider this object if it has got some GP data (saving on all the other tests) */
+			if (base->object && base->object->gpd) {
+				Object *ob = base->object;
+				
+				/* firstly, check if object can be included, by the following factors:
+				 *	- if only visible, must check for layer and also viewport visibility
+				 *		--> while tools may demand only visible, user setting takes priority
+				 *			as user option controls whether sets of channels get included while
+				 *			tool-flag takes into account collapsed/open channels too
+				 *	- if only selected, must check if object is selected 
+				 *	- there must be animation data to edit (this is done recursively as we 
+				 *	  try to add the channels)
+				 */
+				if ((filter_mode & ANIMFILTER_DATA_VISIBLE) && !(ads->filterflag & ADS_FILTER_INCL_HIDDEN)) {
+					/* layer visibility - we check both object and base, since these may not be in sync yet */
+					if ((scene->lay & (ob->lay | base->lay)) == 0) continue;
+					
+					/* outliner restrict-flag */
+					if (ob->restrictflag & OB_RESTRICT_VIEW) continue;
+				}
+				
+				/* check selection and object type filters */
+				if ( (ads->filterflag & ADS_FILTER_ONLYSEL) && !((base->flag & SELECT) /*|| (base == scene->basact)*/) ) {
+					/* only selected should be shown */
+					continue;
+				}
+				
+				/* check if object belongs to the filtering group if option to filter 
+				 * objects by the grouped status is on
+				 *	- used to ease the process of doing multiple-character choreographies
+				 */
+				if (ads->filterflag & ADS_FILTER_ONLYOBGROUP) {
+					if (BKE_group_object_exists(ads->filter_grp, ob) == 0)
+						continue;
+				}
+				
+				/* finally, include this object's grease pencil datablock */
+				/* XXX: Should we store these under expanders per item? */
+				items += animdata_filter_gpencil_data(anim_data, ads, ob->gpd, filter_mode);
+			}
+		}
+	}
+	else {
+		bGPdata *gpd;
+		
+		/* Grab all Grease Pencil datablocks directly from main, but only those that seem to be useful somewhere */
+		for (gpd = G.main->gpencil.first; gpd; gpd = gpd->id.next) {
+			/* only show if gpd is used by something... */
+			if (ID_REAL_USERS(gpd) < 1)
+				continue;
+			
+			/* add GP frames from this datablock */
+			items += animdata_filter_gpencil_data(anim_data, ads, gpd, filter_mode);
+		}
 	}
 	
 	/* return the number of items added to the list */
diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h
index d574694..9c17a1f 100644
--- a/source/blender/makesdna/DNA_action_types.h
+++ b/source/blender/makesdna/DNA_action_types.h
@@ -596,6 +596,9 @@ typedef enum eDopeSheet_FilterFlag {
 	ADS_FILTER_BY_FCU_NAME      = (1 << 27),  /* for F-Curves, filter by the displayed name (i.e. to isolate all Location curves only) */
 	ADS_FILTER_ONLY_ERRORS		= (1 << 28),  /* show only F-Curves which are disabled/have errors - for debugging drivers */
 	
+	/* GPencil Mode */
+	ADS_FILTER_GP_3DONLY        = (1 << 29),  /* GP Mode - Only show datablocks used in the scene */
+	
 	/* combination filters (some only used at runtime) */
 	ADS_FILTER_NOOBDATA = (ADS_FILTER_NOCAM | ADS_FILTER_NOMAT | ADS_FILTER_NOLAM | ADS_FILTER_NOCUR | ADS_FILTER_NOPART | ADS_FILTER_NOARM | ADS_FILTER_NOSPK | ADS_FILTER_NOMODIFIERS)
 } eDopeSheet_FilterFlag;	
diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c
index 9ae9f11..5d90b9f 100644
--- a/source/blender/makesrna/intern/rna_action.c
+++ b/source/blender/makesrna/intern/rna_action.c
@@ -495,6 +495,14 @@ static void rna_def_dopesheet(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Display Grease Pencil", "Include visualization of Grease Pencil related animation data and frames");
 	RNA_def_property_ui_icon(prop, ICON_GREASEPENCIL, 0);
 	RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
+	
+	/* GPencil Mode Settings */
+	prop = RNA_def_property(srna, "show_gpencil_3d_only", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_GP_3DONLY);
+	RNA_def_property_ui_text(prop, "Active Scene Only", 
+	                         "Only show Grease Pencil datablocks used as part of the active scene");
+	RNA_def_property_ui_icon(prop, ICON_SCENE_DATA, 0);
+	RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
 }
 
 static void rna_def_action_group(BlenderRNA *brna)




More information about the Bf-blender-cvs mailing list