diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-09-28 23:53:45 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-09-28 23:53:45 +0400 |
commit | a90115c2eed330ac97b555bca39cc984a2b59782 (patch) | |
tree | 195a19897170b3018c5874e41b059d5507f1a89c /source/blender | |
parent | 30bd26d435fdef82a48bd857e48a7d77eb90443f (diff) |
bugfix [#24040] loop select -> delete edge loop crashes blender
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenlib/BLI_editVert.h | 2 | ||||
-rw-r--r-- | source/blender/editors/mesh/meshtools.c | 38 |
2 files changed, 29 insertions, 11 deletions
diff --git a/source/blender/blenlib/BLI_editVert.h b/source/blender/blenlib/BLI_editVert.h index 2d54e420bb1..051778772e0 100644 --- a/source/blender/blenlib/BLI_editVert.h +++ b/source/blender/blenlib/BLI_editVert.h @@ -68,7 +68,7 @@ typedef struct EditVert unsigned char f, h, f1, f2; float bweight; short fast; /* only 0 or 1, for editmesh_fastmalloc, do not store temp data here! */ - int hash; + int hash; /* internal editmesh.c use only, don't touch! */ int keyindex; /* original index #, for restoring key information */ void *data; /* custom vertex data */ diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 7cef819a795..e8c787b168f 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -867,6 +867,7 @@ long mesh_mirrtopo_table(Object *ob, char mode) Mesh *me= ob->data; MEdge *medge; EditMesh *em= me->edit_mesh; + void **eve_tmp_back= NULL; /* some of the callers are using eve->tmp so restore after */ /* editmode*/ @@ -889,10 +890,13 @@ long mesh_mirrtopo_table(Object *ob, char mode) if(em) { EditVert *eve; totvert= 0; + eve_tmp_back= MEM_callocN( em->totvert * sizeof(void *), "TopoMirr" ); for(eve= em->verts.first; eve; eve= eve->next) { - eve->hash = totvert++; + eve_tmp_back[totvert]= eve->tmp.p; + eve->tmp.l = totvert++; } - } else { + } + else { totvert = me->totvert; } @@ -901,8 +905,8 @@ long mesh_mirrtopo_table(Object *ob, char mode) /* Initialize the vert-edge-user counts used to detect unique topology */ if(em) { for(eed=em->edges.first; eed; eed= eed->next) { - MirrTopoHash[eed->v1->hash]++; - MirrTopoHash[eed->v2->hash]++; + MirrTopoHash[eed->v1->tmp.l]++; + MirrTopoHash[eed->v2->tmp.l]++; } } else { for(a=0, medge=me->medge; a<me->totedge; a++, medge++) { @@ -919,8 +923,8 @@ long mesh_mirrtopo_table(Object *ob, char mode) if(em) { for(eed=em->edges.first; eed; eed= eed->next) { - MirrTopoHash[eed->v1->hash] += MirrTopoHash_Prev[eed->v2->hash]; - MirrTopoHash[eed->v2->hash] += MirrTopoHash_Prev[eed->v1->hash]; + MirrTopoHash[eed->v1->tmp.l] += MirrTopoHash_Prev[eed->v2->tmp.l]; + MirrTopoHash[eed->v2->tmp.l] += MirrTopoHash_Prev[eed->v1->tmp.l]; } } else { for(a=0, medge=me->medge; a<me->totedge; a++, medge++) { @@ -952,6 +956,19 @@ long mesh_mirrtopo_table(Object *ob, char mode) memcpy(MirrTopoHash_Prev, MirrTopoHash, sizeof(MIRRHASH_TYPE) * totvert); } + /* restore eve->tmp.* */ + if(eve_tmp_back) { + EditVert *eve; + totvert= 0; + for(eve= em->verts.first; eve; eve= eve->next) { + eve->tmp.p= eve_tmp_back[totvert++]; + } + + MEM_freeN(eve_tmp_back); + eve_tmp_back= NULL; + } + + /* Hash/Index pairs are needed for sorting to find index pairs */ MirrTopoPairs= MEM_callocN( sizeof(MirrTopoPair) * totvert, "MirrTopoPairs"); @@ -1074,12 +1091,13 @@ static EditVert *editmesh_get_x_mirror_vert_topo(Object *ob, struct EditMesh *em if (mesh_mirrtopo_table(ob, 'u')==-1) return NULL; - if (index!=-1) { + if (index == -1) { index = BLI_findindex(&em->verts, eve); - } - if (index==-1) - return NULL; + if (index == -1) { + return NULL; + } + } poinval= mesh_topo_lookup[ index ]; |