Animation Editors: DopeSheet filtering option to only include Objects that are member...
authorJoshua Leung <aligorith@gmail.com>
Sat, 23 Jan 2010 03:57:11 +0000 (03:57 +0000)
committerJoshua Leung <aligorith@gmail.com>
Sat, 23 Jan 2010 03:57:11 +0000 (03:57 +0000)
Between the datablock filtering options and the auto-snapping menu in the headers of Animation Editors, there is a new toggle for enabling this new feature (only when there are groups in the scene). Enabling this, a field to enter/select a group in the scene to filter with, will appear beside it.

This feature has been added to make it easier to manage animating multiple character shots in Durian.
By assigning the rigs of several bandits to a single group, or Sintel and her staff to another group, or Sintel and the guardians to another group, and so on, it is possible to filter the animation data shown in the editors to a useful subset of the total motion in the scene.

This makes it easier to retime or edit the motions of one set of characters and their props without affecting the motions of other no-related objects. The downside is that there is a bit more setup work required upfront, but that's probably a small price to pay for some groupings that may be useful in other ways too later (perhaps for compositing or lighting work).

source/blender/blenloader/intern/readfile.c
source/blender/editors/animation/anim_filter.c
source/blender/editors/interface/interface_templates.c
source/blender/makesdna/DNA_action_types.h
source/blender/makesrna/intern/rna_action.c

index 7ba17ce..b10c13e 100644 (file)
@@ -4653,9 +4653,12 @@ static void lib_link_screen(FileData *fd, Main *main)
                                        }
                                        else if(sl->spacetype==SPACE_IPO) {
                                                SpaceIpo *sipo= (SpaceIpo *)sl;
+                                               bDopeSheet *ads= sipo->ads;
                                                
-                                               if(sipo->ads)
-                                                       sipo->ads->source= newlibadr(fd, sc->id.lib, sipo->ads->source);
+                                               if (ads) {
+                                                       ads->source= newlibadr(fd, sc->id.lib, ads->source);
+                                                       ads->filter_grp= newlibadr(fd, sc->id.lib, ads->filter_grp);
+                                               }
                                        }
                                        else if(sl->spacetype==SPACE_BUTS) {
                                                SpaceButs *sbuts= (SpaceButs *)sl;
@@ -4686,8 +4689,14 @@ static void lib_link_screen(FileData *fd, Main *main)
                                        }
                                        else if(sl->spacetype==SPACE_ACTION) {
                                                SpaceAction *saction= (SpaceAction *)sl;
+                                               bDopeSheet *ads= &saction->ads;
+                                               
+                                               if (ads) {
+                                                       ads->source= newlibadr(fd, sc->id.lib, ads->source);
+                                                       ads->filter_grp= newlibadr(fd, sc->id.lib, ads->filter_grp);
+                                               }
+                                               
                                                saction->action = newlibadr(fd, sc->id.lib, saction->action);
-                                               saction->ads.source= newlibadr(fd, sc->id.lib, saction->ads.source);
                                        }
                                        else if(sl->spacetype==SPACE_IMAGE) {
                                                SpaceImage *sima= (SpaceImage *)sl;
@@ -4695,7 +4704,13 @@ static void lib_link_screen(FileData *fd, Main *main)
                                                sima->image= newlibadr_us(fd, sc->id.lib, sima->image);
                                        }
                                        else if(sl->spacetype==SPACE_NLA){
-                                               /* SpaceNla *snla= (SpaceNla *)sl;      */
+                                               SpaceNla *snla= (SpaceNla *)sl;
+                                               bDopeSheet *ads= snla->ads;
+                                               
+                                               if (ads) {
+                                                       ads->source= newlibadr(fd, sc->id.lib, ads->source);
+                                                       ads->filter_grp= newlibadr(fd, sc->id.lib, ads->filter_grp);
+                                               }
                                        }
                                        else if(sl->spacetype==SPACE_TEXT) {
                                                SpaceText *st= (SpaceText *)sl;
index 608016e..af6ddca 100644 (file)
@@ -57,7 +57,7 @@
 #include "DNA_camera_types.h"
 #include "DNA_curve_types.h"
 #include "DNA_gpencil_types.h"
-#include "DNA_ipo_types.h"
+#include "DNA_group_types.h"
 #include "DNA_lamp_types.h"
 #include "DNA_lattice_types.h"
 #include "DNA_key_types.h"
@@ -83,6 +83,7 @@
 #include "BKE_fcurve.h"
 #include "BKE_context.h"
 #include "BKE_global.h"
+#include "BKE_group.h"
 #include "BKE_key.h"
 #include "BKE_object.h"
 #include "BKE_material.h"
@@ -1915,6 +1916,15 @@ static int animdata_filter_dopesheet (bAnimContext *ac, ListBase *anim_data, bDo
                                        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 (object_in_group(ob, ads->filter_grp) == 0)
+                                               continue;
+                               }
+                               
                                /* check filters for datatypes */
                                        /* object */
                                actOk= 0;
index f39e69c..dcc5db8 100644 (file)
@@ -115,6 +115,17 @@ void uiTemplateDopeSheetFilter(uiLayout *layout, bContext *C, PointerRNA *ptr)
                uiItemR(row, "", 0, ptr, "display_armature", 0);
        if (mainptr && mainptr->particle.first)
                uiItemR(row, "", 0, ptr, "display_particle", 0);
+       
+       /* group-based filtering (only when groups are available */
+       if (mainptr && mainptr->group.first) {
+               row= uiLayoutRow(layout, 1);
+               
+               uiItemR(row, "", 0, ptr, "only_group_objects", 0);
+               
+               /* if enabled, show the group selection field too */
+               if (RNA_boolean_get(ptr, "only_group_objects"))
+                       uiItemR(row, "", 0, ptr, "filtering_group", 0);
+       }
 }
 
 /********************** Search Callbacks *************************/
