diff --git a/source/blender/editors/geometry/node_group_operator.cc b/source/blender/editors/geometry/node_group_operator.cc index 1ccfeb44f53..453a4ad9afa 100644 --- a/source/blender/editors/geometry/node_group_operator.cc +++ b/source/blender/editors/geometry/node_group_operator.cc @@ -223,18 +223,20 @@ static void store_result_geometry( new_mesh->attributes_for_write().remove_anonymous(); BKE_object_material_from_eval_data(&bmain, &object, &new_mesh->id); - BKE_mesh_nomain_to_mesh(new_mesh, &mesh, &object); + if (object.mode == OB_MODE_EDIT) { + EDBM_mesh_make_from_mesh(&object, new_mesh, scene.toolsettings->selectmode, true); + BKE_editmesh_looptris_and_normals_calc(mesh.edit_mesh); + } + else { + BKE_mesh_nomain_to_mesh(new_mesh, &mesh, &object); + } } if (has_shape_keys && !mesh.key) { BKE_report(op.reports, RPT_WARNING, "Mesh shape key data removed"); } - if (object.mode == OB_MODE_EDIT) { - EDBM_mesh_make(&object, scene.toolsettings->selectmode, true); - BKE_editmesh_looptris_and_normals_calc(mesh.edit_mesh); - } - else if (object.mode == OB_MODE_SCULPT) { + if (object.mode == OB_MODE_SCULPT) { sculpt_paint::undo::geometry_end(&object); } break; diff --git a/source/blender/editors/include/ED_mesh.hh b/source/blender/editors/include/ED_mesh.hh index 15b64e82dab..0de58280dec 100644 --- a/source/blender/editors/include/ED_mesh.hh +++ b/source/blender/editors/include/ED_mesh.hh @@ -77,6 +77,8 @@ void EDBM_mesh_clear(BMEditMesh *em); void EDBM_selectmode_to_scene(bContext *C); void EDBM_mesh_make(Object *ob, int select_mode, bool add_key_index); +/** Replaces the edit-mesh in the object with a new one based on the given mesh. */ +void EDBM_mesh_make_from_mesh(Object *ob, Mesh *src_mesh, int select_mode, bool add_key_index); /** * Should only be called on the active edit-mesh, otherwise call #BKE_editmesh_free_data. */ diff --git a/source/blender/editors/mesh/editmesh_utils.cc b/source/blender/editors/mesh/editmesh_utils.cc index 3936caaf293..40fe380e3ca 100644 --- a/source/blender/editors/mesh/editmesh_utils.cc +++ b/source/blender/editors/mesh/editmesh_utils.cc @@ -265,11 +265,20 @@ bool EDBM_op_call_silentf(BMEditMesh *em, const char *fmt, ...) * \{ */ void EDBM_mesh_make(Object *ob, const int select_mode, const bool add_key_index) +{ + Mesh *mesh = static_cast(ob->data); + EDBM_mesh_make_from_mesh(ob, mesh, select_mode, add_key_index); +} + +void EDBM_mesh_make_from_mesh(Object *ob, + Mesh *src_mesh, + const int select_mode, + const bool add_key_index) { Mesh *mesh = static_cast(ob->data); BMeshCreateParams create_params{}; create_params.use_toolflags = true; - BMesh *bm = BKE_mesh_to_bmesh(mesh, ob, add_key_index, &create_params); + BMesh *bm = BKE_mesh_to_bmesh(src_mesh, ob, add_key_index, &create_params); if (mesh->edit_mesh) { /* this happens when switching shape keys */