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:
authorBastien Montagne <montagne29@wanadoo.fr>2016-07-11 20:13:42 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2016-07-11 22:30:02 +0300
commit2ec17e655c4fdabc6251b5c81f4404451160923c (patch)
treee733b30bb19cfc0037ffae8a01bac3c57334ebac /source/blender/blenkernel/intern/mesh.c
parent439ccca1e0b7078f3055ec14a7c81e964594ae6b (diff)
Use new generic BKE_id_expand_local() for both make_local() and copy() functions of obdata
(armature, mesh, curve, mball, lattice, lamp, camera, and speaker). This greatly simplifies said code, once again no change expected from user PoV.
Diffstat (limited to 'source/blender/blenkernel/intern/mesh.c')
-rw-r--r--source/blender/blenkernel/intern/mesh.c79
1 files changed, 5 insertions, 74 deletions
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index e737696b3af..cfcc88e97b0 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -496,18 +496,11 @@ Mesh *BKE_mesh_add(Main *bmain, const char *name)
Mesh *BKE_mesh_copy(Main *bmain, Mesh *me)
{
Mesh *men;
- MTFace *tface;
- MTexPoly *txface;
- int a, i;
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,37 +515,19 @@ Mesh *BKE_mesh_copy(Main *bmain, Mesh *me)
BKE_mesh_update_customdata_pointers(men, do_tessface);
- /* ensure indirect linked data becomes lib-extern */
- for (i = 0; i < me->fdata.totlayer; i++) {
- if (me->fdata.layers[i].type == CD_MTFACE) {
- tface = (MTFace *)me->fdata.layers[i].data;
-
- for (a = 0; a < me->totface; a++, tface++)
- if (tface->tpage)
- id_lib_extern((ID *)tface->tpage);
- }
- }
-
- for (i = 0; i < me->pdata.totlayer; i++) {
- if (me->pdata.layers[i].type == CD_MTEXPOLY) {
- txface = (MTexPoly *)me->pdata.layers[i].data;
-
- for (a = 0; a < me->totpoly; a++, txface++)
- if (txface->tpage)
- id_lib_extern((ID *)txface->tpage);
- }
- }
-
men->edit_btmesh = NULL;
men->mselect = MEM_dupallocN(men->mselect);
men->bb = MEM_dupallocN(men->bb);
-
+
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_lib_local_paths(bmain, me->id.lib, &men->id);
}
@@ -577,50 +552,6 @@ BMesh *BKE_mesh_to_bmesh(
return bm;
}
-static int extern_local_mesh_callback(
- void *UNUSED(user_data), struct ID *UNUSED(id_self), struct ID **id_pointer, int cd_flag)
-{
- /* We only tag usercounted ID usages as extern... Why? */
- if ((cd_flag & IDWALK_USER) && *id_pointer) {
- id_lib_extern(*id_pointer);
- }
- return IDWALK_RET_NOP;
-}
-
-static void expand_local_mesh(Mesh *me)
-{
- BKE_library_foreach_ID_link(&me->id, extern_local_mesh_callback, NULL, 0);
-
- /* special case: images assigned to UVLayers always made local immediately - why? */
- if (me->mtface || me->mtpoly) {
- int a, i;
-
- for (i = 0; i < me->pdata.totlayer; i++) {
- if (me->pdata.layers[i].type == CD_MTEXPOLY) {
- MTexPoly *txface = (MTexPoly *)me->pdata.layers[i].data;
-
- for (a = 0; a < me->totpoly; a++, txface++) {
- if (txface->tpage) {
- id_lib_extern((ID *)txface->tpage);
- }
- }
- }
- }
-
- for (i = 0; i < me->fdata.totlayer; i++) {
- if (me->fdata.layers[i].type == CD_MTFACE) {
- MTFace *tface = (MTFace *)me->fdata.layers[i].data;
-
- for (a = 0; a < me->totface; a++, tface++) {
- if (tface->tpage) {
- id_lib_extern((ID *)tface->tpage);
- }
- }
- }
- }
- }
-}
-
void BKE_mesh_make_local(Main *bmain, Mesh *me)
{
bool is_local = false, is_lib = false;
@@ -642,7 +573,7 @@ void BKE_mesh_make_local(Main *bmain, Mesh *me)
if (me->key) {
BKE_key_make_local(bmain, me->key);
}
- expand_local_mesh(me);
+ BKE_id_expand_local(&me->id, false);
}
else {
Mesh *me_new = BKE_mesh_copy(bmain, me);