Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/constraint.c
| Show First 20 Lines • Show All 4,731 Lines • ▼ Show 20 Lines | |||||
| static void con_fix_copied_refs_cb(bConstraint *UNUSED(con), ID **idpoin, bool is_reference, void *UNUSED(userData)) | static void con_fix_copied_refs_cb(bConstraint *UNUSED(con), ID **idpoin, bool is_reference, void *UNUSED(userData)) | ||||
| { | { | ||||
| /* increment usercount if this is a reference type */ | /* increment usercount if this is a reference type */ | ||||
| if ((*idpoin) && (is_reference)) | if ((*idpoin) && (is_reference)) | ||||
| id_us_plus(*idpoin); | id_us_plus(*idpoin); | ||||
| } | } | ||||
| /* duplicate all of the constraints in a constraint stack */ | /* duplicate all of the constraints in a constraint stack */ | ||||
| void BKE_constraints_copy(ListBase *dst, const ListBase *src, bool do_extern) | void BKE_constraints_copy_ex(ListBase *dst, const ListBase *src, const int flag, bool do_extern) | ||||
| { | { | ||||
| bConstraint *con, *srccon; | bConstraint *con, *srccon; | ||||
| BLI_listbase_clear(dst); | BLI_listbase_clear(dst); | ||||
| BLI_duplicatelist(dst, src); | BLI_duplicatelist(dst, src); | ||||
| for (con = dst->first, srccon = src->first; con && srccon; srccon = srccon->next, con = con->next) { | for (con = dst->first, srccon = src->first; con && srccon; srccon = srccon->next, con = con->next) { | ||||
| const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con); | const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con); | ||||
| /* make a new copy of the constraint's data */ | /* make a new copy of the constraint's data */ | ||||
| con->data = MEM_dupallocN(con->data); | con->data = MEM_dupallocN(con->data); | ||||
| /* only do specific constraints if required */ | /* only do specific constraints if required */ | ||||
| if (cti) { | if (cti) { | ||||
| /* perform custom copying operations if needed */ | /* perform custom copying operations if needed */ | ||||
| if (cti->copy_data) | if (cti->copy_data) | ||||
| cti->copy_data(con, srccon); | cti->copy_data(con, srccon); | ||||
| /* fix usercounts for all referenced data in referenced data */ | /* Fix usercounts for all referenced data that need it. */ | ||||
| if (cti->id_looper) | if (cti->id_looper && (flag & LIB_ID_COPY_NO_USER_REFCOUNT) == 0) { | ||||
| cti->id_looper(con, con_fix_copied_refs_cb, NULL); | cti->id_looper(con, con_fix_copied_refs_cb, NULL); | ||||
| } | |||||
| /* for proxies we don't want to make extern */ | /* for proxies we don't want to make extern */ | ||||
| if (do_extern) { | if (do_extern) { | ||||
| /* go over used ID-links for this constraint to ensure that they are valid for proxies */ | /* go over used ID-links for this constraint to ensure that they are valid for proxies */ | ||||
| if (cti->id_looper) | if (cti->id_looper) | ||||
| cti->id_looper(con, con_extern_cb, NULL); | cti->id_looper(con, con_extern_cb, NULL); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void BKE_constraints_copy(ListBase *dst, const ListBase *src, bool do_extern) | |||||
| { | |||||
| BKE_constraints_copy_ex(dst, src, 0, do_extern); | |||||
| } | |||||
| /* ......... */ | /* ......... */ | ||||
| bConstraint *BKE_constraints_find_name(ListBase *list, const char *name) | bConstraint *BKE_constraints_find_name(ListBase *list, const char *name) | ||||
| { | { | ||||
| return BLI_findstring(list, name, offsetof(bConstraint, name)); | return BLI_findstring(list, name, offsetof(bConstraint, name)); | ||||
| } | } | ||||
| /* finds the 'active' constraint in a constraint stack */ | /* finds the 'active' constraint in a constraint stack */ | ||||
| ▲ Show 20 Lines • Show All 248 Lines • Show Last 20 Lines | |||||