Merge branch 'master' into blender2.8
authorCampbell Barton <ideasman42@gmail.com>
Mon, 19 Feb 2018 06:46:42 +0000 (17:46 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 19 Feb 2018 06:46:42 +0000 (17:46 +1100)
source/blender/blenkernel/intern/scene.c
source/blender/bmesh/intern/bmesh_mesh_conv.c
source/blender/bmesh/intern/bmesh_mesh_conv.h
source/blender/bmesh/intern/bmesh_opdefines.c
source/blender/bmesh/operators/bmo_mesh_conv.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/mesh/editmesh_undo.c
source/blender/editors/mesh/editmesh_utils.c
source/blender/python/bmesh/bmesh_py_types.c

index 932f80c35d523c1858461cb32693626fb24f589f..899a911270f0383cd2fb8fbc671f91f4a7f552fa 100644 (file)
@@ -1396,7 +1396,11 @@ static void prepare_mesh_for_viewport_render(Main *bmain, const EvaluationContex
                {
                        if (check_rendered_viewport_visible(bmain)) {
                                BMesh *bm = mesh->edit_btmesh->bm;
-                               BM_mesh_bm_to_me(bm, mesh, (&(struct BMeshToMeshParams){0}));
+                               BM_mesh_bm_to_me(
+                                       bm, mesh,
+                                       (&(struct BMeshToMeshParams){
+                                           .calc_object_remap = true,
+                                       }));
                                DEG_id_tag_update(&mesh->id, 0);
                        }
                }
index 6cc1f37db439d337fad170085620cd9713320106..fd32119cb5fa9f22d5d99ddc741cc278377c48b5 100644 (file)
@@ -708,7 +708,7 @@ void BM_mesh_bm_to_me(
        }
 
        /* patch hook indices and vertex parents */
-       if (ototvert > 0) {
+       if (params->calc_object_remap && (ototvert > 0)) {
                Object *ob;
                ModifierData *md;
                BMVert **vertMap = NULL;
@@ -765,11 +765,7 @@ void BM_mesh_bm_to_me(
                if (vertMap) MEM_freeN(vertMap);
        }
 
-       if (params->calc_tessface) {
-               BKE_mesh_tessface_calc(me);
-       }
-
-       BKE_mesh_update_customdata_pointers(me, params->calc_tessface);
+       BKE_mesh_update_customdata_pointers(me, false);
 
        {
                BMEditSelection *selected;
index 1974d364171d06975ada2c8dec3835511b8591f9..6e9d62349ea283e6bd0398f4d5a2f578daee580c 100644 (file)
@@ -55,7 +55,8 @@ void BM_mesh_bm_from_me(
 ATTR_NONNULL(1, 3);
 
 struct BMeshToMeshParams {
-       uint calc_tessface : 1;
+       /** Update object hook indices & vertex parents. */
+       uint calc_object_remap : 1;
        int64_t cd_mask_extra;
 };
 void BM_mesh_bm_to_me(
index 8e0e905cf883e567c2d713fefd9d3af66af52a66..4847ae4be4209fb45fcf07c161a14715e598c854 100644 (file)
@@ -843,7 +843,6 @@ static BMOpDefine bmo_bmesh_to_mesh_def = {
         {"mesh", BMO_OP_SLOT_PTR, {(int)BMO_OP_SLOT_SUBTYPE_PTR_MESH}},
        /* pointer to an object structure */
         {"object", BMO_OP_SLOT_PTR, {(int)BMO_OP_SLOT_SUBTYPE_PTR_OBJECT}},
-        {"skip_tessface", BMO_OP_SLOT_BOOL},  /* don't calculate mfaces */
         {{'\0'}},
        },
        {{{'\0'}}},  /* no output */
index 0eb9bf90ca812eafe87d5069371064a98c6e77cf..7311ed5ce64f283539dba92db8a65e98d56a55b0 100644 (file)
@@ -62,15 +62,18 @@ void bmo_object_load_bmesh_exec(BMesh *bm, BMOperator *op)
        Mesh *me = ob->data;
 
        BMO_op_callf(bm, op->flag,
-                    "bmesh_to_mesh mesh=%p object=%p skip_tessface=%b",
-                    me, ob, true);
+                    "bmesh_to_mesh mesh=%p object=%p",
+                    me, ob);
 }
 
 void bmo_bmesh_to_mesh_exec(BMesh *bm, BMOperator *op)
 {
        Mesh *me = BMO_slot_ptr_get(op->slots_in, "mesh");
        /* Object *ob = BMO_slot_ptr_get(op, "object"); */
-       const bool dotess = !BMO_slot_bool_get(op->slots_in, "skip_tessface");
 
-       BM_mesh_bm_to_me(bm, me, (&(struct BMeshToMeshParams){ .calc_tessface = dotess, }));
+       BM_mesh_bm_to_me(
+               bm, me,
+               (&(struct BMeshToMeshParams){
+                   .calc_object_remap = true,
+               }));
 }
index ff1cd7224cd3f21b2811e7a2ee44ab71bb1137f3..a71b03b6ff7a2f290d9600358b25c9193d33b9e6 100644 (file)
@@ -3374,7 +3374,11 @@ static int edbm_separate_exec(bContext *C, wmOperator *op)
                                        }
 
                                        if (retval_iter) {
-                                               BM_mesh_bm_to_me(bm_old, me, (&(struct BMeshToMeshParams){0}));
+                                               BM_mesh_bm_to_me(
+                                                       bm_old, me,
+                                                       (&(struct BMeshToMeshParams){
+                                                           .calc_object_remap = true,
+                                                       }));
 
                                                DEG_id_tag_update(&me->id, OB_RECALC_DATA);
                                                WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
index 534ca22178eabfd1c9a5b6284d9395bb51fdde65..11667ed571051068361ed7c3ed4e1bf1b0340a51 100644 (file)
@@ -496,6 +496,8 @@ static void *editbtMesh_to_undoMesh(void *emv, void *obdata)
 
        BM_mesh_bm_to_me(
                em->bm, &um->me, (&(struct BMeshToMeshParams){
+                   /* Undo code should not be manipulating 'G.main->object' hooks/vertex-parent. */
+                   .calc_object_remap = false,
                    .cd_mask_extra = CD_MASK_SHAPE_KEYINDEX,
                }));
 
index 132ac0d30b73bb5f72002e712f2ed8015211b3ce..7b727e75b559f2245c291d945d36466afc6d8406 100644 (file)
@@ -381,7 +381,10 @@ void EDBM_mesh_load(Object *ob)
                bm->shapenr = 1;
        }
 
-       BM_mesh_bm_to_me(bm, me, (&(struct BMeshToMeshParams){0}));
+       BM_mesh_bm_to_me(
+               bm, me, (&(struct BMeshToMeshParams){
+                   .calc_object_remap = true,
+               }));
 
 #ifdef USE_TESSFACE_DEFAULT
        BKE_mesh_tessface_calc(me);
index 629c3a3c7a33abcaf65ce45496079d33054e812e..ec787768a57bb36bebe8273d537c03a486aee6bb 100644 (file)
@@ -902,7 +902,11 @@ static PyObject *bpy_bmesh_to_mesh(BPy_BMesh *self, PyObject *args)
 
        bm = self->bm;
 
-       BM_mesh_bm_to_me(bm, me, (&(struct BMeshToMeshParams){0}));
+       BM_mesh_bm_to_me(
+               bm, me,
+               (&(struct BMeshToMeshParams){
+                   .calc_object_remap = true,
+               }));
 
        /* we could have the user do this but if they forget blender can easy crash
         * since the references arrays for the objects derived meshes are now invalid */