2.5 - Partial Bugfixes for Parenting Objects to Curves (Ctrl-P)
authorJoshua Leung <aligorith@gmail.com>
Mon, 21 Sep 2009 12:09:00 +0000 (12:09 +0000)
committerJoshua Leung <aligorith@gmail.com>
Mon, 21 Sep 2009 12:09:00 +0000 (12:09 +0000)
* Path Constraint option (i.e. this creates a follow-path constraint but doesn't actually parent the object to the curve) works now. Fixed a crash here too.

* Follow Path option (i.e. parent the object to the curve, and follow it), is not working correctly yet. Some matrix seems to get set wrongly.

source/blender/blenkernel/intern/constraint.c
source/blender/editors/object/object_relations.c

index e49bda0fdd2ac6417ae7d96bdd6c83d39a0daf7b..a3d59720645fb3037c9c809f71699c43448ddcfb 100644 (file)
@@ -1188,7 +1188,10 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
                if (cu->path && cu->path->data) {
                        if ((data->followflag & FOLLOWPATH_STATIC) == 0) { 
                                /* animated position along curve depending on time */
-                               curvetime= bsystem_time(cob->scene, ct->tar, ctime, 0.0) - data->offset;
+                               if (cob->scene)
+                                       curvetime= bsystem_time(cob->scene, ct->tar, ctime, 0.0) - data->offset;
+                               else    
+                                       curvetime= ctime - data->offset;
                                
                                /* ctime is now a proper var setting of Curve which gets set by Animato like any other var that's animated,
                                 * but this will only work if it actually is animated... 
index 65061e8dfb9368fb18e0dc0316c3d4052737f544..17590cbaad37684f93d2616d7e7aad5c9c182033 100644 (file)
@@ -566,8 +566,9 @@ static int parent_set_exec(bContext *C, wmOperator *op)
                        }
                        else cu->flag |= CU_FOLLOW;
                        
-                       /* fall back on regular parenting now */
-                       partype= PAR_OBJECT;
+                       /* fall back on regular parenting now (for follow only) */
+                       if(partype == PAR_FOLLOW)
+                               partype= PAR_OBJECT;
                }               
        }
        else if(partype==PAR_BONE) {
@@ -593,7 +594,9 @@ static int parent_set_exec(bContext *C, wmOperator *op)
                                /* apply transformation of previous parenting */
                                ED_object_apply_obmat(ob);
                                
-                               ob->parent= par;
+                               /* set the parent (except for follow-path constraint option) */
+                               if(partype != PAR_PATH_CONST)
+                                       ob->parent= par;
                                
                                /* handle types */
                                if (pchan)
@@ -602,7 +605,7 @@ static int parent_set_exec(bContext *C, wmOperator *op)
                                        ob->parsubstr[0]= 0;
                                
                                /* constraint */
-                               if(partype==PAR_PATH_CONST) {
+                               if(partype == PAR_PATH_CONST) {
                                        bConstraint *con;
                                        bFollowPathConstraint *data;
                                        float cmat[4][4], vec[3];
@@ -620,6 +623,7 @@ static int parent_set_exec(bContext *C, wmOperator *op)
                                        
                                        ob->loc[0] = vec[0];
                                        ob->loc[1] = vec[1];
+                                       ob->loc[2] = vec[2];
                                }
                                else if(pararm && ob->type==OB_MESH && par->type == OB_ARMATURE) {
                                        if(partype == PAR_ARMATURE_NAME)
@@ -645,6 +649,8 @@ static int parent_set_exec(bContext *C, wmOperator *op)
                                
                                ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA;
                                
+                               if(partype == PAR_PATH_CONST)
+                                       ; /* don't do anything here, since this is not technically "parenting" */
                                if( ELEM(partype, PAR_CURVE, PAR_LATTICE) || pararm )
                                        ob->partype= PARSKEL; /* note, dna define, not operator property */
                                else if (partype == PAR_BONE)