index 7141d99..d2eb8f2 100644 (file)
@@ -39,6 +39,7 @@
 
 struct SpaceLink;
 struct Object;
+struct Group;
 
 /* ************************************************ */
 /* Visualisation */
@@ -498,11 +499,13 @@ typedef enum eAction_Flags {
 
 /* Storage for Dopesheet/Grease-Pencil Editor data */
 typedef struct bDopeSheet {
-       ID              *source;                /* currently ID_SCE (for Dopesheet), and ID_SC (for Grease Pencil) */
-       ListBase chanbase;              /* cache for channels (only initialised when pinned) */  // XXX not used!
+       ID              *source;                        /* currently ID_SCE (for Dopesheet), and ID_SC (for Grease Pencil) */
+       ListBase chanbase;                      /* cache for channels (only initialised when pinned) */  // XXX not used!
        
-       int filterflag;                 /* flags to use for filtering data */
-       int flag;                               /* standard flags */
+       struct Group *filter_grp;       /* object group for ADS_FILTER_ONLYOBGROUP filtering option */ 
+       
+       int filterflag;                         /* flags to use for filtering data */
+       int flag;                                       /* standard flags */
 } bDopeSheet;
 
 
@@ -511,15 +514,19 @@ typedef enum eDopeSheet_FilterFlag {
                /* general filtering */
        ADS_FILTER_ONLYSEL                      = (1<<0),       /* only include channels relating to selected data */
        
-               /* assorted general settings */
-       ADS_FILTER_ONLYDRIVERS          = (1<<1),       /* for 'Drivers' editor - TEMPORARY -  only include Driver data from AnimData */
+               /* temporary filters */
+       ADS_FILTER_ONLYDRIVERS          = (1<<1),       /* for 'Drivers' editor - only include Driver data from AnimData */
        ADS_FILTER_ONLYNLA                      = (1<<2),       /* for 'NLA' editor - only include NLA data from AnimData */
-       ADS_FILTER_SELEDIT                      = (1<<3),       /* for Graph Editor - TEMPORARY - used to indicate whether to include a filtering flag or not */
-       ADS_FILTER_SUMMARY                      = (1<<4),       /* for 'DopeSheet' Editor - include 'summary' line */
+       ADS_FILTER_SELEDIT                      = (1<<3),       /* for Graph Editor - used to indicate whether to include a filtering flag or not */
+       
+               /* general filtering 2 */
+       ADS_FILTER_SUMMARY                      = (1<<4),       /* for 'DopeSheet' Editors - include 'summary' line */
+       ADS_FILTER_ONLYOBGROUP          = (1<<5),       /* only the objects in the specified object group get used */
        
                /* datatype-based filtering */
        ADS_FILTER_NOSHAPEKEYS          = (1<<6),
        ADS_FILTER_NOMESH                       = (1<<7),
+       // NOTE: there are a few more spaces for datablock filtering here...
        ADS_FILTER_NOCAM                        = (1<<10),
        ADS_FILTER_NOMAT                        = (1<<11),
        ADS_FILTER_NOLAM                        = (1<<12),
index 57e4007..38facec 100644 (file)
@@ -64,35 +64,60 @@ static void rna_def_dopesheet(BlenderRNA *brna)
 
        srna= RNA_def_struct(brna, "DopeSheet", NULL);
        RNA_def_struct_sdna(srna, "bDopeSheet");
-       RNA_def_struct_ui_text(srna, "DopeSheet", "Storage for Dopesheet/Grease-Pencil Editor data.");
-
+       RNA_def_struct_ui_text(srna, "DopeSheet", "Settings for filtering the channels shown in Animation Editors.");
+       
+       /* Source of DopeSheet data */
        prop= RNA_def_property(srna, "source", PROP_POINTER, PROP_NONE);
        RNA_def_property_struct_type(prop, "ID");
        RNA_def_property_ui_text(prop, "Source", "ID-Block representing source data, currently ID_SCE (for Dopesheet), and ID_SC (for Grease Pencil).");
-
+       
+       /* General Filtering Settings */
        prop= RNA_def_property(srna, "only_selected", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_ONLYSEL);
        RNA_def_property_ui_text(prop, "Only Selected", "Only include channels relating to selected objects and data.");
        RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, 0);
        RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
-
-       prop= RNA_def_property(srna, "only_nla", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_ONLYNLA);
-       RNA_def_property_ui_text(prop, "Only NLA", "Only include NLA data from Animation data.");
+       
+       /* Object Group Filtering Settings */
+       prop= RNA_def_property(srna, "only_group_objects", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_ONLYOBGROUP);
+       RNA_def_property_ui_text(prop, "Only Objects in Group", "Only include channels from Objects in the specified Group.");
+       RNA_def_property_ui_icon(prop, ICON_GROUP, 0);
+       RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
+       
+       prop= RNA_def_property(srna, "filtering_group", PROP_POINTER, PROP_NONE);
+       RNA_def_property_pointer_sdna(prop, NULL, "filter_grp");
+       RNA_def_property_flag(prop, PROP_EDITABLE);
+       RNA_def_property_ui_text(prop, "Filtering Group", "Group that included Object should be a member of.");
+       RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
+       
+       /* NLA Specific Settings */
+       prop= RNA_def_property(srna, "include_missing_nla", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NLA_NOACT);
+       RNA_def_property_ui_text(prop, "Include Missing NLA", "Include Animation Data blocks with no NLA data. (NLA Editor only)");
+       RNA_def_property_ui_icon(prop, ICON_ACTION, 0);
        RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
        
+       /* Summary Settings (DopeSheet editors only) */
        prop= RNA_def_property(srna, "display_summary", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_SUMMARY);
        RNA_def_property_ui_text(prop, "Display Summary", "Display an additional 'summary' line. (DopeSheet Editors only)");
        RNA_def_property_ui_icon(prop, ICON_BORDERMOVE, 0);
        RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
-
+       
+       prop= RNA_def_property(srna, "collapse_summary", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", ADS_FLAG_SUMMARY_COLLAPSED);
+       RNA_def_property_ui_text(prop, "Collapse Summary", "Collapse summary when shown, so all other channels get hidden. (DopeSheet Editors Only)");
+       RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
+       
+       
+       /* General DataType Filtering Settings */
        prop= RNA_def_property(srna, "display_shapekeys", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOSHAPEKEYS);
        RNA_def_property_ui_text(prop, "Display Shapekeys", "Include visualization of ShapeKey related Animation data.");
        RNA_def_property_ui_icon(prop, ICON_SHAPEKEY_DATA, 0);
        RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
-
+       
        prop= RNA_def_property(srna, "display_mesh", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOMESH);
        RNA_def_property_ui_text(prop, "Display Meshes", "Include visualization of Mesh related Animation data.");
@@ -104,71 +129,60 @@ static void rna_def_dopesheet(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Display Camera", "Include visualization of Camera related Animation data.");
        RNA_def_property_ui_icon(prop, ICON_CAMERA_DATA, 0);
        RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
-
+       
        prop= RNA_def_property(srna, "display_material", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOMAT);
        RNA_def_property_ui_text(prop, "Display Material", "Include visualization of Material related Animation data.");
        RNA_def_property_ui_icon(prop, ICON_MATERIAL_DATA, 0);
        RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
-
+       
        prop= RNA_def_property(srna, "display_lamp", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOLAM);
        RNA_def_property_ui_text(prop, "Display Lamp", "Include visualization of Lamp related Animation data.");
        RNA_def_property_ui_icon(prop, ICON_LAMP_DATA, 0);
        RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
-
+       
        prop= RNA_def_property(srna, "display_curve", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOCUR);
        RNA_def_property_ui_text(prop, "Display Curve", "Include visualization of Curve related Animation data.");
        RNA_def_property_ui_icon(prop, ICON_CURVE_DATA, 0);
        RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
-
+       
        prop= RNA_def_property(srna, "display_world", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOWOR);
        RNA_def_property_ui_text(prop, "Display World", "Include visualization of World related Animation data.");
        RNA_def_property_ui_icon(prop, ICON_WORLD_DATA, 0);
        RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
-
+       
        prop= RNA_def_property(srna, "display_scene", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOSCE);
        RNA_def_property_ui_text(prop, "Display Scene", "Include visualization of Scene related Animation data.");
        RNA_def_property_ui_icon(prop, ICON_SCENE_DATA, 0);
        RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
-
+       
        prop= RNA_def_property(srna, "display_particle", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOPART);
        RNA_def_property_ui_text(prop, "Display Particle", "Include visualization of Particle related Animation data.");
        RNA_def_property_ui_icon(prop, ICON_PARTICLE_DATA, 0);
        RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
-
+       
        prop= RNA_def_property(srna, "display_metaball", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOMBA);
        RNA_def_property_ui_text(prop, "Display Metaball", "Include visualization of Metaball related Animation data.");
        RNA_def_property_ui_icon(prop, ICON_META_DATA, 0);
        RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
-
+       
        prop= RNA_def_property(srna, "display_armature", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOARM);
        RNA_def_property_ui_text(prop, "Display Armature", "Include visualization of Armature related Animation data.");
        RNA_def_property_ui_icon(prop, ICON_ARMATURE_DATA, 0);
        RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
-
+       
        prop= RNA_def_property(srna, "display_node", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NONTREE);
        RNA_def_property_ui_text(prop, "Display Node", "Include visualization of Node related Animation data.");
        RNA_def_property_ui_icon(prop, ICON_NODETREE, 0);
        RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
-
-       prop= RNA_def_property(srna, "include_missing_nla", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NLA_NOACT);
-       RNA_def_property_ui_text(prop, "Include Missing NLA", "Include Animation Data blocks with no NLA data. (NLA Editor only)");
-       RNA_def_property_ui_icon(prop, ICON_ACTION, 0);
-       RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
-
-       prop= RNA_def_property(srna, "collapse_summary", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, NULL, "flag", ADS_FLAG_SUMMARY_COLLAPSED);
-       RNA_def_property_ui_text(prop, "Collapse Summary", "Collapse summary when shown, so all other channels get hidden. (DopeSheet Editors Only)");
-       RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN_EDIT, NULL);
 }
 
 static void rna_def_action_group(BlenderRNA *brna)