Graph Editor: Added a filtering option for Drivers mode to only show F-Curves

with errors

This filtering option is useful when rigging and you want to figure out if any
of your drivers are not functioning, and/or which one(s) are not, so that you
can go through fixing them. It saves you from having to check on each one
individually, or going into the console to try to infer which ones are not
working.
This commit is contained in:
Joshua Leung 2012-10-10 08:46:07 +00:00
parent 89969a07f0
commit cc8c0d89e3
4 changed files with 40 additions and 0 deletions

@ -29,6 +29,7 @@ from bpy.types import Header, Menu
def dopesheet_filter(layout, context, genericFiltersOnly=False):
dopesheet = context.space_data.dopesheet
is_nla = context.area.type == 'NLA_EDITOR'
is_drivers = (context.area.type == 'GRAPH_EDITOR' and context.space_data.mode == 'DRIVERS')
row = layout.row(align=True)
row.prop(dopesheet, "show_only_selected", text="")
@ -37,6 +38,9 @@ def dopesheet_filter(layout, context, genericFiltersOnly=False):
if is_nla:
row.prop(dopesheet, "show_missing_nla", text="")
if is_drivers:
row.prop(dopesheet, "show_only_errors", text="")
if not genericFiltersOnly:
if bpy.data.groups:
row = layout.row(align=True)

@ -980,6 +980,27 @@ static short skip_fcurve_with_name(bDopeSheet *ads, FCurve *fcu, ID *owner_id)
return 1;
}
/* Check if F-Curve has errors and/or is disabled
* > returns: (bool) True if F-Curve has errors/is disabled
*/
static short fcurve_has_errors(FCurve *fcu)
{
/* F-Curve disabled - path eval error */
if (fcu->flag & FCURVE_DISABLED) {
return 1;
}
/* driver? */
if (fcu->driver) {
/* for now, just check if the entire thing got disabled... */
if (fcu->driver->flag & DRIVER_FLAG_INVALID)
return 1;
}
/* no errors found */
return 0;
}
/* find the next F-Curve that is usable for inclusion */
static FCurve *animfilter_fcurve_next(bDopeSheet *ads, FCurve *first, bActionGroup *grp, int filter_mode, ID *owner_id)
{
@ -1018,6 +1039,13 @@ static FCurve *animfilter_fcurve_next(bDopeSheet *ads, FCurve *first, bActionGro
continue;
}
/* error-based filtering... */
if ((ads) && (ads->filterflag & ADS_FILTER_ONLY_ERRORS)) {
/* skip if no errors... */
if (fcurve_has_errors(fcu) == 0)
continue;
}
/* this F-Curve can be used, so return it */
return fcu;
}

@ -563,6 +563,7 @@ typedef enum eDopeSheet_FilterFlag {
/* general filtering 3 */
ADS_FILTER_INCL_HIDDEN = (1 << 26), /* include 'hidden' channels too (i.e. those from hidden Objects/Bones) */
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 */
/* 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)

@ -287,6 +287,13 @@ static void rna_def_dopesheet(BlenderRNA *brna)
RNA_def_property_ui_icon(prop, ICON_GHOST_ENABLED, 0);
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
/* Debug Filtering Settings */
prop = RNA_def_property(srna, "show_only_errors", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_ONLY_ERRORS);
RNA_def_property_ui_text(prop, "Show Errors", "Only include F-Curves and Drivers that are disabled or have errors");
RNA_def_property_ui_icon(prop, ICON_HELP, 0); // XXX: this doesn't quite fit?
RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
/* Object Group Filtering Settings */
prop = RNA_def_property(srna, "show_only_group_objects", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_ONLYOBGROUP);