more mirror cleanup
- remove BMBVH_FindClosestVertTop - update select mirror operator to EDBM_CacheMirrorVerts
This commit is contained in:
@@ -3945,14 +3945,11 @@ void MESH_OT_select_loose_verts(wmOperatorType *ot)
|
||||
|
||||
static int select_mirror_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
BMEditMesh *em= ((Mesh *)obedit->data)->edit_btmesh;
|
||||
BMBVHTree *tree = BMBVH_NewBVH(em, 0, NULL, NULL);
|
||||
BMVert *v1, *v2;
|
||||
BMIter iter;
|
||||
int extend= RNA_boolean_get(op->ptr, "extend");
|
||||
float mirror_co[3];
|
||||
|
||||
BM_ITER(v1, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
|
||||
if (!BM_TestHFlag(v1, BM_SELECT) || BM_TestHFlag(v1, BM_HIDDEN)) {
|
||||
@@ -3963,6 +3960,8 @@ static int select_mirror_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
}
|
||||
|
||||
EDBM_CacheMirrorVerts(em, FALSE);
|
||||
|
||||
if (!extend)
|
||||
EDBM_clear_flag_all(em, BM_SELECT);
|
||||
|
||||
@@ -3970,14 +3969,14 @@ static int select_mirror_exec(bContext *C, wmOperator *op)
|
||||
if (!BM_TestHFlag(v1, BM_TMP_TAG) || BM_TestHFlag(v1, BM_HIDDEN))
|
||||
continue;
|
||||
|
||||
copy_v3_v3(mirror_co, v1->co);
|
||||
mirror_co[0] *= -1.0f;
|
||||
|
||||
v2 = BMBVH_FindClosestVertTopo(tree, mirror_co, MIRROR_THRESH, v1);
|
||||
if (v2 && !BM_TestHFlag(v2, BM_HIDDEN))
|
||||
v2= EDBM_GetMirrorVert(em, v1);
|
||||
if (v2 && !BM_TestHFlag(v2, BM_HIDDEN)) {
|
||||
BM_Select(em->bm, v2, 1);
|
||||
}
|
||||
}
|
||||
|
||||
EDBM_EndMirrorCache(em);
|
||||
|
||||
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@@ -809,6 +809,7 @@ static BMVert *cache_mirr_intptr_as_bmvert(intptr_t *index_lookup, int index)
|
||||
void EDBM_CacheMirrorVerts(BMEditMesh *em, const short use_select)
|
||||
{
|
||||
Mesh *me = em->me;
|
||||
BMesh *bm = em->bm;
|
||||
BMIter iter;
|
||||
BMVert *v;
|
||||
int li, topo = 0;
|
||||
@@ -826,15 +827,15 @@ void EDBM_CacheMirrorVerts(BMEditMesh *em, const short use_select)
|
||||
em->mirr_free_arrays = 1;
|
||||
}
|
||||
|
||||
if (!CustomData_get_layer_named(&em->bm->vdata, CD_PROP_INT, BM_CD_LAYER_ID)) {
|
||||
BM_add_data_layer_named(em->bm, &em->bm->vdata, CD_PROP_INT, BM_CD_LAYER_ID);
|
||||
if (!CustomData_get_layer_named(&bm->vdata, CD_PROP_INT, BM_CD_LAYER_ID)) {
|
||||
BM_add_data_layer_named(bm, &bm->vdata, CD_PROP_INT, BM_CD_LAYER_ID);
|
||||
}
|
||||
|
||||
li= CustomData_get_named_layer_index(&em->bm->vdata, CD_PROP_INT, BM_CD_LAYER_ID);
|
||||
li= CustomData_get_named_layer_index(&bm->vdata, CD_PROP_INT, BM_CD_LAYER_ID);
|
||||
|
||||
em->bm->vdata.layers[li].flag |= CD_FLAG_TEMPORARY;
|
||||
bm->vdata.layers[li].flag |= CD_FLAG_TEMPORARY;
|
||||
|
||||
BM_ElemIndex_Ensure(em->bm, BM_VERT);
|
||||
BM_ElemIndex_Ensure(bm, BM_VERT);
|
||||
|
||||
if (topo) {
|
||||
ED_mesh_mirrtopo_init(me, -1, &mesh_topo_store, TRUE);
|
||||
@@ -843,28 +844,34 @@ void EDBM_CacheMirrorVerts(BMEditMesh *em, const short use_select)
|
||||
tree= BMBVH_NewBVH(em, 0, NULL, NULL);
|
||||
}
|
||||
|
||||
BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
|
||||
BMVert *mirr;
|
||||
int *idx = CustomData_bmesh_get_layer_n(&em->bm->vdata, v->head.data, li);
|
||||
float co[3] = {-v->co[0], v->co[1], v->co[2]};
|
||||
BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) {
|
||||
|
||||
//temporary for testing, check for selection
|
||||
if (use_select && !BM_TestHFlag(v, BM_SELECT))
|
||||
continue;
|
||||
|
||||
mirr = topo ?
|
||||
/* BMBVH_FindClosestVertTopo(tree, co, BM_SEARCH_MAXDIST_MIRR, v) */
|
||||
cache_mirr_intptr_as_bmvert(mesh_topo_store.index_lookup, BM_GetIndex(v)) :
|
||||
BMBVH_FindClosestVert(tree, co, BM_SEARCH_MAXDIST_MIRR);
|
||||
|
||||
if (mirr && mirr != v) {
|
||||
*idx = BM_GetIndex(mirr);
|
||||
idx = CustomData_bmesh_get_layer_n(&em->bm->vdata,mirr->head.data, li);
|
||||
*idx = BM_GetIndex(v);
|
||||
/* temporary for testing, check for selection */
|
||||
if (use_select && !BM_TestHFlag(v, BM_SELECT)) {
|
||||
/* do nothing */
|
||||
}
|
||||
else {
|
||||
*idx = -1;
|
||||
BMVert *mirr;
|
||||
int *idx = CustomData_bmesh_get_layer_n(&bm->vdata, v->head.data, li);
|
||||
|
||||
if (topo) {
|
||||
mirr= cache_mirr_intptr_as_bmvert(mesh_topo_store.index_lookup, BM_GetIndex(v));
|
||||
}
|
||||
else {
|
||||
float co[3] = {-v->co[0], v->co[1], v->co[2]};
|
||||
mirr= BMBVH_FindClosestVert(tree, co, BM_SEARCH_MAXDIST_MIRR);
|
||||
}
|
||||
|
||||
if (mirr && mirr != v) {
|
||||
*idx = BM_GetIndex(mirr);
|
||||
idx = CustomData_bmesh_get_layer_n(&bm->vdata, mirr->head.data, li);
|
||||
*idx = BM_GetIndex(v);
|
||||
}
|
||||
else {
|
||||
*idx = -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -664,36 +664,6 @@ static void vertsearchcallback_topo(void *userdata, int index, const float *UNUS
|
||||
}
|
||||
}
|
||||
|
||||
BMVert *BMBVH_FindClosestVertTopo(BMBVHTree *tree, float *co, float maxdist, BMVert *sourcev)
|
||||
{
|
||||
BVHTreeNearest hit;
|
||||
|
||||
memset(&hit, 0, sizeof(hit));
|
||||
|
||||
copy_v3_v3(hit.co, co);
|
||||
copy_v3_v3(tree->co, co);
|
||||
hit.index = -1;
|
||||
hit.dist = maxdist;
|
||||
|
||||
tree->curw = FLT_MAX;
|
||||
tree->curd = FLT_MAX;
|
||||
tree->curv = NULL;
|
||||
tree->curtag = 1;
|
||||
|
||||
tree->gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh bvh");
|
||||
|
||||
tree->maxdist = maxdist;
|
||||
tree->v = sourcev;
|
||||
|
||||
BLI_bvhtree_find_nearest(tree->tree, co, &hit, vertsearchcallback_topo, tree);
|
||||
|
||||
BLI_ghash_free(tree->gh, NULL, NULL);
|
||||
tree->gh = NULL;
|
||||
|
||||
return tree->curv;
|
||||
}
|
||||
|
||||
|
||||
#if 0 //BMESH_TODO: not implemented yet
|
||||
int BMBVH_VertVisible(BMBVHTree *tree, BMEdge *e, RegionView3D *r3d)
|
||||
{
|
||||
|
||||
@@ -59,8 +59,6 @@ int BMBVH_EdgeVisible(struct BMBVHTree *tree, struct BMEdge *e,
|
||||
|
||||
/*find a vert closest to co in a sphere of radius maxdist*/
|
||||
struct BMVert *BMBVH_FindClosestVert(struct BMBVHTree *tree, float *co, float maxdist);
|
||||
struct BMVert *BMBVH_FindClosestVertTopo(struct BMBVHTree *tree, float *co,
|
||||
float maxdist, struct BMVert *sourcev);
|
||||
|
||||
/*BMBVH_NewBVH flag parameter*/
|
||||
#define BMBVH_USE_CAGE 1 /*project geometry onto modifier cage */
|
||||
|
||||
Reference in New Issue
Block a user