option to copy constraints without making their ID references direct links.

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)
This commit is contained in:
Campbell Barton 2010-04-29 15:31:53 +00:00
parent 6662440867
commit 610c4befd4
9 changed files with 20 additions and 15 deletions

@ -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);

@ -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) {

@ -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 */

@ -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);
}
}
}
}

@ -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;

@ -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;

@ -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) {

@ -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;
}

@ -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;