Revision: 37122
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37122
Author:   aligorith
Date:     2011-06-03 13:34:02 +0000 (Fri, 03 Jun 2011)
Log Message:
-----------
Experimental Feature: Frame Range Masks for FModifiers

Using this feature, it is now possible to for example have different
noise-profiles for different parts of a curve, which makes it possible
to do animate camera shake for example.

Or perhaps, for having greater control of mixing and matching
different parts of F-Modifier effects, such as combining several
generator modifiers to get multi-case functions for instance.

See http://aligorith.blogspot.com/2011/06/gsoc11-fmodifier-range-
masks.html for details.

Modified Paths:
--------------
    branches/soc-2011-pepper/source/blender/blenkernel/intern/fmodifier.c
    branches/soc-2011-pepper/source/blender/editors/animation/fmodifier_ui.c
    branches/soc-2011-pepper/source/blender/makesdna/DNA_anim_types.h
    branches/soc-2011-pepper/source/blender/makesrna/intern/rna_fcurve.c

Modified: branches/soc-2011-pepper/source/blender/blenkernel/intern/fmodifier.c
===================================================================
--- branches/soc-2011-pepper/source/blender/blenkernel/intern/fmodifier.c       
2011-06-03 13:09:44 UTC (rev 37121)
+++ branches/soc-2011-pepper/source/blender/blenkernel/intern/fmodifier.c       
2011-06-03 13:34:02 UTC (rev 37122)
@@ -1230,11 +1230,21 @@
        for (fcm= modifiers->last; fcm; fcm= fcm->prev) {
                FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm);
                
-               /* only evaluate if there's a callback for this */
-               // TODO: implement the 'influence' control feature...
-               if (fmi && fmi->evaluate_modifier_time) {
-                       if ((fcm->flag & 
(FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED)) == 0)
-                               evaltime= fmi->evaluate_modifier_time(fcu, fcm, 
cvalue, evaltime);
+               if (fmi == NULL) 
+                       continue;
+               
+               /* if modifier cannot be applied on this frame (whatever scale 
it is on, it won't affect the results)
+                * hence we shouldn't bother seeing what it would do given the 
chance
+                */
+               if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT)==0 || 
+                       ((fcm->sfra <= evaltime) && (fcm->efra >= evaltime)) )
+               {
+                       /* only evaluate if there's a callback for this */
+                       // TODO: implement the 'influence' control feature...
+                       if (fmi->evaluate_modifier_time) {
+                               if ((fcm->flag & 
(FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED)) == 0)
+                                       evaltime= 
fmi->evaluate_modifier_time(fcu, fcm, cvalue, evaltime);
+                       }
                }
        }
        
@@ -1257,11 +1267,18 @@
        for (fcm= modifiers->first; fcm; fcm= fcm->next) {
                FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm);
                
-               /* only evaluate if there's a callback for this */
+               if (fmi == NULL) 
+                       continue;
+               
+               /* only evaluate if there's a callback for this, and if 
F-Modifier can be evaluated on this frame */
                // TODO: implement the 'influence' control feature...
-               if (fmi && fmi->evaluate_modifier) {
-                       if ((fcm->flag & 
(FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED)) == 0)
-                               fmi->evaluate_modifier(fcu, fcm, cvalue, 
evaltime);
+               if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT)==0 || 
+                       ((fcm->sfra <= evaltime) && (fcm->efra >= evaltime)) )
+               {
+                       if (fmi->evaluate_modifier) {
+                               if ((fcm->flag & 
(FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED)) == 0)
+                                       fmi->evaluate_modifier(fcu, fcm, 
cvalue, evaltime);
+                       }
                }
        }
 } 

Modified: 
branches/soc-2011-pepper/source/blender/editors/animation/fmodifier_ui.c
===================================================================
--- branches/soc-2011-pepper/source/blender/editors/animation/fmodifier_ui.c    
2011-06-03 13:09:44 UTC (rev 37121)
+++ branches/soc-2011-pepper/source/blender/editors/animation/fmodifier_ui.c    
2011-06-03 13:34:02 UTC (rev 37122)
@@ -694,6 +694,24 @@
                        default: /* unknown type */
                                break;
                }
+               
+               /* one last panel below this: FModifier range */
+               // TODO: experiment with placement of this
+               {
+                       box = uiLayoutBox(layout);
+                       
+                       /* top row: use restricted range */
+                       row= uiLayoutRow(box, 0);
+                       uiItemR(row, &ptr, "use_restricted_range", 0, NULL, 
ICON_NONE);
+                       
+                       if (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) {
+                               /* second row: settings */
+                               row = uiLayoutRow(box, 1);
+                               
+                               uiItemR(row, &ptr, "frame_start", 0, "Start", 
ICON_NONE);
+                               uiItemR(row, &ptr, "frame_end", 0, "End", 
ICON_NONE);
+                       }
+               }
        }
 }
 

