option to copy constraints without making their ID references direct links.
authorCampbell Barton <ideasman42@gmail.com>
Thu, 29 Apr 2010 15:31:53 +0000 (15:31 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 29 Apr 2010 15:31:53 +0000 (15:31 +0000)
needed because proxies are causing libs to be linked directly when they should be kept indirect (likely slowing load times though I didnt time this)

source/blender/blenkernel/BKE_constraint.h
source/blender/blenkernel/intern/action.c
source/blender/blenkernel/intern/armature.c
source/blender/blenkernel/intern/constraint.c
source/blender/blenkernel/intern/object.c
source/blender/editors/armature/poseobject.c
source/blender/editors/object/object_constraint.c
source/blender/editors/object/object_edit.c
source/gameengine/Converter/BL_ArmatureObject.cpp

index 94863e1..64e9636 100644 (file)
@@ -122,7 +122,7 @@ bConstraintTypeInfo *get_constraint_typeinfo(int type);
 void unique_constraint_name(struct bConstraint *con, struct ListBase *list);
 
 void free_constraints(struct ListBase *list);
-void copy_constraints(struct ListBase *dst, const struct ListBase *src);
+void copy_constraints(struct ListBase *dst, const struct ListBase *src, int do_extern);
 void relink_constraints(struct ListBase *list);
 void id_loop_constraints(struct ListBase *list, ConstraintIDFunc func, void *userdata);
 void free_constraint_data(struct bConstraint *con);
index 253da25..c5705a0 100644 (file)
@@ -493,7 +493,7 @@ void copy_pose (bPose **dst, bPose *src, int copycon)
        for (pchan=outPose->chanbase.first; pchan; pchan=pchan->next) {
                // TODO: rename this argument...
                if (copycon) {
-                       copy_constraints(&listb, &pchan->constraints);  // copy_constraints NULLs listb
+                       copy_constraints(&listb, &pchan->constraints, TRUE);  // copy_constraints NULLs listb
                        pchan->constraints= listb;
                        pchan->path= NULL; // XXX remove this line when the new motionpaths are ready... (depreceated code)
                        pchan->mpath= NULL; /* motion paths should not get copied yet... */
@@ -667,7 +667,7 @@ void duplicate_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *pchan_
        pchan->iklinweight= pchan_from->iklinweight;
 
        /* constraints */
-       copy_constraints(&pchan->constraints, &pchan_from->constraints);
+       copy_constraints(&pchan->constraints, &pchan_from->constraints, TRUE);
 
        /* id-properties */
        if(pchan->prop) {
index a2dbaa9..4f9b943 100644 (file)
@@ -1568,9 +1568,11 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected
                         *      1. extract constraints not from proxy (CONSTRAINT_PROXY_LOCAL) from pchan's constraints
                         *      2. copy proxy-pchan's constraints on-to new
                         *      3. add extracted local constraints back on top 
+                        *
+                        *  note for copy_constraints: when copying constraints, disable 'do_extern' otherwise we get the libs direct linked in this blend.
                         */
                        extract_proxylocal_constraints(&proxylocal_constraints, &pchan->constraints);
-                       copy_constraints(&pchanw.constraints, &pchanp->constraints);
+                       copy_constraints(&pchanw.constraints, &pchanp->constraints, FALSE);
                        addlisttolist(&pchanw.constraints, &proxylocal_constraints);
                        
                        /* constraints - set target ob pointer to own object */
index 18504ba..a3f1cb0 100644 (file)
@@ -4131,7 +4131,7 @@ static void con_extern_cb(bConstraint *con, ID **idpoin, void *userdata)
 }
 
 /* duplicate all of the constraints in a constraint stack */
-void copy_constraints (ListBase *dst, const ListBase *src)
+void copy_constraints (ListBase *dst, const ListBase *src, int do_extern)
 {
        bConstraint *con, *srccon;
        
@@ -4149,10 +4149,13 @@ void copy_constraints (ListBase *dst, const ListBase *src)
                        /* perform custom copying operations if needed */
                        if (cti->copy_data)
                                cti->copy_data(con, srccon);
-                       
-                       /* go over used ID-links for this constraint to ensure that they are valid for proxies */
-                       if (cti->id_looper)
-                               cti->id_looper(con, con_extern_cb, NULL);
+
+                       /* for proxies we dont want to make extern */
+                       if(do_extern) {
+                               /* go over used ID-links for this constraint to ensure that they are valid for proxies */
+                               if (cti->id_looper)
+                                       cti->id_looper(con, con_extern_cb, NULL);
+                       }
                }
        }
 }
index ce064a7..baa1cae 100644 (file)
@@ -1282,7 +1282,7 @@ Object *copy_object(Object *ob)
                        armature_rebuild_pose(obn, obn->data);
        }
        defgroup_copy_list(&obn->defbase, &ob->defbase);
-       copy_constraints(&obn->constraints, &ob->constraints);
+       copy_constraints(&obn->constraints, &ob->constraints, TRUE);
 
        obn->mode = 0;
        obn->sculpt = NULL;
index dcd59a3..24c3aff 100644 (file)
@@ -691,7 +691,7 @@ void pose_copy_menu(Scene *scene)
                                                /* copy constraints to tmpbase and apply 'local' tags before 
                                                 * appending to list of constraints for this channel
                                                 */
-                                               copy_constraints(&tmp_constraints, &pchanact->constraints);
+                                               copy_constraints(&tmp_constraints, &pchanact->constraints, TRUE);
                                                if ((ob->proxy) && (pchan->bone->layer & arm->layer_protected)) {
                                                        bConstraint *con;
                                                        
@@ -800,7 +800,7 @@ void pose_copy_menu(Scene *scene)
                                /* copy constraints to tmpbase and apply 'local' tags before 
                                 * appending to list of constraints for this channel
                                 */
-                               copy_constraints(&tmp_constraints, &const_copy);
+                               copy_constraints(&tmp_constraints, &const_copy, TRUE);
                                if ((ob->proxy) && (pchan->bone->layer & arm->layer_protected)) {
                                        bConstraint *con;
                                        
index 83da8ad..eef7919 100644 (file)
@@ -1256,7 +1256,7 @@ static int object_constraint_copy_exec(bContext *C, wmOperator *op)
        CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) {
                if(ob != ob_iter) {
                        if (ob->data != ob_iter->data){
-                               copy_constraints(&ob_iter->constraints, &ob->constraints);
+                               copy_constraints(&ob_iter->constraints, &ob->constraints, TRUE);
                        }
                        
                        if(ob_iter->totcol==ob->totcol) {
index 6631f5f..53d6146 100644 (file)
@@ -1450,7 +1450,7 @@ void copy_attr(Scene *scene, View3D *v3d, short event)
                                }
                                else if(event==22) {
                                        /* Copy the constraint channels over */
-                                       copy_constraints(&base->object->constraints, &ob->constraints);
+                                       copy_constraints(&base->object->constraints, &ob->constraints, TRUE);
                                        
                                        do_scene_sort= 1;
                                }
index 35ee3ac..78f16dd 100644 (file)
@@ -108,7 +108,7 @@ void game_copy_pose(bPose **dst, bPose *src, int copy_constraint)
                if (copy_constraint) {
                        ListBase listb;
                        // copy all constraint for backward compatibility
-                       copy_constraints(&listb, &pchan->constraints);  // copy_constraints NULLs listb
+                       copy_constraints(&listb, &pchan->constraints, FALSE);  // copy_constraints NULLs listb, no need to make extern for this operation.
                        pchan->constraints= listb;
                } else {
                        pchan->constraints.first = NULL;