- sequencer speed effect back using fcurves, still needs manual reloading to refresh.
authorCampbell Barton <ideasman42@gmail.com>
Sat, 14 Nov 2009 14:58:19 +0000 (14:58 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 14 Nov 2009 14:58:19 +0000 (14:58 +0000)
- added a function id_data_find_fcurve() to get the fcurve without RNA vars. Aligorith: this could be made to use a path rather then a property name.

release/scripts/ui/space_sequencer.py
source/blender/blenkernel/BKE_fcurve.h
source/blender/blenkernel/BKE_sequence.h
source/blender/blenkernel/intern/fcurve.c
source/blender/blenkernel/intern/seqeffects.c
source/blender/blenkernel/intern/sequence.c
source/blender/editors/space_sequencer/sequencer_edit.c
source/blender/makesrna/intern/rna_sequence.c
source/blender/render/intern/source/pipeline.c

index de499a5089db17ed326226c2c1b84728e0a721a7..6dbd561f3e124172c6cbe5d48f8f22265eac3724 100644 (file)
@@ -426,6 +426,10 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel):
             col.itemR(strip, "rotation_start", text="Start")
             col.itemR(strip, "rotation_end", text="End")
 
+        col = layout.column(align=True)
+        col.itemR(strip, "factor_0", text="Anim0")
+        col.itemR(strip, "factor_1", text="Anim1")
+
 
 class SEQUENCER_PT_input(SequencerButtonsPanel):
     bl_label = "Strip Input"
index 6e273c81e398f2fc5378c64c3023296acef9a5a9..24d5be524d7ffaee488386bd104833740fc4b15b 100644 (file)
@@ -34,6 +34,7 @@ struct ChannelDriver;
 struct DriverTarget;
 
 struct BezTriple;
+struct StructRNA;
 
 #include "DNA_curve_types.h"
 
@@ -155,6 +156,9 @@ void copy_fcurves(ListBase *dst, ListBase *src);
 /* find matching F-Curve in the given list of F-Curves */
 struct FCurve *list_find_fcurve(ListBase *list, const char rna_path[], const int array_index);
 
+/* high level function to get an fcurve from C without having the rna */
+struct FCurve *id_data_find_fcurve(ID* id, void *data, struct StructRNA *type, char *prop_name, int index);
+
 /* Binary search algorithm for finding where to 'insert' BezTriple with given frame number.
  * Returns the index to insert at (data already at that index will be offset if replace is 0)
  */
