Graph Editor: Added a filtering option for Drivers mode to only show F-Curves
authorJoshua Leung <aligorith@gmail.com>
Wed, 10 Oct 2012 08:46:07 +0000 (08:46 +0000)
committerJoshua Leung <aligorith@gmail.com>
Wed, 10 Oct 2012 08:46:07 +0000 (08:46 +0000)
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.

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

index 8e955338480aefe5278428f6830737faade79da5..8a47a631e827fa2e151968561c928e5acd16a0f8 100644 (file)
@@ -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)
index 8b0593d48ac0a356a27972c2d2e186d079f52b9e..d913779a883d2c67b30f68c6a4c784075520fdcf 100644 (file)
@@ -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;
                                        }
index d75c601982566d4d5a5947c9925cc0d92edec313..d8d1ad784510faee60c00d15cbde4ea3e5f0a066 100644 (file)
@@ -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)
index 00a257ab4f956d1dadb1ec74242b8e9f9f4411e6..f08b9084b3cdcd674cdae284c250921b793e2349 100644 (file)
@@ -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);