Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-11-14 17:58:19 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-11-14 17:58:19 +0300
commitc9d2186561a86b050c94c52925c2f7353448961b (patch)
treec369135530c4070e95c79eb7807d730b5fe71211 /source/blender/blenkernel
parentd33291fcc45f17b0bfa6c6021edc47f41f45e76f (diff)
- 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.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_fcurve.h4
-rw-r--r--source/blender/blenkernel/BKE_sequence.h4
-rw-r--r--source/blender/blenkernel/intern/fcurve.c45
-rw-r--r--source/blender/blenkernel/intern/seqeffects.c42
-rw-r--r--source/blender/blenkernel/intern/sequence.c10
5 files changed, 82 insertions, 23 deletions
diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h
index 6e273c81e39..24d5be524d7 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -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)
*/
diff --git a/source/blender/blenkernel/BKE_sequence.h b/source/blender/blenkernel/BKE_sequence.h
index fb3c282b090..05129c73b03 100644
--- a/source/blender/blenkernel/BKE_sequence.h
+++ b/source/blender/blenkernel/BKE_sequence.h
@@ -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);
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index e8dc843dd01..40328c876be 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -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)
{
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index a175ddf975a..68edc00de23 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -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;
diff --git a/source/blender/blenkernel/intern/sequence.c b/source/blender/blenkernel/intern/sequence.c
index a986e9d7a94..fd28123c5d8 100644
--- a/source/blender/blenkernel/intern/sequence.c
+++ b/source/blender/blenkernel/intern/sequence.c
@@ -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);
}
}