From 42bc76511d829e2fc9002ee7a6f95f30cbb00a42 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 5 May 2009 09:43:11 +0000 Subject: [PATCH] Cycles FModifier - Repeat Mirrored now works for cycles before the start of the keyframe range --- source/blender/blenkernel/intern/fcurve.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 3d780ee97d5..cade555a07a 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -1774,8 +1774,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) */ 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)); + /* when 'mirror' option is used and cycle number is odd, this cycle is played in reverse + * - for 'before' extrapolation, we need to flip in a different way, otherwise values past + * then end of the curve get referenced (result of fmod will be negative, and with different phase) + */ + if (side < 0) + evaltime= (float)(prevkey[0] - fmod(evaltime-ofs, cycdx)); + else + evaltime= (float)(lastkey[0] - fmod(evaltime-ofs, cycdx)); } else { /* the cycle is played normally... */