fix own error [#28645] TODO: dissolve edges doesn't delete lonely vertices on edges
authorCampbell Barton <ideasman42@gmail.com>
Tue, 17 Jan 2012 03:40:37 +0000 (03:40 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 17 Jan 2012 03:40:37 +0000 (03:40 +0000)
made this mistake when refactoring edge collapse code, though overall I think the function works better then before now.

source/blender/bmesh/intern/bmesh_mods.c
source/blender/bmesh/operators/dissolveops.c

index a3a084f737814462d75aa01f5e69825bbf0c0b63..cd0fc21c3d8e2fad925168fe28c88352855f3bbf 100644 (file)
@@ -408,17 +408,21 @@ BMEdge* BM_Collapse_Vert_Faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac)
        BMEdge *ne = NULL;
        BMVert *tv = bmesh_edge_getothervert(ke, kv);
 
+       BMEdge *e2;
+       BMVert *tv2;
 
        BMIter iter;
        BMLoop *l=NULL, *kvloop=NULL, *tvloop=NULL;
        BMFace **faces = NULL, *f;
        BLI_array_staticdeclare(faces, 8);
+
        void *src[2];
        float w[2];
 
        /* Only intended to be called for 2-valence vertices */
        BLI_assert(bmesh_disk_count(kv) <= 2);
 
+
        w[0] = 1.0f - fac;
        w[1] = fac;
 
@@ -441,19 +445,13 @@ BMEdge* BM_Collapse_Vert_Faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac)
                BLI_array_append(faces, f);
        }
 
-       /* Collapse between 2+ faces */
-       if (faces && BLI_array_count(faces) > 1) {
-               BMFace *f2;
-               BMEdge *e2;
-               BMVert *tv2;
+       BM_Data_Interp_From_Verts(bm, kv, tv, kv, fac);
 
-               /* only call when making real changes */
-               BM_Data_Interp_From_Verts(bm, kv, tv, kv, fac);
+       e2 = bmesh_disk_nextedge(ke, kv);
+       tv2 = BM_OtherEdgeVert(e2, kv);
 
-               e2 = bmesh_disk_nextedge(ke, kv);
-               tv2 = BM_OtherEdgeVert(e2, kv);
-
-               f2 = BM_Join_Faces(bm, faces, BLI_array_count(faces));
+       if (BLI_array_count(faces) > 1) {
+               BMFace *f2 = BM_Join_Faces(bm, faces, BLI_array_count(faces));
                if (f2) {
                        BMLoop *nl = NULL;
                        if (BM_Split_Face(bm, f2, tv, tv2, &nl, NULL)) {
@@ -461,7 +459,12 @@ BMEdge* BM_Collapse_Vert_Faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac)
                        }
                }
        }
-       /* else we cant do anything! */
+       else { /* single face or no faces */
+               /* same as BM_Collapse_Vert_Edges() however we already
+                * have vars to perform this operation so dont call. */
+               bmesh_jekv(bm, ke, kv);
+               ne = BM_Edge_Exist(tv, tv2);
+       }
 
        BLI_array_free(faces);
 
@@ -472,8 +475,7 @@ BMEdge* BM_Collapse_Vert_Faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac)
 /**
  *                     BM_Collapse_Vert_Edges
  *
- * Collapses a vertex onto another vertex it shares an edge with. Fac defines
- * the amount of interpolation for Custom Data.
+ * Collapses a vertex onto another vertex it shares an edge with.
  *
  * Note that this is not a general edge collapse function.
  *
index 69ccba14175a6f8dc13296783c33eaa6cdf363f0..c341effea895fde5290a377a47e60ce438e4ba3b 100644 (file)
@@ -159,10 +159,9 @@ void dissolve_edgeloop_exec(BMesh *bm, BMOperator *op)
 
        BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) {
                if (BMO_TestFlag(bm, v, VERT_MARK) && 
-                       BM_Vert_EdgeCount(v) == 2) 
+                       BM_Vert_EdgeCount(v) == 2)
                {
-                       BLI_array_growone(verts);
-                       verts[BLI_array_count(verts)-1] = v;
+                       BLI_array_append(verts, v);
                }
        }
 
@@ -224,8 +223,8 @@ void dissolveedges_exec(BMesh *bm, BMOperator *op)
                        BMVert *v1= e->v1, *v2= e->v2;
 
                        /*collapse the vert*/
-                       if (BM_Vert_EdgeCount(v1) == 2) BM_Collapse_Vert_Edges(bm, v1->e, v1);
-                       if (BM_Vert_EdgeCount(v2) == 2) BM_Collapse_Vert_Edges(bm, v2->e, v2);
+                       if (BM_Vert_EdgeCount(v1) == 2) BM_Collapse_Vert_Faces(bm, v1->e, v1, 1.0f);
+                       if (BM_Vert_EdgeCount(v2) == 2) BM_Collapse_Vert_Faces(bm, v2->e, v2, 1.0f);
 
                }
        }
@@ -298,7 +297,7 @@ void dissolveverts_exec(BMesh *bm, BMOperator *op)
                        if (BM_Vert_EdgeCount(v) == 2) {
 
                                /*collapse the vert*/
-                               BM_Collapse_Vert_Edges(bm, v->e, v);
+                               BM_Collapse_Vert_Faces(bm, v->e, v, 1.0f);
                                continue;
                        }