index fb3c282b0900b6646f0a94b95c46162944632643..05129c73b035ffab0b9efc8740196334e27d8b3c 100644 (file)
@@ -163,7 +163,7 @@ void update_changed_seq_and_deps(struct Scene *scene, struct Sequence *changed_s
 /* seqeffects.c */
 // intern?
 struct SeqEffectHandle get_sequence_blend(struct Sequence *seq);
-void sequence_effect_speed_rebuild_map(struct Sequence *seq, int force);
+void sequence_effect_speed_rebuild_map(struct Scene *scene, struct Sequence *seq, int force);
 
 // extern
 struct SeqEffectHandle get_sequence_effect(struct Sequence *seq);
@@ -183,7 +183,7 @@ void fix_single_seq(struct Sequence *seq);
 int seq_test_overlap(struct ListBase * seqbasep, struct Sequence *test);
 int shuffle_seq(struct ListBase * seqbasep, struct Sequence *test);
 int shuffle_seq_time(ListBase * seqbasep);
-void free_imbuf_seq(struct ListBase * seqbasep, int check_mem_usage);
+void free_imbuf_seq(struct Scene *scene, struct ListBase * seqbasep, int check_mem_usage);
 
 void seq_update_sound(struct Sequence *seq);
 
index e8dc843dd011ea8d7d8f39c36bd9d6e204925406..40328c876bec52e32b19acad0eaa3cb80d61e52e 100644 (file)
@@ -47,6 +47,8 @@
 #include "BLI_noise.h"
 
 #include "BKE_fcurve.h"
+#include "BKE_animsys.h"
+
 #include "BKE_curve.h" 
 #include "BKE_global.h"
 #include "BKE_idprop.h"
@@ -177,6 +179,49 @@ void copy_fcurves (ListBase *dst, ListBase *src)
 
 /* --------------------- Finding -------------------------- */
 
+FCurve *id_data_find_fcurve(ID *id, void *data, StructRNA *type, char *prop_name, int index)
+{
+       /* anim vars */
+       AnimData *adt;
+       FCurve *fcu= NULL;
+
+       /* rna vars */
+       PointerRNA ptr;
+       PropertyRNA *prop;
+       char *path;
+
+       adt= BKE_animdata_from_id(id);
+
+       /* only use the current action ??? */
+       if(adt==NULL || adt->action==NULL)
+               return NULL;
+
+       RNA_pointer_create(id, type, data, &ptr);
+       prop = RNA_struct_find_property(&ptr, prop_name);
+
+       if(prop) {
+               path= RNA_path_from_ID_to_property(&ptr, prop);
+
+               if(path) {
+                       /* animation takes priority over drivers */
+                       if(adt->action && adt->action->curves.first)
+                               fcu= list_find_fcurve(&adt->action->curves, path, index);
+
+                       /* if not animated, check if driven */
+#if 0
+                       if(!fcu && (adt->drivers.first)) {
+                               fcu= list_find_fcurve(&adt->drivers, path, but->rnaindex);
+                       }
+#endif
+
+                       MEM_freeN(path);
+               }
+       }
+
+       return fcu;
+}
+
+
 /* Find the F-Curve affecting the given RNA-access path + index, in the list of F-Curves provided */
 FCurve *list_find_fcurve (ListBase *list, const char rna_path[], const int array_index)
 {
index a175ddf975ab723ab87ad6102fdb6b1887788a99..68edc00de234c8bfe84f4e535ef6c10da2116608 100644 (file)
 
 #include "DNA_scene_types.h"
 #include "DNA_sequence_types.h"
+#include "DNA_anim_types.h"
 
 #include "BLI_blenlib.h"
 #include "BLI_math.h"
 
 #include "BKE_global.h"
+#include "BKE_fcurve.h"
 #include "BKE_plugin_types.h"
 #include "BKE_sequence.h"
 #include "BKE_texture.h"
@@ -49,6 +51,8 @@
 #include "IMB_imbuf_types.h"
 #include "IMB_imbuf.h"
 
+#include "RNA_access.h"
+
 /* **** XXX **** */
 static void error() {}
 
@@ -2777,14 +2781,15 @@ static void store_icu_yrange_speed(struct Sequence * seq,
                }
        }       
 }
-
-void sequence_effect_speed_rebuild_map(Sequence * seq, int force)
+extern float frame_to_float (Scene *scene, int cfra);
+void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force)
 {
        float facf0 = seq->facf0;
-       //float ctime, div;
+       float ctime, div;
        int cfra;
        float fallback_fac;
        SpeedControlVars * v = (SpeedControlVars *)seq->effectdata;
+       FCurve *fcu= NULL;
 
        /* if not already done, load / initialize data */
        get_sequence_effect(seq);
@@ -2797,6 +2802,11 @@ void sequence_effect_speed_rebuild_map(Sequence * seq, int force)
                return;
        }
 
