diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2016-07-25 20:33:55 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2016-07-25 20:33:55 +0300 |
commit | bcc020b1bc1b60f6cbd6d2c9bf400744931e57e1 (patch) | |
tree | fef4d83d0e5addb59c8389adf125281a4c7e35f8 /source/blender/blenkernel/intern/mesh.c | |
parent | 99bb1accbbb8e1ba38f30b073b22deb107bf3220 (diff) | |
parent | 3f36cd3f33e52d53d82a3a221e2a576cf26390a5 (diff) |
Merge branch 'asset-engine' into asset-experimentsasset-experiments
Conflicts:
source/blender/blenloader/intern/readfile.c
Diffstat (limited to 'source/blender/blenkernel/intern/mesh.c')
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 58 |
1 files changed, 13 insertions, 45 deletions
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 787b9905734..733e9030056 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -31,6 +31,7 @@ #include "DNA_scene_types.h" #include "DNA_material_types.h" +#include "DNA_meta_types.h" #include "DNA_object_types.h" #include "DNA_key_types.h" #include "DNA_mesh_types.h" @@ -530,10 +531,7 @@ Mesh *BKE_mesh_copy(Main *bmain, Mesh *me) men->key->from = (ID *)men; } - if (ID_IS_LINKED_DATABLOCK(me)) { - BKE_id_expand_local(&men->id); - BKE_id_lib_local_paths(bmain, me->id.lib, &men->id); - } + BKE_id_copy_ensure_local(bmain, &me->id, &men->id); return men; } @@ -555,37 +553,9 @@ BMesh *BKE_mesh_to_bmesh( return bm; } -void BKE_mesh_make_local(Main *bmain, Mesh *me) +void BKE_mesh_make_local(Main *bmain, Mesh *me, const bool lib_local) { - bool is_local = false, is_lib = false; - - /* - only lib users: do nothing - * - only local users: set flag - * - mixed: make copy - */ - - if (!ID_IS_LINKED_DATABLOCK(me)) { - return; - } - - BKE_library_ID_test_usages(bmain, me, &is_local, &is_lib); - - if (is_local) { - if (!is_lib) { - id_clear_lib_data(bmain, &me->id); - if (me->key) { - BKE_key_make_local(bmain, me->key); - } - BKE_id_expand_local(&me->id); - } - else { - Mesh *me_new = BKE_mesh_copy(bmain, me); - - me_new->id.us = 0; - - BKE_libblock_remap(bmain, me, me_new, ID_REMAP_SKIP_INDIRECT_USAGE); - } - } + BKE_id_make_local_generic(bmain, &me->id, true, lib_local); } bool BKE_mesh_uv_cdlayer_rename_index(Mesh *me, const int poly_index, const int loop_index, const int face_index, @@ -2227,7 +2197,6 @@ Mesh *BKE_mesh_new_from_object( { Mesh *tmpmesh; Curve *tmpcu = NULL, *copycu; - Object *tmpobj = NULL; int render = settings == eModifierMode_Render, i; int cage = !apply_modifiers; @@ -2242,7 +2211,7 @@ Mesh *BKE_mesh_new_from_object( int uv_from_orco; /* copies object and modifiers (but not the data) */ - tmpobj = BKE_object_copy_ex(bmain, ob, true); + Object *tmpobj = BKE_object_copy_ex(bmain, ob, true); tmpcu = (Curve *)tmpobj->data; id_us_min(&tmpcu->id); @@ -2398,23 +2367,25 @@ Mesh *BKE_mesh_new_from_object( } break; -#if 0 - /* Crashes when assigning the new material, not sure why */ case OB_MBALL: - tmpmb = (MetaBall *)ob->data; + { + MetaBall *tmpmb = (MetaBall *)ob->data; + tmpmesh->mat = MEM_dupallocN(tmpmb->mat); tmpmesh->totcol = tmpmb->totcol; /* free old material list (if it exists) and adjust user counts */ if (tmpmb->mat) { for (i = tmpmb->totcol; i-- > 0; ) { - tmpmesh->mat[i] = tmpmb->mat[i]; /* CRASH HERE ??? */ + /* are we an object material or data based? */ + tmpmesh->mat[i] = ob->matbits[i] ? ob->mat[i] : tmpmb->mat[i]; + if (tmpmesh->mat[i]) { - id_us_plus(&tmpmb->mat[i]->id); + id_us_plus(&tmpmesh->mat[i]->id); } } } break; -#endif + } case OB_MESH: if (!cage) { @@ -2442,9 +2413,6 @@ Mesh *BKE_mesh_new_from_object( BKE_mesh_tessface_ensure(tmpmesh); } - /* make sure materials get updated in object */ - test_object_materials(tmpobj ? tmpobj : ob, &tmpmesh->id); - return tmpmesh; } |