Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/object.c
| Show First 20 Lines • Show All 672 Lines • ▼ Show 20 Lines | if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) { | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| void BKE_object_link_modifiers(struct Object *ob_dst, const struct Object *ob_src) | bool BKE_object_link_modifier(struct Object *ob_dst, const struct Object *ob_src, ModifierData *md) | ||||
| { | { | ||||
| BKE_object_free_modifiers(ob_dst, 0); | |||||
| if (!ELEM(ob_dst->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE, OB_GPENCIL)) { | |||||
| /* only objects listed above can have modifiers and linking them to objects | |||||
| * which doesn't have modifiers stack is quite silly */ | |||||
| return; | |||||
| } | |||||
| /* No grease pencil modifiers. */ | |||||
| if ((ob_src->type != OB_GPENCIL) && (ob_dst->type != OB_GPENCIL)) { | |||||
| LISTBASE_FOREACH (ModifierData *, md, &ob_src->modifiers) { | |||||
| ModifierData *nmd = NULL; | ModifierData *nmd = NULL; | ||||
| if (ELEM(md->type, eModifierType_Hook, eModifierType_Collision)) { | if (ELEM(md->type, eModifierType_Hook, eModifierType_Collision)) { | ||||
| continue; | return false; | ||||
| } | } | ||||
| if (!BKE_object_support_modifier_type_check(ob_dst, md->type)) { | if (!BKE_object_support_modifier_type_check(ob_dst, md->type)) { | ||||
| continue; | return false; | ||||
| } | } | ||||
| switch (md->type) { | switch (md->type) { | ||||
| case eModifierType_Softbody: | case eModifierType_Softbody: | ||||
| BKE_object_copy_softbody(ob_dst, ob_src, 0); | BKE_object_copy_softbody(ob_dst, ob_src, 0); | ||||
| break; | break; | ||||
| case eModifierType_Skin: | case eModifierType_Skin: | ||||
| /* ensure skin-node customdata exists */ | /* ensure skin-node customdata exists */ | ||||
| BKE_mesh_ensure_skin_customdata(ob_dst->data); | BKE_mesh_ensure_skin_customdata(ob_dst->data); | ||||
| break; | break; | ||||
| } | } | ||||
| nmd = BKE_modifier_new(md->type); | nmd = BKE_modifier_new(md->type); | ||||
| BLI_strncpy(nmd->name, md->name, sizeof(nmd->name)); | BLI_strncpy(nmd->name, md->name, sizeof(nmd->name)); | ||||
| if (md->type == eModifierType_Multires) { | if (md->type == eModifierType_Multires) { | ||||
| /* Has to be done after mod creation, but *before* we actually copy its settings! */ | /* Has to be done after mod creation, but *before* we actually copy its settings! */ | ||||
| multiresModifier_sync_levels_ex( | multiresModifier_sync_levels_ex( | ||||
| ob_dst, (MultiresModifierData *)md, (MultiresModifierData *)nmd); | ob_dst, (MultiresModifierData *)md, (MultiresModifierData *)nmd); | ||||
| } | } | ||||
| BKE_modifier_copydata(md, nmd); | BKE_modifier_copydata(md, nmd); | ||||
| BLI_addtail(&ob_dst->modifiers, nmd); | BLI_addtail(&ob_dst->modifiers, nmd); | ||||
| BKE_modifier_unique_name(&ob_dst->modifiers, nmd); | BKE_modifier_unique_name(&ob_dst->modifiers, nmd); | ||||
| } | |||||
| return true; | |||||
| } | } | ||||
| /* Copy grease pencil modifiers. */ | bool BKE_object_link_gpencil_modifier(struct Object *ob_dst, GpencilModifierData *md) | ||||
| if ((ob_src->type == OB_GPENCIL) && (ob_dst->type == OB_GPENCIL)) { | { | ||||
| LISTBASE_FOREACH (GpencilModifierData *, md, &ob_src->greasepencil_modifiers) { | |||||
| GpencilModifierData *nmd = NULL; | GpencilModifierData *nmd = NULL; | ||||
| nmd = BKE_gpencil_modifier_new(md->type); | nmd = BKE_gpencil_modifier_new(md->type); | ||||
| BLI_strncpy(nmd->name, md->name, sizeof(nmd->name)); | BLI_strncpy(nmd->name, md->name, sizeof(nmd->name)); | ||||
| const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(md->type); | const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(md->type); | ||||
| mti->copyData(md, nmd); | mti->copyData(md, nmd); | ||||
| BLI_addtail(&ob_dst->greasepencil_modifiers, nmd); | BLI_addtail(&ob_dst->greasepencil_modifiers, nmd); | ||||
| BKE_gpencil_modifier_unique_name(&ob_dst->greasepencil_modifiers, nmd); | BKE_gpencil_modifier_unique_name(&ob_dst->greasepencil_modifiers, nmd); | ||||
| return true; | |||||
| } | |||||
| void BKE_object_link_modifiers(struct Object *ob_dst, const struct Object *ob_src) | |||||
| { | |||||
| BKE_object_free_modifiers(ob_dst, 0); | |||||
| if (!ELEM(ob_dst->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE, OB_GPENCIL)) { | |||||
| /* only objects listed above can have modifiers and linking them to objects | |||||
| * which doesn't have modifiers stack is quite silly */ | |||||
| return; | |||||
| } | |||||
| /* No grease pencil modifiers. */ | |||||
| if ((ob_src->type != OB_GPENCIL) && (ob_dst->type != OB_GPENCIL)) { | |||||
| LISTBASE_FOREACH (ModifierData *, md, &ob_src->modifiers) { | |||||
| BKE_object_link_modifier(ob_dst, ob_src, md); | |||||
| } | |||||
| } | |||||
| /* Copy grease pencil modifiers. */ | |||||
| if ((ob_src->type == OB_GPENCIL) && (ob_dst->type == OB_GPENCIL)) { | |||||
| LISTBASE_FOREACH (GpencilModifierData *, md, &ob_src->greasepencil_modifiers) { | |||||
| BKE_object_link_gpencil_modifier(ob_dst, md); | |||||
| } | } | ||||
| } | } | ||||
| BKE_object_copy_particlesystems(ob_dst, ob_src, 0); | BKE_object_copy_particlesystems(ob_dst, ob_src, 0); | ||||
| /* TODO: smoke?, cloth? */ | /* TODO: smoke?, cloth? */ | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 3,955 Lines • Show Last 20 Lines | |||||