diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-07-27 12:18:11 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-07-27 12:18:11 +0400 |
commit | c42b23030b8d25805214dacac78d8d22818db2a2 (patch) | |
tree | f34978dcb9b64a9a1f86b8feaa717efeb1b742f6 /source/blender/blenkernel/intern | |
parent | 61469d2e3e1319c1242f07e604c822c8b310d772 (diff) |
copy support for mask datablocks
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mask.c | 43 |
2 files changed, 45 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index f3ef01425dd..98133b936d5 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -360,6 +360,8 @@ int id_copy(ID *id, ID **newid, int test) return 0; /* can't be copied from here */ case ID_GD: return 0; /* not implemented */ + case ID_MSK: + if (!test) *newid = (ID *)BKE_mask_copy((Mask *)id); } return 0; diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index d963d46569a..801c431265a 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -1330,6 +1330,49 @@ Mask *BKE_mask_new(const char *name) return mask; } +Mask *BKE_mask_copy_nolib(Mask *mask) +{ + Mask *mask_new; + + mask_new = MEM_dupallocN(mask); + + /*take care here! - we may want to copy anim data */ + mask_new->adt = NULL; + + mask_new->masklayers.first = NULL; + mask_new->masklayers.last = NULL; + + BKE_mask_layer_copy_list(&mask_new->masklayers, &mask->masklayers); + + /* enable fake user by default */ + if (!(mask_new->id.flag & LIB_FAKEUSER)) { + mask_new->id.flag |= LIB_FAKEUSER; + mask_new->id.us++; + } + + return mask_new; +} + +Mask *BKE_mask_copy(Mask *mask) +{ + Mask *mask_new; + + mask_new = BKE_libblock_copy(&mask->id); + + mask_new->masklayers.first = NULL; + mask_new->masklayers.last = NULL; + + BKE_mask_layer_copy_list(&mask_new->masklayers, &mask->masklayers); + + /* enable fake user by default */ + if (!(mask_new->id.flag & LIB_FAKEUSER)) { + mask_new->id.flag |= LIB_FAKEUSER; + mask_new->id.us++; + } + + return mask_new; +} + void BKE_mask_point_free(MaskSplinePoint *point) { if (point->uw) |