Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_object.c
| Show First 20 Lines • Show All 1,667 Lines • ▼ Show 20 Lines | static void rna_Object_constraints_move( | ||||
| ED_object_constraint_tag_update(bmain, object, NULL); | ED_object_constraint_tag_update(bmain, object, NULL); | ||||
| WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT, object); | WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT, object); | ||||
| } | } | ||||
| static bConstraint *rna_Object_constraints_copy(Object *object, Main *bmain, PointerRNA *con_ptr) | static bConstraint *rna_Object_constraints_copy(Object *object, Main *bmain, PointerRNA *con_ptr) | ||||
| { | { | ||||
| bConstraint *con = con_ptr->data; | bConstraint *con = con_ptr->data; | ||||
| bConstraint *new_con = BKE_constraint_copy_for_object(object, con); | bConstraint *new_con = BKE_constraint_copy_for_object(object, con); | ||||
| new_con->flag |= CONSTRAINT_OVERRIDE_LIBRARY_LOCAL; | |||||
| ED_object_constraint_tag_update(bmain, object, new_con); | ED_object_constraint_tag_update(bmain, object, new_con); | ||||
| WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_ADDED, object); | WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_ADDED, object); | ||||
| return new_con; | return new_con; | ||||
| } | } | ||||
| bool rna_Object_constraints_override_apply(Main *UNUSED(bmain), | bool rna_Object_constraints_override_apply(Main *UNUSED(bmain), | ||||
| Show All 15 Lines | BLI_assert(opop->operation == IDOVERRIDE_LIBRARY_OP_INSERT_AFTER && | ||||
| "Unsupported RNA override operation on constraints collection"); | "Unsupported RNA override operation on constraints collection"); | ||||
| Object *ob_dst = (Object *)ptr_dst->owner_id; | Object *ob_dst = (Object *)ptr_dst->owner_id; | ||||
| Object *ob_src = (Object *)ptr_src->owner_id; | Object *ob_src = (Object *)ptr_src->owner_id; | ||||
| /* Remember that insertion operations are defined and stored in correct order, which means that | /* Remember that insertion operations are defined and stored in correct order, which means that | ||||
| * even if we insert several items in a row, we always insert first one, then second one, etc. | * even if we insert several items in a row, we always insert first one, then second one, etc. | ||||
| * So we should always find 'anchor' constraint in both _src *and* _dst. */ | * So we should always find 'anchor' constraint in both _src *and* _dst. */ | ||||
| bConstraint *con_anchor = NULL; | const size_t name_offset = offsetof(bConstraint, name); | ||||
| if (opop->subitem_local_name && opop->subitem_local_name[0]) { | bConstraint *con_anchor = BLI_listbase_string_or_index_find(&ob_dst->constraints, | ||||
| con_anchor = BLI_findstring( | opop->subitem_reference_name, | ||||
| &ob_dst->constraints, opop->subitem_local_name, offsetof(bConstraint, name)); | name_offset, | ||||
| } | opop->subitem_reference_index); | ||||
| if (con_anchor == NULL && opop->subitem_local_index >= 0) { | /* If `con_anchor` is NULL, `con_src` will be inserted in first position. */ | ||||
| con_anchor = BLI_findlink(&ob_dst->constraints, opop->subitem_local_index); | |||||
| } | |||||
| /* Otherwise we just insert in first position. */ | |||||
| bConstraint *con_src = NULL; | bConstraint *con_src = BLI_listbase_string_or_index_find( | ||||
| if (opop->subitem_local_name && opop->subitem_local_name[0]) { | &ob_src->constraints, opop->subitem_local_name, name_offset, opop->subitem_local_index); | ||||
| con_src = BLI_findstring( | |||||
| &ob_src->constraints, opop->subitem_local_name, offsetof(bConstraint, name)); | |||||
| } | |||||
| if (con_src == NULL && opop->subitem_local_index >= 0) { | |||||
| con_src = BLI_findlink(&ob_src->constraints, opop->subitem_local_index); | |||||
| } | |||||
| con_src = con_src ? con_src->next : ob_src->constraints.first; | |||||
| if (con_src == NULL) { | |||||
| BLI_assert(con_src != NULL); | BLI_assert(con_src != NULL); | ||||
| return false; | |||||
| } | |||||
| bConstraint *con_dst = BKE_constraint_duplicate_ex(con_src, 0, true); | bConstraint *con_dst = BKE_constraint_duplicate_ex(con_src, 0, true); | ||||
| /* This handles NULL anchor as expected by adding at head of list. */ | /* This handles NULL anchor as expected by adding at head of list. */ | ||||
| BLI_insertlinkafter(&ob_dst->constraints, con_anchor, con_dst); | BLI_insertlinkafter(&ob_dst->constraints, con_anchor, con_dst); | ||||
| /* This should actually *not* be needed in typical cases. | /* This should actually *not* be needed in typical cases. | ||||
| * However, if overridden source was edited, we *may* have some new conflicting names. */ | * However, if overridden source was edited, we *may* have some new conflicting names. */ | ||||
| ▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | BLI_assert(opop->operation == IDOVERRIDE_LIBRARY_OP_INSERT_AFTER && | ||||
| "Unsupported RNA override operation on modifiers collection"); | "Unsupported RNA override operation on modifiers collection"); | ||||
| Object *ob_dst = (Object *)ptr_dst->owner_id; | Object *ob_dst = (Object *)ptr_dst->owner_id; | ||||
| Object *ob_src = (Object *)ptr_src->owner_id; | Object *ob_src = (Object *)ptr_src->owner_id; | ||||
| /* Remember that insertion operations are defined and stored in correct order, which means that | /* Remember that insertion operations are defined and stored in correct order, which means that | ||||
| * even if we insert several items in a row, we always insert first one, then second one, etc. | * even if we insert several items in a row, we always insert first one, then second one, etc. | ||||
| * So we should always find 'anchor' modifier in both _src *and* _dst. */ | * So we should always find 'anchor' modifier in both _src *and* _dst. */ | ||||
| ModifierData *mod_anchor = NULL; | const size_t name_offset = offsetof(ModifierData, name); | ||||
| if (opop->subitem_local_name && opop->subitem_local_name[0]) { | ModifierData *mod_anchor = BLI_listbase_string_or_index_find(&ob_dst->modifiers, | ||||
| mod_anchor = BLI_findstring( | opop->subitem_reference_name, | ||||
| &ob_dst->modifiers, opop->subitem_local_name, offsetof(ModifierData, name)); | name_offset, | ||||
| } | opop->subitem_reference_index); | ||||
| if (mod_anchor == NULL && opop->subitem_local_index >= 0) { | /* If `mod_anchor` is NULL, `mod_src` will be inserted in first position. */ | ||||
| mod_anchor = BLI_findlink(&ob_dst->modifiers, opop->subitem_local_index); | |||||
| } | |||||
| /* Otherwise we just insert in first position. */ | |||||
| ModifierData *mod_src = NULL; | ModifierData *mod_src = BLI_listbase_string_or_index_find( | ||||
| if (opop->subitem_local_name && opop->subitem_local_name[0]) { | &ob_src->modifiers, opop->subitem_local_name, name_offset, opop->subitem_local_index); | ||||
| mod_src = BLI_findstring( | |||||
| &ob_src->modifiers, opop->subitem_local_name, offsetof(ModifierData, name)); | |||||
| } | |||||
| if (mod_src == NULL && opop->subitem_local_index >= 0) { | |||||
| mod_src = BLI_findlink(&ob_src->modifiers, opop->subitem_local_index); | |||||
| } | |||||
| mod_src = mod_src ? mod_src->next : ob_src->modifiers.first; | |||||
| if (mod_src == NULL) { | if (mod_src == NULL) { | ||||
| BLI_assert(mod_src != NULL); | BLI_assert(mod_src != NULL); | ||||
| return false; | return false; | ||||
| } | } | ||||
| /* While it would be nicer to use lower-level BKE_modifier_new() here, this one is lacking | /* While it would be nicer to use lower-level BKE_modifier_new() here, this one is lacking | ||||
| * special-cases handling (particles and other physics modifiers mostly), so using the ED version | * special-cases handling (particles and other physics modifiers mostly), so using the ED version | ||||
| ▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | BLI_assert(opop->operation == IDOVERRIDE_LIBRARY_OP_INSERT_AFTER && | ||||
| "Unsupported RNA override operation on modifiers collection"); | "Unsupported RNA override operation on modifiers collection"); | ||||
| Object *ob_dst = (Object *)ptr_dst->owner_id; | Object *ob_dst = (Object *)ptr_dst->owner_id; | ||||
| Object *ob_src = (Object *)ptr_src->owner_id; | Object *ob_src = (Object *)ptr_src->owner_id; | ||||
| /* Remember that insertion operations are defined and stored in correct order, which means that | /* Remember that insertion operations are defined and stored in correct order, which means that | ||||
| * even if we insert several items in a row, we always insert first one, then second one, etc. | * even if we insert several items in a row, we always insert first one, then second one, etc. | ||||
| * So we should always find 'anchor' modifier in both _src *and* _dst. */ | * So we should always find 'anchor' modifier in both _src *and* _dst. */ | ||||
| GpencilModifierData *mod_anchor = NULL; | const size_t name_offset = offsetof(GpencilModifierData, name); | ||||
| if (opop->subitem_local_name && opop->subitem_local_name[0]) { | GpencilModifierData *mod_anchor = BLI_listbase_string_or_index_find( | ||||
| mod_anchor = BLI_findstring( | &ob_dst->greasepencil_modifiers, | ||||
| &ob_dst->greasepencil_modifiers, opop->subitem_local_name, offsetof(ModifierData, name)); | opop->subitem_reference_name, | ||||
| } | name_offset, | ||||
| if (mod_anchor == NULL && opop->subitem_local_index >= 0) { | opop->subitem_reference_index); | ||||
| mod_anchor = BLI_findlink(&ob_dst->greasepencil_modifiers, opop->subitem_local_index); | /* If `mod_anchor` is NULL, `mod_src` will be inserted in first position. */ | ||||
| } | |||||
| /* Otherwise we just insert in first position. */ | GpencilModifierData *mod_src = BLI_listbase_string_or_index_find(&ob_src->greasepencil_modifiers, | ||||
| opop->subitem_local_name, | |||||
| GpencilModifierData *mod_src = NULL; | name_offset, | ||||
| if (opop->subitem_local_name && opop->subitem_local_name[0]) { | opop->subitem_local_index); | ||||
| mod_src = BLI_findstring( | |||||
| &ob_src->greasepencil_modifiers, opop->subitem_local_name, offsetof(ModifierData, name)); | |||||
| } | |||||
| if (mod_src == NULL && opop->subitem_local_index >= 0) { | |||||
| mod_src = BLI_findlink(&ob_src->greasepencil_modifiers, opop->subitem_local_index); | |||||
| } | |||||
| mod_src = mod_src ? mod_src->next : ob_src->greasepencil_modifiers.first; | |||||
| if (mod_src == NULL) { | if (mod_src == NULL) { | ||||
| BLI_assert(mod_src != NULL); | BLI_assert(mod_src != NULL); | ||||
| return false; | return false; | ||||
| } | } | ||||
| /* While it would be nicer to use lower-level BKE_modifier_new() here, this one is lacking | /* While it would be nicer to use lower-level BKE_modifier_new() here, this one is lacking | ||||
| * special-cases handling (particles and other physics modifiers mostly), so using the ED version | * special-cases handling (particles and other physics modifiers mostly), so using the ED version | ||||
| ▲ Show 20 Lines • Show All 1,879 Lines • Show Last 20 Lines | |||||