Cleanup: remove automerge BMesh operator

Move logic into EDBM_automerge since this is meant to run after
transform and isn't a generic editing operation.
This commit is contained in:
2019-08-28 13:12:25 +10:00
parent f93b69c17a
commit ed066f231d
4 changed files with 23 additions and 62 deletions

View File

@@ -368,28 +368,6 @@ static BMOpDefine bmo_remove_doubles_def = {
BMO_OPTYPE_FLAG_SELECT_VALIDATE),
};
/*
* Auto Merge.
*
* Finds groups of vertices closer then **dist** and merges them together,
* using the weld verts bmop. The merges must go from a vert not in
* **verts** to one in **verts**.
*/
static BMOpDefine bmo_automerge_def = {
"automerge",
/* slots_in */
{{"verts", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT}}, /* input verts */
{"dist", BMO_OP_SLOT_FLT}, /* maximum distance */
{{'\0'}},
},
{{{'\0'}}}, /* no output */
bmo_automerge_exec,
(BMO_OPTYPE_FLAG_UNTAN_MULTIRES |
BMO_OPTYPE_FLAG_NORMALS_CALC |
BMO_OPTYPE_FLAG_SELECT_FLUSH |
BMO_OPTYPE_FLAG_SELECT_VALIDATE),
};
/*
* Collapse Connected.
*
@@ -2073,7 +2051,6 @@ static BMOpDefine bmo_symmetrize_def = {
/* clang-format on */
const BMOpDefine *bmo_opdefines[] = {
&bmo_automerge_def,
&bmo_average_vert_facedata_def,
&bmo_beautify_fill_def,
&bmo_bevel_def,

View File

@@ -24,7 +24,6 @@
struct BMOperator;
struct BMesh;
void bmo_automerge_exec(BMesh *bm, BMOperator *op);
void bmo_average_vert_facedata_exec(BMesh *bm, BMOperator *op);
void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op);
void bmo_bevel_exec(BMesh *bm, BMOperator *op);

View File

@@ -706,34 +706,3 @@ void bmo_find_doubles_exec(BMesh *bm, BMOperator *op)
slot_targetmap_out = BMO_slot_get(op->slots_out, "targetmap.out");
bmesh_find_doubles_common(bm, op, op, slot_targetmap_out);
}
void bmo_automerge_exec(BMesh *bm, BMOperator *op)
{
BMOperator findop, weldop;
BMIter viter;
BMVert *v;
/* The "verts" input sent to this op is the set of verts that
* can be merged away into any other verts. Mark all other verts
* as VERT_KEEP. */
BMO_slot_buffer_flag_enable(bm, op->slots_in, "verts", BM_VERT, VERT_IN);
BM_ITER_MESH (v, &viter, bm, BM_VERTS_OF_MESH) {
if (!BMO_vert_flag_test(bm, v, VERT_IN)) {
BMO_vert_flag_enable(bm, v, VERT_KEEP);
}
}
/* Search for doubles among all vertices, but only merge non-VERT_KEEP
* vertices into VERT_KEEP vertices. */
BMO_op_initf(bm, &findop, op->flag, "find_doubles verts=%av keep_verts=%fv", VERT_KEEP);
BMO_slot_copy(op, slots_in, "dist", &findop, slots_in, "dist");
BMO_op_exec(bm, &findop);
/* weld the vertices */
BMO_op_init(bm, &weldop, op->flag, "weld_verts");
BMO_slot_copy(&findop, slots_out, "targetmap.out", &weldop, slots_in, "targetmap");
BMO_op_exec(bm, &weldop);
BMO_op_finish(bm, &findop);
BMO_op_finish(bm, &weldop);
}

View File

@@ -56,16 +56,32 @@
void EDBM_automerge(Scene *scene, Object *obedit, bool update, const char hflag)
{
bool ok;
BMEditMesh *em = BKE_editmesh_from_object(obedit);
BMesh *bm = em->bm;
int totvert_prev = bm->totvert;
ok = BMO_op_callf(em->bm,
BMO_FLAG_DEFAULTS,
"automerge verts=%hv dist=%f",
hflag,
scene->toolsettings->doublimit);
BMOperator findop, weldop;
if (LIKELY(ok) && update) {
/* Search for doubles among all vertices, but only merge non-VERT_KEEP
* vertices into VERT_KEEP vertices. */
BMO_op_initf(bm,
&findop,
BMO_FLAG_DEFAULTS,
"find_doubles verts=%av keep_verts=%Hv dist=%f",
hflag,
scene->toolsettings->doublimit);
BMO_op_exec(bm, &findop);
/* weld the vertices */
BMO_op_init(bm, &weldop, BMO_FLAG_DEFAULTS, "weld_verts");
BMO_slot_copy(&findop, slots_out, "targetmap.out", &weldop, slots_in, "targetmap");
BMO_op_exec(bm, &weldop);
BMO_op_finish(bm, &findop);
BMO_op_finish(bm, &weldop);
if ((totvert_prev != bm->totvert) && update) {
EDBM_update_generic(em, true, true);
}
}