Revision: 19299
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19299
Author:   aligorith
Date:     2009-03-15 11:39:02 +0100 (Sun, 15 Mar 2009)

Log Message:
-----------
F-Curve Modifiers: Groundwork for getting these working

- Completed cleaning up the drawing code so that F-Curves with modifiers now 
get drawn to reflect this.
- Added a temporary operator to add modifiers (hotkey Ctrl-Shift-M) 

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenkernel/BKE_fcurve.h
    branches/blender2.5/blender/source/blender/blenkernel/intern/fcurve.c
    branches/blender2.5/blender/source/blender/editors/animation/anim_filter.c
    branches/blender2.5/blender/source/blender/editors/include/ED_anim_api.h
    
branches/blender2.5/blender/source/blender/editors/space_graph/graph_buttons.c
    branches/blender2.5/blender/source/blender/editors/space_graph/graph_draw.c
    branches/blender2.5/blender/source/blender/editors/space_graph/graph_edit.c
    
branches/blender2.5/blender/source/blender/editors/space_graph/graph_intern.h
    branches/blender2.5/blender/source/blender/editors/space_graph/graph_ops.c
    branches/blender2.5/blender/source/blender/editors/space_graph/space_graph.c

Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_fcurve.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_fcurve.h  
2009-03-15 08:58:33 UTC (rev 19298)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_fcurve.h  
2009-03-15 10:39:02 UTC (rev 19299)
@@ -44,6 +44,8 @@
        /* admin/ident */
        short type;                             /* FMODIFIER_TYPE_### */
        short size;                             /* size in bytes of the struct 
*/
+       short acttype;                  /* eFMI_Action_Types */
+       short requires;                 /* eFMI_Requirement_Flags */
        char name[32];                  /* name of modifier in interface */
        char structName[32];    /* name of struct for SDNA */
        
@@ -60,13 +62,37 @@
        void (*evaluate_modifier)(struct FCurve *fcu, struct FModifier *fcm, 
float *cvalue, float evaltime);
 } FModifierTypeInfo;
 
+/* Values which describe the behaviour of a FModifier Type */
+enum {
+               /* modifier only modifies values outside of data range */
+       FMI_TYPE_EXTRAPOLATION = 0,
+               /* modifier leaves data-points alone, but adjusts the 
interpolation between and around them */
+       FMI_TYPE_INTERPOLATION,
+               /* modifier only modifies the values of points (but times stay 
the same) */
+       FMI_TYPE_REPLACE_VALUES,
+               /* modifier generates a curve regardless of what came before */
+       FMI_TYPE_GENERATE_CURVE,
+} eFMI_Action_Types;
+
+/* Flags for the requirements of a FModifier Type */
+enum {
+               /* modifier requires original data-points (kindof beats the 
purpose of a modifier stack?) */
+       FMI_REQUIRES_ORIGINAL_DATA              = (1<<0),
+               /* modifier doesn't require on any preceeding data (i.e. it 
will generate a curve). 
+                * Use in conjunction with FMI_TYPE_GENRATE_CURVE 
+                */
+       FMI_REQUIRES_NOTHING                    = (1<<1),
+               /* refer to modifier instance */
+       FMI_REQUIRES_RUNTIME_CHECK              = (1<<2),
+} eFMI_Requirement_Flags;
+
 /* Function Prototypes for FModifierTypeInfo's */
 FModifierTypeInfo *fmodifier_get_typeinfo(struct FModifier *fcm);
 FModifierTypeInfo *get_fmodifier_typeinfo(int type);
 
 /* ---------------------- */
 
