Merge with -r 22620:23107.
[blender.git] / source / blender / editors / animation / anim_filter.c
index 5970cf481ac2d9bb64e0387de5a42ace4294b127..55fb1ccace05006e7535040a369fa36b51ddcc30 100644 (file)
@@ -62,6 +62,7 @@
 #include "DNA_key_types.h"
 #include "DNA_material_types.h"
 #include "DNA_mesh_types.h"
+#include "DNA_meta_types.h"
 #include "DNA_object_types.h"
 #include "DNA_particle_types.h"
 #include "DNA_space_types.h"
@@ -373,27 +374,29 @@ short ANIM_animdata_get_context (const bContext *C, bAnimContext *ac)
  */
 #define ANIMDATA_FILTER_CASES(id, adtOk, nlaOk, driversOk, keysOk) \
        {\
-               if (filter_mode & ANIMFILTER_ANIMDATA) {\
-                       if ((id)->adt) {\
-                               adtOk\
-                       }\
-               }\
-               else if (ads->filterflag & ADS_FILTER_ONLYNLA) {\
-                       if (ANIMDATA_HAS_NLA(id)) {\
-                               nlaOk\
-                       }\
-                       else if (!(ads->filterflag & ADS_FILTER_NLA_NOACT) && ANIMDATA_HAS_KEYS(id)) {\
-                               nlaOk\
-                       }\
-               }\
-               else if (ads->filterflag & ADS_FILTER_ONLYDRIVERS) {\
-                       if (ANIMDATA_HAS_DRIVERS(id)) {\
-                               driversOk\
-                       }\
-               }\
-               else {\
-                       if (ANIMDATA_HAS_KEYS(id)) {\
-                               keysOk\
+               if ((id)->adt) {\
+                       if (!(filter_mode & ANIMFILTER_CURVEVISIBLE) || !((id)->adt->flag & ADT_CURVES_NOT_VISIBLE)) {\
+                               if (filter_mode & ANIMFILTER_ANIMDATA) {\
+                                       adtOk\
+                               }\
+                               else if (ads->filterflag & ADS_FILTER_ONLYNLA) {\
+                                       if (ANIMDATA_HAS_NLA(id)) {\
+                                               nlaOk\
+                                       }\
+                                       else if (!(ads->filterflag & ADS_FILTER_NLA_NOACT) && ANIMDATA_HAS_KEYS(id)) {\
+                                               nlaOk\
+                                       }\
+                               }\
+                               else if (ads->filterflag & ADS_FILTER_ONLYDRIVERS) {\
+                                       if (ANIMDATA_HAS_DRIVERS(id)) {\
+                                               driversOk\
+                                       }\
+                               }\
+                               else {\
+                                       if (ANIMDATA_HAS_KEYS(id)) {\
+                                               keysOk\
+                                       }\
+                               }\
                        }\
                }\
        }
@@ -856,71 +859,6 @@ static int animdata_filter_nla (ListBase *anim_data, AnimData *adt, int filter_m
        /* return the number of items added to the list */
        return items;
 }
-
-static int animdata_filter_shapekey (ListBase *anim_data, Key *key, int filter_mode, void *owner, short ownertype, ID *owner_id)
-{
-       bAnimListElem *ale;
-       KeyBlock *kb;
-       //FCurve *fcu;
-       int i, items=0;
-       
-       /* are we filtering for display or editing */
-       if (filter_mode & ANIMFILTER_CHANNELS) {
-               /* for display - loop over shapekeys, adding ipo-curve references where needed */
-               kb= key->block.first;
-               
-               /* loop through possible shapekeys, manually creating entries */
-               for (i= 1; i < key->totkey; i++) {
-                       ale= MEM_callocN(sizeof(bAnimListElem), "bAnimListElem");
-                       kb = kb->next; /* do this even on the first try, as the first is 'Basis' (which doesn't get included) */
-                       
-                       ale->data= kb;
-                       ale->type= ANIMTYPE_SHAPEKEY; /* 'abused' usage of this type */
-                       ale->owner= key;
-                       ale->ownertype= ANIMTYPE_SHAPEKEY;
-                       ale->datatype= ALE_NONE;
-                       ale->index = i;
-                       
-#if 0 // XXX fixme... old system
-                       if (key->ipo) {
-                               for (icu= key->ipo->curve.first; icu; icu=icu->next) {
-                                       if (icu->adrcode == i) {
-                                               ale->key_data= icu;
-                                               ale->datatype= ALE_ICU;
-                                               break;
-                                       }
-                               }
-                       }
-#endif // XXX fixme... old system
-                       
-                       ale->id= owner_id;
-                       
-                       BLI_addtail(anim_data, ale);
-                       items++;
-               }
-       }
-       else {
-#if 0 // XXX fixme... old system
-               /* loop over ipo curves if present - for editing */
-               if (key->ipo) {
-                       if (filter_mode & ANIMFILTER_IPOKEYS) {
-                               ale= make_new_animlistelem(key->ipo, ANIMTYPE_IPO, key, ANIMTYPE_SHAPEKEY);
-                               if (ale) {
-                                       if (owned) ale->id= owner;
-                                       BLI_addtail(anim_data, ale);
-                                       items++;
-                               }
-                       }
-                       else {
-                               items += animdata_filter_ipocurves(anim_data, key->ipo, filter_mode, key, ANIMTYPE_SHAPEKEY, (owned)?(owner):(NULL));
-                       }
-               }
-#endif // XXX fixme... old system
-       }
-       
-       /* return the number of items added to the list */
-       return items;
-}
  
 #if 0
 // FIXME: switch this to use the bDopeSheet...
@@ -947,7 +885,7 @@ static int animdata_filter_gpencil (ListBase *anim_data, bScreen *sc, int filter
                for (sa= sc->areabase.first; sa; sa= sa->next) {
                        /* try to get gp data */
                        // XXX need to put back grease pencil api...
-                       gpd= gpencil_data_getactive(sa);
+                       gpd= gpencil_data_get_active(sa);
                        if (gpd == NULL) continue;
                        
                        /* add gpd as channel too (if for drawing, and it has layers) */
@@ -1155,6 +1093,14 @@ static int animdata_filter_dopesheet_obdata (ListBase *anim_data, bDopeSheet *ad
                        expanded= FILTER_CUR_OBJD(cu);
                }
                        break;
+               case OB_MBALL: /* ------- MetaBall ---------- */
+               {
+                       MetaBall *mb= (MetaBall *)ob->data;
+                       
+                       type= ANIMTYPE_DSMBALL;
+                       expanded= FILTER_MBALL_OBJD(mb);
+               }
+                       break;
        }
        
        /* special exception for drivers instead of action */
@@ -1272,7 +1218,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B
                                
                                /* add channels */
                                if (FILTER_SKE_OBJD(key) || (filter_mode & ANIMFILTER_CURVESONLY)) {
-                                       items += animdata_filter_shapekey(anim_data, key, filter_mode, ob, ANIMTYPE_OBJECT, (ID *)ob);
+                                       items += animdata_filter_fcurves(anim_data, adt->drivers.first, NULL, key, ANIMTYPE_DSSKEY, filter_mode, (ID *)key);
                                }
                        },
                        { /* action (keyframes) */
@@ -1287,7 +1233,7 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B
                                
                                /* add channels */
                                if (FILTER_SKE_OBJD(key) || (filter_mode & ANIMFILTER_CURVESONLY)) {
-                                       items += animdata_filter_shapekey(anim_data, key, filter_mode, ob, ANIMTYPE_OBJECT, (ID *)ob);
+                                       items += animdata_filter_action(anim_data, adt->action, filter_mode, key, ANIMTYPE_DSSKEY, (ID *)key); 
                                }
                        }
                );
@@ -1338,12 +1284,25 @@ static int animdata_filter_dopesheet_ob (ListBase *anim_data, bDopeSheet *ads, B
                        }
                }
                        break;
