diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-08-03 11:08:10 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2021-08-09 09:09:30 +0300 |
commit | 168965835c98c51c8f80e564768c9eae5925acbf (patch) | |
tree | b8c73649725e4dd085da96a82a5316d52a96d6bd /source/blender/editors/mesh/editmesh_tools.c | |
parent | 2bb38f302287718a357e995016d68534fdae932e (diff) |
Fix T85436: Separate by loose parts doesn't show new objects
Only the "changed" state from the last edit-object was used,
this meant the operator would not perform the necessary update
with multi-object edit-mode.
Use "changed" & "changed_multi" naming convention.
Diffstat (limited to 'source/blender/editors/mesh/editmesh_tools.c')
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 33e4691bfb5..64b1400e8e9 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -4481,7 +4481,7 @@ static int edbm_separate_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); const int type = RNA_enum_get(op->ptr, "type"); - int retval = 0; + bool changed_multi = false; if (ED_operator_editmesh(C)) { uint bases_len = 0; @@ -4491,6 +4491,7 @@ static int edbm_separate_exec(bContext *C, wmOperator *op) for (uint bs_index = 0; bs_index < bases_len; bs_index++) { Base *base = bases[bs_index]; BMEditMesh *em = BKE_editmesh_from_object(base->object); + bool changed = false; if (type == 0) { if ((em->bm->totvertsel == 0) && (em->bm->totedgesel == 0) && (em->bm->totfacesel == 0)) { @@ -4505,22 +4506,23 @@ static int edbm_separate_exec(bContext *C, wmOperator *op) /* editmode separate */ switch (type) { case MESH_SEPARATE_SELECTED: - retval = mesh_separate_selected(bmain, scene, view_layer, base, em->bm); + changed = mesh_separate_selected(bmain, scene, view_layer, base, em->bm); break; case MESH_SEPARATE_MATERIAL: - retval = mesh_separate_material(bmain, scene, view_layer, base, em->bm); + changed = mesh_separate_material(bmain, scene, view_layer, base, em->bm); break; case MESH_SEPARATE_LOOSE: - retval = mesh_separate_loose(bmain, scene, view_layer, base, em->bm); + changed = mesh_separate_loose(bmain, scene, view_layer, base, em->bm); break; default: BLI_assert(0); break; } - if (retval) { + if (changed) { EDBM_update_generic(base->object->data, true, true); } + changed_multi |= changed; } MEM_freeN(bases); } @@ -4537,7 +4539,7 @@ static int edbm_separate_exec(bContext *C, wmOperator *op) Mesh *me = ob->data; if (!ID_IS_LINKED(me)) { BMesh *bm_old = NULL; - int retval_iter = 0; + bool changed = false; bm_old = BM_mesh_create(&bm_mesh_allocsize_default, &((struct BMeshCreateParams){ @@ -4548,17 +4550,17 @@ static int edbm_separate_exec(bContext *C, wmOperator *op) switch (type) { case MESH_SEPARATE_MATERIAL: - retval_iter = mesh_separate_material(bmain, scene, view_layer, base_iter, bm_old); + changed = mesh_separate_material(bmain, scene, view_layer, base_iter, bm_old); break; case MESH_SEPARATE_LOOSE: - retval_iter = mesh_separate_loose(bmain, scene, view_layer, base_iter, bm_old); + changed = mesh_separate_loose(bmain, scene, view_layer, base_iter, bm_old); break; default: BLI_assert(0); break; } - if (retval_iter) { + if (changed) { BM_mesh_bm_to_me(bmain, bm_old, me, @@ -4572,14 +4574,14 @@ static int edbm_separate_exec(bContext *C, wmOperator *op) BM_mesh_free(bm_old); - retval |= retval_iter; + changed_multi |= changed; } } } CTX_DATA_END; } - if (retval) { + if (changed_multi) { /* delay depsgraph recalc until all objects are duplicated */ DEG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, NULL); |