-// TODO... general API here..
+struct FModifier *fcurve_active_modifier(struct FCurve *fcu);
 struct FModifier *fcurve_add_modifier(struct FCurve *fcu, int type);
 void fcurve_copy_modifiers(ListBase *dst, ListBase *src);
 void fcurve_remove_modifier(struct FCurve *fcu, struct FModifier *fcm);

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/fcurve.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/fcurve.c       
2009-03-15 08:58:33 UTC (rev 19298)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/fcurve.c       
2009-03-15 10:39:02 UTC (rev 19299)
@@ -1105,6 +1105,8 @@
 static FModifierTypeInfo FMI_MODNAME = {
        FMODIFIER_TYPE_MODNAME, /* type */
        sizeof(FMod_ModName), /* size */
+       FMI_TYPE_SOME_ACTION, /* action type */
+       FMI_REQUIRES_SOME_REQUIREMENT, /* requirements */
        "Modifier Name", /* name */
        "FMod_ModName", /* struct name */
        fcm_modname_free, /* free data */
@@ -1155,6 +1157,7 @@
        
        /* behaviour depends on mode (NOTE: we don't need to do anything...) */
        switch (data->mode) {
+               // TODO: implement factorised polynomial too
                case FCM_GENERATOR_POLYNOMIAL: /* polynomial expression */
                {
                        /* we overwrite cvalue with the sum of the polynomial */
@@ -1184,6 +1187,8 @@
 static FModifierTypeInfo FMI_GENERATOR = {
        FMODIFIER_TYPE_GENERATOR, /* type */
        sizeof(FMod_Generator), /* size */
+       FMI_TYPE_GENERATE_CURVE, /* action type */
+       FMI_REQUIRES_NOTHING, /* requirements */
        "Generator", /* name */
        "FMod_Generator", /* struct name */
        fcm_generator_free, /* free data */
@@ -1266,6 +1271,8 @@
 static FModifierTypeInfo FMI_ENVELOPE = {
        FMODIFIER_TYPE_ENVELOPE, /* type */
        sizeof(FMod_Envelope), /* size */
+       FMI_TYPE_REPLACE_VALUES, /* action type */
+       0, /* requirements */
        "Envelope", /* name */
        "FMod_Envelope", /* struct name */
        fcm_envelope_free, /* free data */
@@ -1399,6 +1406,8 @@
 static FModifierTypeInfo FMI_CYCLES = {
        FMODIFIER_TYPE_CYCLES, /* type */
        sizeof(FMod_Cycles), /* size */
+       FMI_TYPE_EXTRAPOLATION, /* action type */
+       FMI_REQUIRES_ORIGINAL_DATA, /* requirements */
        "Cycles", /* name */
        "FMod_Cycles", /* struct name */
        NULL, /* free data */
@@ -1413,6 +1422,8 @@
 static FModifierTypeInfo FMI_NOISE = {
        FMODIFIER_TYPE_NOISE, /* type */
        sizeof(FMod_Noise), /* size */
+       FMI_TYPE_REPLACE_VALUES, /* action type */
+       0, /* requirements */
        "Noise", /* name */
        "FMod_Noise", /* struct name */
        NULL, /* free data */
@@ -1428,6 +1439,8 @@
 static FModifierTypeInfo FMI_FILTER = {
        FMODIFIER_TYPE_FILTER, /* type */
        sizeof(FMod_Filter), /* size */
+       FMI_TYPE_REPLACE_VALUES, /* action type */
+       0, /* requirements */
        "Filter", /* name */
        "FMod_Filter", /* struct name */
        NULL, /* free data */
@@ -1480,6 +1493,8 @@
 static FModifierTypeInfo FMI_PYTHON = {
        FMODIFIER_TYPE_PYTHON, /* type */
        sizeof(FMod_Python), /* size */
+       FMI_TYPE_GENERATE_CURVE, /* action type */
+       FMI_REQUIRES_RUNTIME_CHECK, /* requirements */
        "Python", /* name */
        "FMod_Python", /* struct name */
        fcm_python_free, /* free data */
@@ -1499,7 +1514,8 @@
 static short FMI_INIT= 1; /* when non-zero, the list needs to be updated */
 
 /* This function only gets called when FMI_INIT is non-zero */
-static void fmods_init_typeinfo () {
+static void fmods_init_typeinfo () 
+{
        fmodifiersTypeInfo[0]=  NULL;                                   /* 
'Null' F-Curve Modifier */
        fmodifiersTypeInfo[1]=  &FMI_GENERATOR;                 /* Generator 
F-Curve Modifier */
        fmodifiersTypeInfo[2]=  &FMI_ENVELOPE;                  /* Envelope 
F-Curve Modifier */
@@ -1568,6 +1584,8 @@
        
        /* add modifier itself */
        fcm= MEM_callocN(sizeof(FModifier), "F-Curve Modifier");
+       fcm->type = type;
+       fcm->flag = FMODIFIER_FLAG_EXPANDED;
        BLI_addtail(&fcu->modifiers, fcm);
        
        /* add modifier's data */
@@ -1674,12 +1692,30 @@
        fcu->driver= driver;
 }
 
+/* Find the active F-Curve Modifier */
+FModifier *fcurve_active_modifier (FCurve *fcu)
+{
+       FModifier *fcm;
+       
+       /* sanity checks */
+       if ELEM(NULL, fcu, fcu->modifiers.first)
+               return NULL;
+       
+       /* loop over modifiers until 'active' one is found */
+       for (fcm= fcu->modifiers.first; fcm; fcm= fcm->next) {
+               if (fcm->flag & FMODIFIER_FLAG_ACTIVE)
+                       return fcm;
+       }
+       
+       /* no modifier is active */
+       return NULL;
+}
+
 /* ***************************** F-Curve - Evaluation 
********************************* */
 
 /* Evaluate and return the value of the given F-Curve at the specified frame 
("evaltime") 
  * Note: this is also used for drivers
  */
-// TODO: set up the modifier system...
 float evaluate_fcurve (FCurve *fcu, float evaltime) 
 {
        FModifier *fcm;

Modified: 
branches/blender2.5/blender/source/blender/editors/animation/anim_filter.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/anim_filter.c  
2009-03-15 08:58:33 UTC (rev 19298)
+++ branches/blender2.5/blender/source/blender/editors/animation/anim_filter.c  
2009-03-15 10:39:02 UTC (rev 19299)
@@ -310,6 +310,12 @@
 /* quick macro to test if AnimData is usable for drivers */
 #define ANIMDATA_HAS_DRIVERS(id) ((id)->adt && (id)->adt->drivers.first)
 
+/* quick macro to test if a anim-channel (F-Curve, Group, etc.) is selected in 
an acceptable way */
+#define ANIMCHANNEL_SELOK(test_func) \
+               ( !(filter_mode & (ANIMFILTER_SEL|ANIMFILTER_UNSEL)) || \
+                 ((filter_mode & ANIMFILTER_SEL) && test_func) || \
+                 ((filter_mode & ANIMFILTER_UNSEL) && test_func==0) ) 
+
 /* ----------- 'Private' Stuff --------------- */
 
 /* this function allocates memory for a new bAnimListElem struct for the 
@@ -509,8 +515,8 @@
                if (!(filter_mode & ANIMFILTER_CURVEVISIBLE) || (fcu->flag & 
FCURVE_VISIBLE)) {
                        /* only work with this channel and its subchannels if 
it is editable */
                        if (!(filter_mode & ANIMFILTER_FOREDIT) || 
EDITABLE_FCU(fcu)) {
-                               /* only include this curve if selected */
-                               if (!(filter_mode & ANIMFILTER_SEL) || 
(SEL_FCU(fcu))) {
+                               /* only include this curve if selected in a way 
consistent with the filtering requirements */
+                               if ( ANIMCHANNEL_SELOK(SEL_FCU(fcu)) ) {
                                        /* only include if this curve is active 
*/
                                        if (!(filter_mode & ANIMFILTER_ACTIVE) 
|| (fcu->flag & FCURVE_ACTIVE)) {
                                                /* owner/ownertype will be 
either object or action-channel, depending if it was dopesheet or part of an 
action */
@@ -543,7 +549,7 @@
                /* add this group as a channel first */
                if ((filter_mode & ANIMFILTER_CHANNELS) || !(filter_mode & 
ANIMFILTER_CURVESONLY)) {
                        /* check if filtering by selection */
-                       if ( !(filter_mode & ANIMFILTER_SEL) || SEL_AGRP(agrp) 
) {
+                       if ( ANIMCHANNEL_SELOK(SEL_AGRP(agrp)) ) {
                                ale= make_new_animlistelem(agrp, 
ANIMTYPE_GROUP, NULL, ANIMTYPE_NONE, owner_id);
                                if (ale) {
                                        BLI_addtail(anim_data, ale);
@@ -569,8 +575,7 @@
                         *      - we're interested in keyframes, but not if 
they appear in selected channels
                         */
                        if ( (!(filter_mode & ANIMFILTER_VISIBLE) || 
EXPANDED_AGRP(agrp)) || 
-                                ( (!(filter_mode & ANIMFILTER_SEL) || 
(SEL_AGRP(agrp))) && 
-                                  (filter_mode & ANIMFILTER_CURVESONLY) ) ) 
+                                ( ANIMCHANNEL_SELOK(SEL_AGRP(agrp)) && 
(filter_mode & ANIMFILTER_CURVESONLY) ) ) 
                        {
                                if (!(filter_mode & ANIMFILTER_FOREDIT) || 
EDITABLE_AGRP(agrp)) {
                                        // XXX the 'owner' info here needs 
review...
@@ -709,7 +714,7 @@
                                /* loop over layers as the conditions are 
acceptable */
                                for (gpl= gpd->layers.first; gpl; gpl= 
gpl->next) {
                                        /* only if selected */
-                                       if (!(filter_mode & ANIMFILTER_SEL) || 
SEL_GPL(gpl)) {
+                                       if ( ANIMCHANNEL_SELOK(SEL_GPL(gpl)) ) {
                                                /* only if editable */
                                                if (!(filter_mode & 
ANIMFILTER_FOREDIT) || EDITABLE_GPL(gpl)) {
                                                        /* add to list */
@@ -784,7 +789,6 @@
                        
                        /* add material's F-Curve channels? */
                        if (FILTER_MAT_OBJD(ma) || (filter_mode & 
ANIMFILTER_CURVESONLY)) {
-                               //items += animdata_filter_ipocurves(anim_data, 
ma->ipo, filter_mode, base, ANIMTYPE_OBJECT, (ID *)ma);
                                        // XXX the 'owner' info here is still 
subject to improvement
                                items += animdata_filter_action(anim_data, 
ma->adt->action, filter_mode, ma, ANIMTYPE_DSMAT, (ID *)ma);
                        }
@@ -873,7 +877,7 @@
        /* add this object as a channel first */
        if ((filter_mode & ANIMFILTER_CURVESONLY) == 0) {
                /* check if filtering by selection */
-               if ( !(filter_mode & ANIMFILTER_SEL) || ((base->flag & SELECT) 
|| (base == sce->basact)) ) {

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to