BMesh: remove BMEditMesh.ob use for ED_mesh_mirror_* API
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user