Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Vazquez <blendergit@gmail.com>2020-05-07 10:57:28 +0300
committerAntonio Vazquez <blendergit@gmail.com>2020-05-07 10:58:08 +0300
commita834c819ee25d0107ad0d53786d67f3b766b37a6 (patch)
tree75c6119833112425247039e6625bf724bc14d77c /source/blender/blenkernel/intern/object.c
parentb1374a8ce99bcc307e47bc9a96032a464bbf385f (diff)
GPencil: Add support for Link Modifiers
This adds support to the Link modifiers data. This was missing. Also I did a small cleanup using LISTBASE_FOREACH macro. Related to T76478 Reviewed By: campbellbarton Differential Revision: https://developer.blender.org/D7643
Diffstat (limited to 'source/blender/blenkernel/intern/object.c')
-rw-r--r--source/blender/blenkernel/intern/object.c74
1 files changed, 46 insertions, 28 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 4df8b6f595a..ba0e113d25c 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -544,48 +544,66 @@ bool BKE_object_support_modifier_type_check(const Object *ob, int modifier_type)
void BKE_object_link_modifiers(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)) {
+ 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;
}
- for (md = ob_src->modifiers.first; md; md = md->next) {
- ModifierData *nmd = NULL;
+ /* 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;
- if (ELEM(md->type, eModifierType_Hook, eModifierType_Collision)) {
- continue;
- }
+ if (ELEM(md->type, eModifierType_Hook, eModifierType_Collision)) {
+ continue;
+ }
- if (!BKE_object_support_modifier_type_check(ob_dst, md->type)) {
- continue;
- }
+ if (!BKE_object_support_modifier_type_check(ob_dst, md->type)) {
+ continue;
+ }
- switch (md->type) {
- case eModifierType_Softbody:
- BKE_object_copy_softbody(ob_dst, ob_src, 0);
- break;
- case eModifierType_Skin:
- /* ensure skin-node customdata exists */
- BKE_mesh_ensure_skin_customdata(ob_dst->data);
- break;
- }
+ switch (md->type) {
+ case eModifierType_Softbody:
+ BKE_object_copy_softbody(ob_dst, ob_src, 0);
+ break;
+ case eModifierType_Skin:
+ /* ensure skin-node customdata exists */
+ BKE_mesh_ensure_skin_customdata(ob_dst->data);
+ break;
+ }
- nmd = modifier_new(md->type);
- BLI_strncpy(nmd->name, md->name, sizeof(nmd->name));
+ nmd = modifier_new(md->type);
+ BLI_strncpy(nmd->name, md->name, sizeof(nmd->name));
- if (md->type == eModifierType_Multires) {
- /* Has to be done after mod creation, but *before* we actually copy its settings! */
- multiresModifier_sync_levels_ex(
- ob_dst, (MultiresModifierData *)md, (MultiresModifierData *)nmd);
+ if (md->type == eModifierType_Multires) {
+ /* Has to be done after mod creation, but *before* we actually copy its settings! */
+ multiresModifier_sync_levels_ex(
+ ob_dst, (MultiresModifierData *)md, (MultiresModifierData *)nmd);
+ }
+
+ modifier_copyData(md, nmd);
+ BLI_addtail(&ob_dst->modifiers, nmd);
+ modifier_unique_name(&ob_dst->modifiers, nmd);
}
+ }
- modifier_copyData(md, nmd);
- BLI_addtail(&ob_dst->modifiers, nmd);
- modifier_unique_name(&ob_dst->modifiers, nmd);
+ /* Copy grease pencil modifiers. */
+ if ((ob_src->type == OB_GPENCIL) && (ob_dst->type == OB_GPENCIL)) {
+ LISTBASE_FOREACH (GpencilModifierData *, md, &ob_src->greasepencil_modifiers) {
+ GpencilModifierData *nmd = NULL;
+
+ nmd = BKE_gpencil_modifier_new(md->type);
+ BLI_strncpy(nmd->name, md->name, sizeof(nmd->name));
+
+ const GpencilModifierTypeInfo *mti = BKE_gpencil_modifierType_getInfo(md->type);
+ mti->copyData(md, nmd);
+
+ BLI_addtail(&ob_dst->greasepencil_modifiers, nmd);
+ BKE_gpencil_modifier_unique_name(&ob_dst->greasepencil_modifiers, nmd);
+ }
}
BKE_object_copy_particlesystems(ob_dst, ob_src, 0);