Modified: branches/soc-2011-pepper/source/blender/makesdna/DNA_anim_types.h
===================================================================
--- branches/soc-2011-pepper/source/blender/makesdna/DNA_anim_types.h   
2011-06-03 13:09:44 UTC (rev 37121)
+++ branches/soc-2011-pepper/source/blender/makesdna/DNA_anim_types.h   
2011-06-03 13:34:02 UTC (rev 37122)
@@ -62,6 +62,9 @@
        short flag;                     /* settings for the modifier */
        
        float influence;        /* the amount that the modifier should 
influence the value */
+       
+       float sfra;                     /* start frame of restricted 
frame-range */
+       float efra;                     /* end frame of restricted frame-range 
*/
 } FModifier;
 
 /* Types of F-Curve modifier 
@@ -86,13 +89,15 @@
 /* F-Curve Modifier Settings */
 typedef enum eFModifier_Flags {
                /* modifier is not able to be evaluated for some reason, and 
should be skipped (internal) */
-       FMODIFIER_FLAG_DISABLED         = (1<<0),
+       FMODIFIER_FLAG_DISABLED          = (1<<0),
                /* modifier's data is expanded (in UI) */
-       FMODIFIER_FLAG_EXPANDED         = (1<<1),
+       FMODIFIER_FLAG_EXPANDED          = (1<<1),
                /* modifier is active one (in UI) for editing purposes */
-       FMODIFIER_FLAG_ACTIVE           = (1<<2),
+       FMODIFIER_FLAG_ACTIVE            = (1<<2),
                /* user wants modifier to be skipped */
-       FMODIFIER_FLAG_MUTED            = (1<<3)
+       FMODIFIER_FLAG_MUTED             = (1<<3),
+               /* restrict range that F-Modifier can be considered over */
+       FMODIFIER_FLAG_RANGERESTRICT = (1<<4)
 } eFModifier_Flags; 
 
 /* --- */

Modified: branches/soc-2011-pepper/source/blender/makesrna/intern/rna_fcurve.c
===================================================================
--- branches/soc-2011-pepper/source/blender/makesrna/intern/rna_fcurve.c        
2011-06-03 13:09:44 UTC (rev 37121)
+++ branches/soc-2011-pepper/source/blender/makesrna/intern/rna_fcurve.c        
2011-06-03 13:34:02 UTC (rev 37122)
@@ -454,6 +454,22 @@
        fm->flag |= FMODIFIER_FLAG_ACTIVE;
 }
 
+static void rna_FModifier_start_frame_range(PointerRNA *ptr, float *min, float 
*max)
+{
+       FModifier *fcm= (FModifier*)ptr->data;
+       
+       *min= MINAFRAMEF;
+       *max= (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT)? fcm->efra : MAXFRAMEF;
+}
+
+static void rna_FModifier_end_frame_range(PointerRNA *ptr, float *min, float 
*max)
+{
+       FModifier *fcm= (FModifier*)ptr->data;
+
+       *min= (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT)? fcm->sfra : 
MINAFRAMEF;
+       *max= MAXFRAMEF;
+}
+
 static void rna_FModifier_active_update(Main *bmain, Scene *scene, PointerRNA 
*ptr)
 {
        FModifier *fm, *fmo= (FModifier*)ptr->data;
@@ -1015,6 +1031,25 @@
        RNA_def_property_boolean_funcs(prop, NULL, "rna_FModifier_active_set");
        RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, 
"rna_FModifier_active_update");
        RNA_def_property_ui_icon(prop, ICON_RADIOBUT_OFF, 1);
+       
+       /* restricted range */
+       prop= RNA_def_property(srna, "use_restricted_range", PROP_BOOLEAN, 
PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", 
FMODIFIER_FLAG_RANGERESTRICT);
+       RNA_def_property_ui_text(prop, "Restrict Frame Range", "F-Curve 
Modifier is only applied for the specified frame range to help mask off effects 
in order to chain them");
+       RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
+       RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1); // XXX: depends on 
UI implementation
+       
+       prop= RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_float_sdna(prop, NULL, "sfra");
+       RNA_def_property_float_funcs(prop, NULL, NULL, 
"rna_FModifier_start_frame_range");
+       RNA_def_property_ui_text(prop, "Start Frame", "Frame that modifier's 
influence starts (if Restrict Frame Range is in use)");
+       RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
+       
+       prop= RNA_def_property(srna, "frame_end", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_float_sdna(prop, NULL, "efra");
+       RNA_def_property_float_funcs(prop, NULL, NULL, 
"rna_FModifier_end_frame_range");
+       RNA_def_property_ui_text(prop, "End Frame", "Frame that modifier's 
influence ends (if Restrict Frame Range is in use)");
+       RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
 }      
 
 /* *********************** */

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

Reply via email to