+       /* XXX - new in 2.5x. should we use the animation system this way?
+        * The fcurve is needed because many frames need evaluating at once - campbell */
+       fcu= id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "factor_0", 0);
+
+
        if (!v->frameMap || v->length != seq->len) {
                if (v->frameMap) MEM_freeN(v->frameMap);
 
@@ -2811,8 +2821,7 @@ void sequence_effect_speed_rebuild_map(Sequence * seq, int force)
        /* if there is no IPO, try to make retiming easy by stretching the
           strip */
        // XXX old animation system - seq
-       if (/*!seq->ipo &&*/ seq->seq1->enddisp != seq->seq1->start
-           && seq->seq1->len != 0) {
+       if (!fcu && seq->seq1->enddisp != seq->seq1->start && seq->seq1->len != 0) {
                fallback_fac = (float) seq->seq1->len / 
                        (float) (seq->seq1->enddisp - seq->seq1->start);
                /* FIXME: this strip stretching gets screwed by stripdata
@@ -2834,8 +2843,7 @@ void sequence_effect_speed_rebuild_map(Sequence * seq, int force)
                v->lastValidFrame = 0;
 
                for (cfra = 1; cfra < v->length; cfra++) {
-#if 0 // XXX old animation system
-                       if(seq->ipo) {
+                       if(fcu) {
                                if((seq->flag & SEQ_IPO_FRAME_LOCKED) != 0) {
                                        ctime = frame_to_float(scene, seq->startdisp + cfra);
                                        div = 1.0;
@@ -2845,10 +2853,11 @@ void sequence_effect_speed_rebuild_map(Sequence * seq, int force)
                                        if(div==0.0) return;
                                }
                
-                               calc_ipo(seq->ipo, ctime/div);
-                               execute_ipo((ID *)seq, seq->ipo);
+//XXX OLD ANIMSYS
+//                             calc_ipo(seq->ipo, ctime/div);
+//                             execute_ipo((ID *)seq, seq->ipo);
+                               seq->facf0 = evaluate_fcurve(fcu, ctime/div);
                        } else 
-#endif // XXX old animation system
                        {
                                seq->facf0 = fallback_fac;
                        }
@@ -2866,8 +2875,8 @@ void sequence_effect_speed_rebuild_map(Sequence * seq, int force)
        } else {
                v->lastValidFrame = 0;
                for (cfra = 0; cfra < v->length; cfra++) {
-#if 0 // XXX old animation system
-                       if(seq->ipo) {
+
+                       if(fcu) {
                                if((seq->flag & SEQ_IPO_FRAME_LOCKED) != 0) {
                                        ctime = frame_to_float(scene, seq->startdisp + cfra);
                                        div = 1.0;
@@ -2877,15 +2886,16 @@ void sequence_effect_speed_rebuild_map(Sequence * seq, int force)
                                        if(div==0.0) return;
                                }
                
-                               calc_ipo(seq->ipo, ctime/div);
-                               execute_ipo((ID *)seq, seq->ipo);
+// XXX old animation system
+//                             calc_ipo(seq->ipo, ctime/div);
+//                             execute_ipo((ID *)seq, seq->ipo);
+                               seq->facf0 = evaluate_fcurve(fcu, ctime/div);
                        }
-#endif // XXX old animation system
                        
                        if (v->flags & SEQ_SPEED_COMPRESS_IPO_Y) {
                                seq->facf0 *= v->length;
                        }
-                       if (/*!seq->ipo*/ 1) { // XXX old animation system - seq
+                       if (!fcu) {
                                seq->facf0 = (float) cfra * fallback_fac;
                        }
                        seq->facf0 *= v->globalSpeed;
index a986e9d7a943f0157891ed4aa25fb0f524c18320..fd28123c5d8196a91a794196c115fb4474cb6602 100644 (file)
@@ -2226,7 +2226,7 @@ static TStripElem* do_handle_speed_effect(Scene *scene, Sequence * seq, int cfra
        TStripElem * se1 = 0;
        TStripElem * se2 = 0;
        
-       sequence_effect_speed_rebuild_map(seq, 0);
+       sequence_effect_speed_rebuild_map(scene, seq, 0);
        
        f_cfra = seq->start + s->frameMap[nr];
        
@@ -3053,7 +3053,7 @@ static void free_imbuf_seq_except(Scene *scene, int cfra)
 }
 #endif
 
-void free_imbuf_seq(ListBase * seqbase, int check_mem_usage)
+void free_imbuf_seq(Scene *scene, ListBase * seqbase, int check_mem_usage)
 {
        Sequence *seq;
        TStripElem *se;
@@ -3111,11 +3111,11 @@ void free_imbuf_seq(ListBase * seqbase, int check_mem_usage)
                        if(seq->type==SEQ_MOVIE)
                                free_anim_seq(seq);
                        if(seq->type==SEQ_SPEED) {
-                               sequence_effect_speed_rebuild_map(seq, 1);
+                               sequence_effect_speed_rebuild_map(scene, seq, 1);
                        }
                }
                if(seq->type==SEQ_META) {
-                       free_imbuf_seq(&seq->seqbase, FALSE);
+                       free_imbuf_seq(scene, &seq->seqbase, FALSE);
                }
                if(seq->type==SEQ_SCENE) {
                        /* FIXME: recurs downwards, 
@@ -3164,7 +3164,7 @@ static int update_changed_seq_recurs(Scene *scene, Sequence *seq, Sequence *chan
                        if(seq->type == SEQ_MOVIE)
                                free_anim_seq(seq);
                        if(seq->type == SEQ_SPEED) {
-                               sequence_effect_speed_rebuild_map(seq, 1);
+                               sequence_effect_speed_rebuild_map(scene, seq, 1);
                        }
                }
                
index 041ccd6641a53e0b50999fe33e00adfd175bb70f..1cf44d97c93b8f95e89c96d65d65692d6dec0d59 100644 (file)
@@ -1701,7 +1701,7 @@ static int sequencer_refresh_all_exec(bContext *C, wmOperator *op)
        if(ed==NULL)
                return OPERATOR_CANCELLED;
 
-       free_imbuf_seq(&ed->seqbase, FALSE);
+       free_imbuf_seq(scene, &ed->seqbase, FALSE);
 
        ED_area_tag_redraw(CTX_wm_area(C));
 
index 670af4d230c865d878a5e0b7f1cdeed1e0cded26..101c6969311b882166fcff0a62591db0fe6b131c 100644 (file)
@@ -545,6 +545,17 @@ static void rna_def_sequence(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Blend Opacity", "");
        RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL);
        
+       /* generic factors, should these be exposed some other way? */
+       prop= RNA_def_property(srna, "factor_0", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_float_sdna(prop, NULL, "facf0");
+       RNA_def_property_ui_text(prop, "Generic Factor 0", "");
+       RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL);
+
+       prop= RNA_def_property(srna, "factor_1", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_float_sdna(prop, NULL, "facf1");
+       RNA_def_property_ui_text(prop, "Generic Factor 0", "");
+       RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL);
+
        /* functions */
        func= RNA_def_function(srna, "getStripElem", "give_stripelem");
        RNA_def_function_ui_description(func, "Return the strip element from a given frame or None.");
@@ -1054,6 +1065,7 @@ static void rna_def_speed_control(BlenderRNA *brna)
        
        prop= RNA_def_property(srna, "global_speed", PROP_FLOAT, PROP_UNSIGNED);
        RNA_def_property_float_sdna(prop, NULL, "globalSpeed");
+       RNA_def_property_clear_flag(prop, PROP_ANIMATEABLE); /* seq->facf0 is used to animate this */
        RNA_def_property_ui_text(prop, "Global Speed", "");
        RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 0);
        
index 9c4c83a82f9c99b9dbdfa82ae8b1655ce01b7f5e..b357a17e244d2cd969dd762b5ab4f784d7f6f505 100644 (file)
@@ -2463,7 +2463,7 @@ static void do_render_seq(Render * re)
                if (recurs_depth == 0) { /* with nested scenes, only free on toplevel... */
                        Editing * ed = re->scene->ed;
                        if (ed) {
-                               free_imbuf_seq(&ed->seqbase, TRUE);
+                               free_imbuf_seq(re->scene, &ed->seqbase, TRUE);
                        }
                }
        }