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:
authorJoshua Leung <aligorith@gmail.com>2009-03-17 09:37:50 +0300
committerJoshua Leung <aligorith@gmail.com>2009-03-17 09:37:50 +0300
commit1ac0d54fea831c485e8e27e8bfa887e15beb58de (patch)
tree480b6e00ecb23a841022faefdcf633285dd081ed /source/blender/blenkernel
parentb68f5d7e96ba2451c41ead3361f5faedc39acade (diff)
F-Curve Modifiers: Cycles Modifier
* Added GUI and fixed bugs in the Cycles Modifier. This replaces the old Cyclic Extrapolation settings, giving more fine-grained control over the results. You can now specify whether the keyframes are repeated before and/or after the range independently, also, the maximum number of cycles on either side can be controlled. * TODO: it would be nice to have the last value held for cyclic+offset. * Deleting modifiers now works
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/intern/fcurve.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index 570af95f267..6f6d40c33ba 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -59,7 +59,7 @@ void free_fcurve (FCurve *fcu)
fcurve_free_driver(fcu);
fcurve_free_modifiers(fcu);
- /* free f-cruve itself */
+ /* free f-curve itself */
MEM_freeN(fcu);
}
@@ -1477,6 +1477,14 @@ static FModifierTypeInfo FMI_ENVELOPE = {
* as appropriate
*/
+static void fcm_cycles_new_data (void *mdata)
+{
+ FMod_Cycles *data= (FMod_Cycles *)mdata;
+
+ /* turn on cycles by default */
+ data->before_mode= data->after_mode= FCM_EXTRAPOLATE_CYCLIC;
+}
+
static void fcm_cycles_evaluate (FCurve *fcu, FModifier *fcm, float *cvalue, float evaltime)
{
FMod_Cycles *data= (FMod_Cycles *)fcm->data;
@@ -1522,7 +1530,7 @@ static void fcm_cycles_evaluate (FCurve *fcu, FModifier *fcm, float *cvalue, flo
* 2) if before first frame or after last frame, make sure some cycling is in use
*/
if (evaltime < prevkey[0]) {
- if (data->before_mode) {
+ if (data->before_mode) {
side= -1;
mode= data->before_mode;
cycles= data->before_cycles;
@@ -1538,8 +1546,7 @@ static void fcm_cycles_evaluate (FCurve *fcu, FModifier *fcm, float *cvalue, flo
if ELEM(0, side, mode)
return;
- /* extrapolation mode is 'cyclic' - find relative place within a cycle */
- // FIXME: adding the more fine-grained control of extrpolation mode
+ /* find relative place within a cycle */
{
float cycdx=0, cycdy=0, ofs=0;
@@ -1553,15 +1560,19 @@ static void fcm_cycles_evaluate (FCurve *fcu, FModifier *fcm, float *cvalue, flo
/* check if cycle is infinitely small, to be point of being impossible to use */
if (cycdx == 0)
return;
+
/* check that cyclic is still enabled for the specified time */
if (cycles == 0) {
/* catch this case so that we don't exit when we have cycles=0
* as this indicates infinite cycles...
*/
}
- else if ( ((float)side * (evaltime - ofs) / cycdx) > cycles )
+ else if ( ((float)side * (evaltime - ofs) / cycdx) > (cycles+1) ) {
+ /* we are too far away from range to evaluate
+ * TODO: but we should still hold last value...
+ */
return;
-
+ }
/* check if 'cyclic extrapolation', and thus calculate y-offset for this cycle */
if (mode == FCM_EXTRAPOLATE_CYCLIC_OFFSET) {
@@ -1596,7 +1607,7 @@ static FModifierTypeInfo FMI_CYCLES = {
"FMod_Cycles", /* struct name */
NULL, /* free data */
NULL, /* copy data */
- NULL, /* new data */
+ fcm_cycles_new_data, /* new data */
NULL /*fcm_cycles_verify*/, /* verify */
fcm_cycles_evaluate /* evaluate */
};