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-05-04 14:04:46 +0400
committerJoshua Leung <aligorith@gmail.com>2009-05-04 14:04:46 +0400
commit22c2827d2de6cccf272cadeaa7632fc27f229a32 (patch)
tree915619bdf14144ff6560bd82d88b7415f163fc24 /source/blender/blenkernel
parent387df32933996850145487ddba07a3bd3c25d627 (diff)
Cycles F-Curve Modifier: 'Mirrored' Option
Using this cycling mode option, the keyframe range will be repeated in reverse order every second repeat. Thanks for the idea mfoxdogg :)
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/intern/fcurve.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index 3bc80d64329..0585717e13e 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -1736,6 +1736,7 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float cvalue, float e
/* find relative place within a cycle */
{
float cycdx=0, cycdy=0, ofs=0;
+ float cycle= 0;
/* ofs is start frame of cycle */
ofs= prevkey[0];
@@ -1748,13 +1749,16 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float cvalue, float e
if (cycdx == 0)
return evaltime;
+ /* calculate the 'number' of the cycle */
+ cycle= ((float)side * (evaltime - ofs) / cycdx);
+
/* 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+1) ) {
+ else if (cycle > (cycles+1)) {
/* we are too far away from range to evaluate
* TODO: but we should still hold last value...
*/
@@ -1768,7 +1772,14 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float cvalue, float e
}
/* calculate where in the cycle we are (overwrite evaltime to reflect this) */
- evaltime= (float)(fmod(evaltime-ofs, cycdx) + ofs);
+ if ((mode == FCM_EXTRAPOLATE_MIRROR) && ((int)(cycle) % 2)) {
+ /* when 'mirror' option is used and cycle number is odd, this cycle is played in reverse */
+ evaltime= (float)(lastkey[0] - fmod(evaltime-ofs, cycdx));
+ }
+ else {
+ /* the cycle is played normally... */
+ evaltime= (float)(fmod(evaltime-ofs, cycdx) + ofs);
+ }
if (evaltime < ofs) evaltime += cycdx;
}