- sequencer speed effect back using fcurves, still needs manual reloading to refresh.

- 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.
This commit is contained in:
Campbell Barton 2009-11-14 14:58:19 +00:00
parent d33291fcc4
commit c9d2186561
9 changed files with 100 additions and 25 deletions

View 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"

View 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)
*/

View 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);

View 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)
{

View File

@ -36,11 +36,13 @@
#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;

View 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);
}
}

View 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));

View 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);

View 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);
}
}
}