diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2016-07-11 22:27:15 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2016-07-11 22:30:02 +0300 |
commit | 7212ebd09f9720883581221be923ae5e97ff5d76 (patch) | |
tree | 546606626647d473ae9d4a037ce8e24e17943e08 /source/blender/blenkernel/intern/mesh.c | |
parent | 3b8e0606e1cfa484971d09c5060a78dbadbe1569 (diff) |
Remove usercount handling from BKE_id_expand_local.
Idea looked good, but we have too much custom situations here (some half-fake-sub-ID
being copied with their 'owner', animdata, etc.), let's let datablock copy functions
handle that themselves.
Also allows to safely call BKE_id_expand_local from all copy functions now (only when
copying linked data).
Diffstat (limited to 'source/blender/blenkernel/intern/mesh.c')
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 66adea04f67..787b9905734 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -496,11 +496,16 @@ Mesh *BKE_mesh_add(Main *bmain, const char *name) Mesh *BKE_mesh_copy(Main *bmain, Mesh *me) { Mesh *men; + int a; const int do_tessface = ((me->totface != 0) && (me->totpoly == 0)); /* only do tessface if we have no polys */ men = BKE_libblock_copy(bmain, &me->id); men->mat = MEM_dupallocN(me->mat); + for (a = 0; a < men->totcol; a++) { + id_us_plus((ID *)men->mat[a]); + } + id_us_plus((ID *)men->texcomesh); CustomData_copy(&me->vdata, &men->vdata, CD_MASK_MESH, CD_DUPLICATE, men->totvert); CustomData_copy(&me->edata, &men->edata, CD_MASK_MESH, CD_DUPLICATE, men->totedge); @@ -522,13 +527,11 @@ Mesh *BKE_mesh_copy(Main *bmain, Mesh *me) if (me->key) { men->key = BKE_key_copy(bmain, me->key); - men->id.us = 0; /* Will be increased again by BKE_id_expand_local. */ men->key->from = (ID *)men; } - BKE_id_expand_local(&men->id, true); - if (ID_IS_LINKED_DATABLOCK(me)) { + BKE_id_expand_local(&men->id); BKE_id_lib_local_paths(bmain, me->id.lib, &men->id); } @@ -573,7 +576,7 @@ void BKE_mesh_make_local(Main *bmain, Mesh *me) if (me->key) { BKE_key_make_local(bmain, me->key); } - BKE_id_expand_local(&me->id, false); + BKE_id_expand_local(&me->id); } else { Mesh *me_new = BKE_mesh_copy(bmain, me); |