[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [42776] branches/bmesh/blender/source/ blender/editors: replace editmode topo mirror function from the one in trunk ( ED_mesh_mirrtopo_init)
Campbell Barton
ideasman42 at gmail.com
Tue Dec 20 23:01:19 CET 2011
Revision: 42776
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42776
Author: campbellbarton
Date: 2011-12-20 22:01:11 +0000 (Tue, 20 Dec 2011)
Log Message:
-----------
replace editmode topo mirror function from the one in trunk (ED_mesh_mirrtopo_init)
Modified Paths:
--------------
branches/bmesh/blender/source/blender/editors/include/ED_mesh.h
branches/bmesh/blender/source/blender/editors/mesh/bmeshutils.c
branches/bmesh/blender/source/blender/editors/mesh/editface.c
branches/bmesh/blender/source/blender/editors/mesh/meshtools.c
Modified: branches/bmesh/blender/source/blender/editors/include/ED_mesh.h
===================================================================
--- branches/bmesh/blender/source/blender/editors/include/ED_mesh.h 2011-12-20 21:28:57 UTC (rev 42775)
+++ branches/bmesh/blender/source/blender/editors/include/ED_mesh.h 2011-12-20 22:01:11 UTC (rev 42776)
@@ -313,7 +313,8 @@
} MirrTopoStore_t;
int ED_mesh_mirrtopo_recalc_check(struct Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_topo_store);
-void ED_mesh_mirrtopo_init(struct Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_topo_store);
+void ED_mesh_mirrtopo_init(struct Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_topo_store,
+ const short skip_em_vert_array_init);
void ED_mesh_mirrtopo_free(MirrTopoStore_t *mesh_topo_store);
#ifdef __cplusplus
Modified: branches/bmesh/blender/source/blender/editors/mesh/bmeshutils.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/mesh/bmeshutils.c 2011-12-20 21:28:57 UTC (rev 42775)
+++ branches/bmesh/blender/source/blender/editors/mesh/bmeshutils.c 2011-12-20 22:01:11 UTC (rev 42776)
@@ -796,6 +796,12 @@
return em && em->bm->totface && CustomData_has_layer(&em->bm->ldata, CD_MLOOPCOL);
}
+static BMVert *cache_mirr_intptr_as_bmvert(intptr_t *index_lookup, int index)
+{
+ intptr_t eve_i= index_lookup[index];
+ return (eve_i == -1) ? NULL : (BMVert *)eve_i;
+}
+
/* BM_SEARCH_MAXDIST is too big, copied from 2.6x MOC_THRESH, should become a
* preference */
#define BM_SEARCH_MAXDIST_MIRR 0.00002f
@@ -803,11 +809,14 @@
void EDBM_CacheMirrorVerts(BMEditMesh *em, const short use_select)
{
Mesh *me = em->me;
- BMBVHTree *tree = BMBVH_NewBVH(em, 0, NULL, NULL);
BMIter iter;
BMVert *v;
int li, topo = 0;
+ /* one or the other is used depending if topo is enabled */
+ BMBVHTree *tree= NULL;
+ MirrTopoStore_t mesh_topo_store= {NULL, -1, -1, -1};
+
if (me && (me->editflag & ME_EDIT_MIRROR_TOPO)) {
topo = 1;
}
@@ -827,6 +836,13 @@
BM_ElemIndex_Ensure(em->bm, BM_VERT);
+ if (topo) {
+ ED_mesh_mirrtopo_init(me, -1, &mesh_topo_store, TRUE);
+ }
+ else {
+ 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);
@@ -835,9 +851,10 @@
//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) :
+ /* 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) {
@@ -850,8 +867,14 @@
}
}
- BMBVH_FreeBVH(tree);
+ if (topo) {
+ ED_mesh_mirrtopo_free(&mesh_topo_store);
+ }
+ else {
+ BMBVH_FreeBVH(tree);
+ }
+
em->mirror_cdlayer= li;
}
Modified: branches/bmesh/blender/source/blender/editors/mesh/editface.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/mesh/editface.c 2011-12-20 21:28:57 UTC (rev 42775)
+++ branches/bmesh/blender/source/blender/editors/mesh/editface.c 2011-12-20 22:01:11 UTC (rev 42776)
@@ -820,7 +820,8 @@
}
-void ED_mesh_mirrtopo_init(Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_topo_store)
+void ED_mesh_mirrtopo_init(Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_topo_store,
+ const short skip_em_vert_array_init)
{
MEdge *medge;
BMEditMesh *em= me->edit_btmesh;
@@ -914,7 +915,9 @@
mesh_topo_store->index_lookup = MEM_mallocN( totvert * sizeof(long), "mesh_topo_lookup" );
if(em) {
- EDBM_init_index_arrays(em,1,0,0);
+ if (skip_em_vert_array_init == FALSE) {
+ EDBM_init_index_arrays(em,1,0,0);
+ }
}
@@ -949,7 +952,9 @@
}
}
if(em) {
- EDBM_free_index_arrays(em);
+ if (skip_em_vert_array_init == FALSE) {
+ EDBM_free_index_arrays(em);
+ }
}
MEM_freeN( MirrTopoPairs );
Modified: branches/bmesh/blender/source/blender/editors/mesh/meshtools.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/mesh/meshtools.c 2011-12-20 21:28:57 UTC (rev 42775)
+++ branches/bmesh/blender/source/blender/editors/mesh/meshtools.c 2011-12-20 22:01:11 UTC (rev 42776)
@@ -914,7 +914,7 @@
}
}
else if(mode=='s') { /* start table */
- ED_mesh_mirrtopo_init(ob->data, ob->mode, &mesh_topo_store);
+ ED_mesh_mirrtopo_init(ob->data, ob->mode, &mesh_topo_store, FALSE);
}
else if(mode=='e') { /* end table */
ED_mesh_mirrtopo_free(&mesh_topo_store);
More information about the Bf-blender-cvs
mailing list