use BM_Make_Vert example argument rather then calling inline, was also copying vertex...
authorCampbell Barton <ideasman42@gmail.com>
Mon, 12 Sep 2011 05:24:45 +0000 (05:24 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 12 Sep 2011 05:24:45 +0000 (05:24 +0000)
source/blender/bmesh/intern/bmesh_construct.c
source/blender/bmesh/intern/bmesh_newcore.c
source/blender/bmesh/operators/edgesplitop.c
source/blender/bmesh/operators/extrudeops.c
source/blender/editors/mesh/bmesh_tools.c
source/blender/editors/mesh/knifetool.c

index b3ed3bb10b625f9fc7c4d4d8e0b1c3e959348ea1..79566029719df4000d1b6a8fe5dd9fc8245015fe 100644 (file)
@@ -497,10 +497,9 @@ BMesh *BM_Copy_Mesh(BMesh *bmold)
 
        v = BMIter_New(&iter, bmold, BM_VERTS_OF_MESH, NULL);
        for (i=0; v; v=BMIter_Step(&iter), i++) {
-               v2 = BM_Make_Vert(bm, v->co, NULL);
+               v2 = BM_Make_Vert(bm, v->co, NULL); /* copy between meshes so cant use 'example' argument */
                BM_Copy_Attributes(bmold, bm, v, v2);
                BLI_array_growone(vtable);
-               copy_v3_v3(v2->no, v->no);
 
                vtable[BLI_array_count(vtable)-1] = v2;
 
index 3ce8cb7fb621b0ad91af19b3dbfd52982cd16bef..a441a7d5d44052b9a4b9e5fea518c1e899575269 100644 (file)
@@ -26,6 +26,7 @@ BMVert *BM_Make_Vert(BMesh *bm, float co[3], const struct BMVert *example) {
 
        v->head.type = BM_VERT;
 
+       /* 'v->no' is handled by BM_Copy_Attributes */
        if (co) copy_v3_v3(v->co, co);
        
        /*allocate flags*/
index de546d5d5b3735913887fbdc54260e6e1b6e620c..87f93849c3fcc91f3afd721d62db6da7e156cedd 100644 (file)
@@ -207,8 +207,8 @@ void bmesh_edgesplitop_exec(BMesh *bm, BMOperator *op)
 
        BMO_Flag_Buffer(bm, op, "edges", EDGE_SEAM, BM_EDGE);
        
-       /*single marked edges unconnected to any other marked edges
-         are illegal, go through and unmark them*/
+       /* single marked edges unconnected to any other marked edges
+        * are illegal, go through and unmark them */
        BMO_ITER(e, &siter, bm, op, "edges", BM_EDGE) {
                for (i=0; i<2; i++) {
                        BM_ITER(e2, &iter, bm, BM_EDGES_OF_VERT, i ? e->v2 : e->v1) {
@@ -231,10 +231,10 @@ void bmesh_edgesplitop_exec(BMesh *bm, BMOperator *op)
        }
 
 #ifdef ETV
-#undef ETV
+#  undef ETV
 #endif
 #ifdef SETETV
-#undef SETETV
+#  undef SETETV
 #endif
 
 #define ETV(et, v, l) (l->e->v1 == v ? et->newv1 : et->newv2)
@@ -271,9 +271,7 @@ void bmesh_edgesplitop_exec(BMesh *bm, BMOperator *op)
                                if (BMO_TestFlag(bm, l2->e, EDGE_SEAM)) {
                                        if (!verts[j ? (i+1) % f->len : i]) {
                                                /*make unique vert here for this face only*/
-                                               v2 = BM_Make_Vert(bm, v->co, NULL);
-                                               copy_v3_v3(v2->no, v->no);
-                                               BM_Copy_Attributes(bm, bm, v, v2);
+                                               v2 = BM_Make_Vert(bm, v->co, v);
 
                                                verts[j ? (i+1) % f->len : i] = v2;
                                        } else v2 = verts[j ? (i+1) % f->len : i];
@@ -301,9 +299,7 @@ void bmesh_edgesplitop_exec(BMesh *bm, BMOperator *op)
                                        if (l3 == NULL || (BMO_TestFlag(bm, l3->e, EDGE_SEAM) && l3->e != l->e)) {
                                                et = etags + BM_GetIndex(l2->e);
                                                if (ETV(et, v, l2) == NULL) {
-                                                       v2 = BM_Make_Vert(bm, v->co, NULL);
-                                                       copy_v3_v3(v2->no, v->no);
-                                                       BM_Copy_Attributes(bm, bm, v, v2);
+                                                       v2 = BM_Make_Vert(bm, v->co, v);
                                                        
                                                        l3 = l2;
                                                        do {
index 1ed31d5c84d27dceca51f16c503badcb00d863d2..d917b48438bfd994665c6695db503ed6f7f0cc34 100644 (file)
@@ -39,8 +39,7 @@ void bmesh_extrude_face_indiv_exec(BMesh *bm, BMOperator *op)
                BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) {
                        BLI_array_growone(edges);
 
-                       v = BM_Make_Vert(bm, l->v->co, NULL);
-                       BM_Copy_Attributes(bm, bm, l->v, v);
+                       v = BM_Make_Vert(bm, l->v->co, l->v);
 
                        if (lastv) {
                                e = BM_Make_Edge(bm, lastv, v, l->e, 0);
@@ -151,9 +150,7 @@ void extrude_vert_indiv_exec(BMesh *bm, BMOperator *op)
 
        v = BMO_IterNew(&siter, bm, op, "verts", BM_VERT);
        for (; v; v=BMO_IterStep(&siter)) {
-               dupev = BM_Make_Vert(bm, v->co, NULL);
-               copy_v3_v3(dupev->no, v->no);
-               BM_Copy_Attributes(bm, bm, v, dupev);
+               dupev = BM_Make_Vert(bm, v->co, v);
 
                e = BM_Make_Edge(bm, v, dupev, NULL, 0);
 
index 049b596883c9894e95a4c2a20ad8d2a59b1e0aa9..80de84b3cf812b8aab6fa312d1cc59f0766f7c5b 100644 (file)
@@ -2709,7 +2709,7 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
        BMEdge *e, *e2, *closest = NULL;
        BMVert *v;
        int side = 0, i, singlesel = 0;
-       float projectMat[4][4], fmval[3] = {event->mval[0], event->mval[1], 0.0f};
+       float projectMat[4][4], fmval[3] = {event->mval[0], event->mval[1]};
        float dist = FLT_MAX, d;
 
        ED_view3d_ob_project_mat_get(rv3d, obedit, projectMat);
@@ -2803,34 +2803,31 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
 
        for (i=0; i<2; i++) {
                BMO_ITER(e, &siter, em->bm, &bmop, i ? "edgeout2":"edgeout1", BM_EDGE) {
-                       float cent[3] = {0, 0, 0}, mid[4], vec[3];
+                       float cent[3] = {0, 0, 0}, mid[3], vec[3];
 
                        if (!BMBVH_EdgeVisible(bvhtree, e, ar, v3d, obedit) || !e->l)
                                continue;
 
-                       /*method for calculating distance:
-                       
-                         for each edge: calculate face center, then made a vector
-                         from edge midpoint to face center.  offset edge midpoint
-                         by a small amount along this vector.*/
+                       /* method for calculating distance:
+                        *
+                        * for each edge: calculate face center, then made a vector
+                        * from edge midpoint to face center.  offset edge midpoint
+                        * by a small amount along this vector. */
                        BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, e->l->f) {
-                               add_v3_v3v3(cent, cent, l->v->co);
+                               add_v3_v3(cent, l->v->co);
                        }
                        mul_v3_fl(cent, 1.0f/(float)e->l->f->len);
 
-                       add_v3_v3v3(mid, e->v1->co, e->v2->co);
-                       mul_v3_fl(mid, 0.5f);
+                       mid_v3_v3v3(mid, e->v1->co, e->v2->co);
                        sub_v3_v3v3(vec, cent, mid);
                        normalize_v3(vec);
                        mul_v3_fl(vec, 0.01f);
                        add_v3_v3v3(mid, mid, vec);
 
-                       /*yay we have our comparison point, now project it*/
+                       /* yay we have our comparison point, now project it */
                        ED_view3d_project_float(ar, mid, mid, projectMat);
 
-                       vec[0] = fmval[0] - mid[0];
-                       vec[1] = fmval[1] - mid[1];
-                       d = vec[0]*vec[0] + vec[1]*vec[1];
+                       d = len_squared_v2v2(fmval, mid);
 
                        if (d < dist) {
                                side = i;
index 6dd5da6511a86574845f64163040e4c2bf8467b2..cbac51b685620253d3835adbb3028ef16528c605 100755 (executable)
@@ -1373,6 +1373,7 @@ static void knifenet_fill_faces(knifetool_opdata *kcd)
        BLI_mempool_iternew(kcd->kverts, &iter);
        for (kfv=BLI_mempool_iterstep(&iter); kfv; kfv=BLI_mempool_iterstep(&iter)) {
                if (!kfv->v) {
+                       /* shouldn't we be at least copying the normal? - if not some comment here should explain why - campbell */
                        kfv->v = BM_Make_Vert(bm, kfv->co, NULL);
                        kfv->flag = 1;
                        BMO_SetFlag(bm, kfv->v, DEL);