Changes to "evaluation time" for Curves:
[blender-staging.git] / source / blender / editors / object / object_relations.c
index d92aeb13547c92e9ee787d038062623e60091c69..b1c027a2f24c273805d8105b929db77b8976de2f 100644 (file)
@@ -57,6 +57,7 @@
 #include "BKE_depsgraph.h"
 #include "BKE_displist.h"
 #include "BKE_global.h"
+#include "BKE_fcurve.h"
 #include "BKE_lattice.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
@@ -82,6 +83,7 @@
 
 #include "ED_armature.h"
 #include "ED_curve.h"
+#include "ED_keyframing.h"
 #include "ED_object.h"
 #include "ED_screen.h"
 #include "ED_view3d.h"
@@ -546,6 +548,17 @@ static int parent_set_exec(bContext *C, wmOperator *op)
                        }
                        else cu->flag |= CU_FOLLOW;
                        
+                       /* if follow, add F-Curve for ctime (i.e. "eval_time") so that path-follow works */
+                       if(partype == PAR_FOLLOW) {
+                               /* get or create F-Curve */
+                               bAction *act = verify_adt_action(&cu->id, 1);
+                               FCurve *fcu = verify_fcurve(act, NULL, "eval_time", 0, 1);
+                               
+                               /* setup dummy 'generator' modifier here to get 1-1 correspondance still working */
+                               if (!fcu->bezt && !fcu->fpt && !fcu->modifiers.first)
+                                       add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR);
+                       }
+                       
                        /* fall back on regular parenting now (for follow only) */
                        if(partype == PAR_FOLLOW)
                                partype= PAR_OBJECT;