diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-01-07 07:39:08 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-01-07 07:39:08 +0300 |
commit | 32b7056acd0a31e1d94fc3ed243d249baac04e92 (patch) | |
tree | 4d8b196b54d14a3e8020c75e7bc57c31956566dc /source/blender | |
parent | 9d7abce359f60eefb78e5edaf21aa24322a6f511 (diff) |
BMesh: remove BMEditMesh.ob use for ED_mesh_mirror_* API
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/include/ED_mesh.h | 8 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_utils.c | 3 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_mirror.c | 32 | ||||
-rw-r--r-- | source/blender/editors/mesh/meshtools.c | 21 |
4 files changed, 39 insertions, 25 deletions
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index e1330f8b9e7..1153944068e 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -336,11 +336,11 @@ typedef struct MirrTopoStore_t { bool prev_is_editmode; } MirrTopoStore_t; -bool ED_mesh_mirrtopo_recalc_check(struct Mesh *me, - struct Mesh *me_eval, +bool ED_mesh_mirrtopo_recalc_check(struct BMEditMesh *em, + struct Mesh *me, MirrTopoStore_t *mesh_topo_store); -void ED_mesh_mirrtopo_init(struct Mesh *me, - struct Mesh *me_eval, +void ED_mesh_mirrtopo_init(struct BMEditMesh *em, + struct Mesh *me, MirrTopoStore_t *mesh_topo_store, const bool skip_em_vert_array_init); void ED_mesh_mirrtopo_free(MirrTopoStore_t *mesh_topo_store); diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index 67f8db71e54..2cfb66b57f5 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -1061,7 +1061,6 @@ void EDBM_verts_mirror_cache_begin_ex(BMEditMesh *em, float maxdist, int *r_index) { - Mesh *me = (Mesh *)em->ob->data; BMesh *bm = em->bm; BMIter iter; BMVert *v; @@ -1094,7 +1093,7 @@ void EDBM_verts_mirror_cache_begin_ex(BMEditMesh *em, BM_mesh_elem_index_ensure(bm, BM_VERT); if (use_topology) { - ED_mesh_mirrtopo_init(me, NULL, &mesh_topo_store, true); + ED_mesh_mirrtopo_init(em, NULL, &mesh_topo_store, true); } else { tree = BLI_kdtree_3d_new(bm->totvert); diff --git a/source/blender/editors/mesh/mesh_mirror.c b/source/blender/editors/mesh/mesh_mirror.c index e086eda9b33..628c8273bc5 100644 --- a/source/blender/editors/mesh/mesh_mirror.c +++ b/source/blender/editors/mesh/mesh_mirror.c @@ -148,19 +148,15 @@ static int mirrtopo_vert_sort(const void *v1, const void *v2) return 0; } -bool ED_mesh_mirrtopo_recalc_check(Mesh *me, Mesh *me_eval, MirrTopoStore_t *mesh_topo_store) +bool ED_mesh_mirrtopo_recalc_check(BMEditMesh *em, Mesh *me, MirrTopoStore_t *mesh_topo_store) { - const bool is_editmode = (me->edit_mesh != NULL); + const bool is_editmode = em != NULL; int totvert; int totedge; - if (me_eval) { - totvert = me_eval->totvert; - totedge = me_eval->totedge; - } - else if (me->edit_mesh) { - totvert = me->edit_mesh->bm->totvert; - totedge = me->edit_mesh->bm->totedge; + if (em) { + totvert = em->bm->totvert; + totedge = em->bm->totedge; } else { totvert = me->totvert; @@ -177,14 +173,16 @@ bool ED_mesh_mirrtopo_recalc_check(Mesh *me, Mesh *me_eval, MirrTopoStore_t *mes } } -void ED_mesh_mirrtopo_init(Mesh *me, - Mesh *me_eval, +void ED_mesh_mirrtopo_init(BMEditMesh *em, + Mesh *me, MirrTopoStore_t *mesh_topo_store, const bool skip_em_vert_array_init) { - const bool is_editmode = (me->edit_mesh != NULL); + if (em) { + BLI_assert(me == NULL); + } + const bool is_editmode = (em != NULL); MEdge *medge = NULL, *med; - BMEditMesh *em = me_eval ? NULL : me->edit_mesh; /* editmode*/ BMEdge *eed; @@ -213,14 +211,14 @@ void ED_mesh_mirrtopo_init(Mesh *me, totvert = em->bm->totvert; } else { - totvert = me_eval ? me_eval->totvert : me->totvert; + totvert = me->totvert; } topo_hash = MEM_callocN(totvert * sizeof(MirrTopoHash_t), "TopoMirr"); /* Initialize the vert-edge-user counts used to detect unique topology */ if (em) { - totedge = me->edit_mesh->bm->totedge; + totedge = em->bm->totedge; BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) { const int i1 = BM_elem_index_get(eed->v1), i2 = BM_elem_index_get(eed->v2); @@ -229,8 +227,8 @@ void ED_mesh_mirrtopo_init(Mesh *me, } } else { - totedge = me_eval ? me_eval->totedge : me->totedge; - medge = me_eval ? me_eval->medge : me->medge; + totedge = me->totedge; + medge = me->medge; for (a = 0, med = medge; a < totedge; a++, med++) { const unsigned int i1 = med->v1, i2 = med->v2; diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 772e7446430..380d9100ed4 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -801,13 +801,30 @@ static MirrTopoStore_t mesh_topo_store = {NULL, -1. - 1, -1}; */ int ED_mesh_mirror_topo_table(Object *ob, Mesh *me_eval, char mode) { + + Mesh *me_mirror = NULL; + BMEditMesh *em_mirror = NULL; + + if (mode != 'e') { + Mesh *me = ob->data; + if (me_eval != NULL) { + me_mirror = me_eval; + } + else if (me->edit_mesh != NULL) { + em_mirror = me->edit_mesh; + } + else { + me_mirror = me; + } + } + if (mode == 'u') { /* use table */ - if (ED_mesh_mirrtopo_recalc_check(ob->data, me_eval, &mesh_topo_store)) { + if (ED_mesh_mirrtopo_recalc_check(em_mirror, me_mirror, &mesh_topo_store)) { ED_mesh_mirror_topo_table(ob, me_eval, 's'); } } else if (mode == 's') { /* start table */ - ED_mesh_mirrtopo_init(ob->data, me_eval, &mesh_topo_store, false); + ED_mesh_mirrtopo_init(em_mirror, me_mirror, &mesh_topo_store, false); } else if (mode == 'e') { /* end table */ ED_mesh_mirrtopo_free(&mesh_topo_store); |