Merge branch 'temp_remove_particles' into blender2.8
[blender.git] / source / blender / editors / object / object_edit.c
index 2a199068a3b2a907c71a01d041abadf9848f898a..5b4364076f2cd87db8d85bc247c20017e931c5ac 100644 (file)
@@ -316,6 +316,27 @@ void OBJECT_OT_hide_render_set(wmOperatorType *ot)
 
 /* ******************* toggle editmode operator  ***************** */
 
+static bool mesh_needs_keyindex(const Mesh *me)
+{
+       if (me->key) {
+               return false;  /* will be added */
+       }
+
+       for (const Object *ob = G.main->object.first; ob; ob = ob->id.next) {
+               if ((ob->parent) && (ob->parent->data == me) && ELEM(ob->partype, PARVERT1, PARVERT3)) {
+                       return true;
+               }
+               if (ob->data == me) {
+                       for (const ModifierData *md = ob->modifiers.first; md; md = md->next) {
+                               if (md->type == eModifierType_Hook) {
+                                       return true;
+                               }
+                       }
+               }
+       }
+       return false;
+}
+
 /**
  * Load EditMode data back into the object,
  * optionally freeing the editmode data.
@@ -493,15 +514,15 @@ void ED_object_editmode_enter(bContext *C, int flag)
                ok = 1;
                scene->obedit = ob;  /* context sees this */
 
-               EDBM_mesh_make(scene->toolsettings, ob);
+               const bool use_key_index = mesh_needs_keyindex(ob->data);
+
+               EDBM_mesh_make(scene->toolsettings, ob, use_key_index);
 
                em = BKE_editmesh_from_object(ob);
                if (LIKELY(em)) {
                        /* order doesn't matter */
                        EDBM_mesh_normals_update(em);
                        BKE_editmesh_tessface_calc(em);
-
-                       BM_mesh_select_mode_flush(em->bm);
                }
 
                WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_MESH, scene);