+               case OB_MBALL: /* ------- MetaBall ---------- */
+               {
+                       MetaBall *mb= (MetaBall *)ob->data;
+                       
+                       if ((ads->filterflag & ADS_FILTER_NOMBA) == 0) {
+                               ANIMDATA_FILTER_CASES(mb,
+                                       { /* AnimData blocks - do nothing... */ },
+                                       obdata_ok= 1;,
+                                       obdata_ok= 1;,
+                                       obdata_ok= 1;)
+                       }
+               }
+                       break;
        }
        if (obdata_ok) 
                items += animdata_filter_dopesheet_obdata(anim_data, ads, base, filter_mode);
 
        /* particles */
-       if(ob->particlesystem.first && !(ads->filterflag & ADS_FILTER_NOPART))
+       if (ob->particlesystem.first && !(ads->filterflag & ADS_FILTER_NOPART))
                items += animdata_filter_dopesheet_particles(anim_data, ads, base, filter_mode);
        
        /* return the number of items added to the list */
@@ -1508,6 +1467,14 @@ static int animdata_filter_dopesheet (ListBase *anim_data, bDopeSheet *ads, int
                                worOk= !(ads->filterflag & ADS_FILTER_NOWOR);)
                }
                
+               /* if only F-Curves with visible flags set can be shown, check that 
+                * datablocks haven't been set to invisible 
+                */
+               if (filter_mode & ANIMFILTER_CURVEVISIBLE) {
+                       if ((sce->adt) && (sce->adt->flag & ADT_CURVES_NOT_VISIBLE))
+                               sceOk= worOk= 0;
+               }
+               
                /* check if not all bad (i.e. so there is something to show) */
                if ( !(!sceOk && !worOk) ) {
                        /* add scene data to the list of filtered channels */
@@ -1524,7 +1491,7 @@ static int animdata_filter_dopesheet (ListBase *anim_data, bDopeSheet *ads, int
                        Key *key= ob_get_key(ob);
                        short actOk=1, keyOk=1, dataOk=1, matOk=1, partOk=1;
                        
-                       /* firstly, check if object can be included, by the following fanimors:
+                       /* firstly, check if object can be included, by the following factors:
                         *      - if only visible, must check for layer and also viewport visibility
                         *      - if only selected, must check if object is selected 
                         *      - there must be animation data to edit
@@ -1538,6 +1505,14 @@ static int animdata_filter_dopesheet (ListBase *anim_data, bDopeSheet *ads, int
                                if (ob->restrictflag & OB_RESTRICT_VIEW) continue;
                        }
                        
+                       /* if only F-Curves with visible flags set can be shown, check that 
+                        * datablock hasn't been set to invisible 
+                        */
+                       if (filter_mode & ANIMFILTER_CURVEVISIBLE) {
+                               if ((ob->adt) && (ob->adt->flag & ADT_CURVES_NOT_VISIBLE))
+                                       continue;
+                       }
+                       
                        /* additionally, dopesheet filtering also affects what objects to consider */
                        if (ads->filterflag) {
                                /* check selection and object type filters */
@@ -1660,6 +1635,23 @@ static int animdata_filter_dopesheet (ListBase *anim_data, bDopeSheet *ads, int
                                                        dataOk= !(ads->filterflag & ADS_FILTER_NOCUR);)
                                        }
                                                break;
+                                       case OB_MBALL: /* ------- MetaBall ---------- */
+                                       {
+                                               MetaBall *mb= (MetaBall *)ob->data;
+                                               dataOk= 0;
+                                               ANIMDATA_FILTER_CASES(mb, 
+                                                       if ((ads->filterflag & ADS_FILTER_NOMBA)==0) {
+                                                               /* for the special AnimData blocks only case, we only need to add
+                                                                * the block if it is valid... then other cases just get skipped (hence ok=0)
+                                                                */
+                                                               ANIMDATA_ADD_ANIMDATA(mb);
+                                                               dataOk=0;
+                                                       },
+                                                       dataOk= !(ads->filterflag & ADS_FILTER_NOMBA);, 
+                                                       dataOk= !(ads->filterflag & ADS_FILTER_NOMBA);, 
+                                                       dataOk= !(ads->filterflag & ADS_FILTER_NOMBA);)
+                                       }
+                                               break;
                                        default: /* --- other --- */
                                                dataOk= 0;
                                                break;
@@ -1736,6 +1728,12 @@ static int animdata_filter_dopesheet (ListBase *anim_data, bDopeSheet *ads, int
                                                dataOk= ANIMDATA_HAS_KEYS(cu);  
                                        }
                                                break;
+                                       case OB_MBALL: /* -------- Metas ---------- */
+                                       {
+                                               MetaBall *mb= (MetaBall *)ob->data;
+                                               dataOk= ANIMDATA_HAS_KEYS(mb);  
+                                       }
+                                               break;
                                        default: /* --- other --- */
                                                dataOk= 0;
                                                break;
@@ -1792,7 +1790,7 @@ int ANIM_animdata_filter (bAnimContext *ac, ListBase *anim_data, int filter_mode
                                break;
                                
                        case ANIMCONT_SHAPEKEY:
-                               items= animdata_filter_shapekey(anim_data, data, filter_mode, NULL, ANIMTYPE_NONE, (ID *)obact);
+                               //items= animdata_filter_shapekey(anim_data, data, filter_mode, NULL, ANIMTYPE_NONE, (ID *)obact);
                                break;
                                
                        case ANIMCONT_GPENCIL: