[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [42780] branches/bmesh/blender/source/ blender/editors/mesh: more mirror cleanup

Campbell Barton ideasman42 at gmail.com
Wed Dec 21 01:09:52 CET 2011


Revision: 42780
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42780
Author:   campbellbarton
Date:     2011-12-21 00:09:44 +0000 (Wed, 21 Dec 2011)
Log Message:
-----------
more mirror cleanup
- remove BMBVH_FindClosestVertTop
- update select mirror operator to EDBM_CacheMirrorVerts

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c
    branches/bmesh/blender/source/blender/editors/mesh/bmeshutils.c
    branches/bmesh/blender/source/blender/editors/mesh/editbmesh_bvh.c
    branches/bmesh/blender/source/blender/editors/mesh/editbmesh_bvh.h

Modified: branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c	2011-12-20 23:17:24 UTC (rev 42779)
+++ branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c	2011-12-21 00:09:44 UTC (rev 42780)
@@ -3945,14 +3945,11 @@
 
 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 @@
 		}
 	}
 
+	EDBM_CacheMirrorVerts(em, FALSE);
+
 	if (!extend)
 		EDBM_clear_flag_all(em, BM_SELECT);
 
@@ -3970,14 +3969,14 @@
 		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;
 }

Modified: branches/bmesh/blender/source/blender/editors/mesh/bmeshutils.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/mesh/bmeshutils.c	2011-12-20 23:17:24 UTC (rev 42779)
+++ branches/bmesh/blender/source/blender/editors/mesh/bmeshutils.c	2011-12-21 00:09:44 UTC (rev 42780)
@@ -809,6 +809,7 @@
 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 @@
 		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 @@
 		 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;
+		/* temporary for testing, check for selection */
+		if (use_select && !BM_TestHFlag(v, BM_SELECT)) {
+			/* do nothing */
+		}
+		else {
+			BMVert *mirr;
+			int *idx = CustomData_bmesh_get_layer_n(&bm->vdata, v->head.data, li);
 
-		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 (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(&em->bm->vdata,mirr->head.data, li);
-			*idx = BM_GetIndex(v);
+			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;
+			}
 		}
-		else {
-			*idx = -1;
-		}
+
 	}
 
 

Modified: branches/bmesh/blender/source/blender/editors/mesh/editbmesh_bvh.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/mesh/editbmesh_bvh.c	2011-12-20 23:17:24 UTC (rev 42779)
+++ branches/bmesh/blender/source/blender/editors/mesh/editbmesh_bvh.c	2011-12-21 00:09:44 UTC (rev 42780)
@@ -664,36 +664,6 @@
 	}
 }
 
-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)
 {

Modified: branches/bmesh/blender/source/blender/editors/mesh/editbmesh_bvh.h
===================================================================
--- branches/bmesh/blender/source/blender/editors/mesh/editbmesh_bvh.h	2011-12-20 23:17:24 UTC (rev 42779)
+++ branches/bmesh/blender/source/blender/editors/mesh/editbmesh_bvh.h	2011-12-21 00:09:44 UTC (rev 42780)
@@ -59,8 +59,6 @@
 
 /*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 */




More information about the Bf-blender-cvs mailing list