merge with/from trunk at r35190
[blender.git] / source / blender / bmesh / operators / removedoubles.c
index c7ab4af3ada458a2235eddac92c98a42b79d050e..f806fd33a6b6596c32e1e1ec029abe56ca04a6e9 100644 (file)
@@ -11,6 +11,7 @@
 #include "BLI_ghash.h"
 #include "BLI_blenlib.h"
 #include "BLI_array.h"
+#include "BLI_utildefines.h"
 
 #include "bmesh.h"
 #include "mesh_intern.h"
@@ -33,8 +34,8 @@ void remdoubles_splitface(BMFace *f, BMesh *bm, BMOperator *op)
                v2 = BMO_Get_MapPointer(bm, op, "targetmap", l->v);
                /*ok: if v2 is NULL (e.g. not in the map) then it's
                      a target vert, otherwise it's a double*/
-               if (v2 && BM_Vert_In_Face(f, v2) && v2 != BL(l->head.prev)->v 
-                   && v2 != BL(l->head.next)->v)
+               if (v2 && BM_Vert_In_Face(f, v2) && v2 != BL(l->prev)->v 
+                   && v2 != BL(l->next)->v)
                {
                        doub = l->v;
                        split = 1;
@@ -142,7 +143,7 @@ void bmesh_weldverts_exec(BMesh *bm, BMOperator *op)
                a = 0;
                BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) {
                        v = l->v;
-                       v2 = BL(l->head.next)->v;
+                       v2 = BL(l->next)->v;
                        if (BMO_TestFlag(bm, v, ELE_DEL)) 
                                v = BMO_Get_MapPointer(bm, op, "targetmap", v);
                        if (BMO_TestFlag(bm, v2, ELE_DEL)) 
@@ -317,7 +318,7 @@ void bmesh_pointmerge_exec(BMesh *bm, BMOperator *op)
        BMO_ITER(v, &siter, bm, op, "verts", BM_VERT) {
                if (!snapv) {
                        snapv = v;
-                       VECCOPY(snapv->co, vec);
+                       copy_v3_v3(snapv->co, vec);
                } else {
                        BMO_Insert_MapPointer(bm, &weldop, "targetmap", v, snapv);
                }               
@@ -359,8 +360,8 @@ void bmesh_collapse_exec(BMesh *bm, BMOperator *op)
                        DO_MINMAX(e->v2->co, min, max);
                }
 
-               VECADD(min, min, max);
-               VECMUL(min, 0.5f);
+               add_v3_v3v3(min, min, max);
+               mul_v3_fl(min, 0.5f);
 
                /*snap edges to a point.  for initial testing purposes anyway.*/
                for (i=0; i<tot; i++) {
@@ -475,8 +476,10 @@ void bmesh_removedoubles_exec(BMesh *bm, BMOperator *op)
                        float vec[3];
                        
                        v2 = verts[j];
-                       if ((v2->co[0]+v2->co[1]+v2->co[2]) - (v->co[0]+v->co[1]+v->co[2])
-                            > distsqr) break;
+                       //if ((v2->co[0]+v2->co[1]+v2->co[2]) - (v->co[0]+v->co[1]+v->co[2])
+                       //     > distsqr) break;
+                       if ((v2->co[0]-v->co[0]) + (v2->co[1]-v->co[1]) + (v2->co[2]-v->co[2]) > distsqr*4.0f)
+                               break;
 
                        vec[0] = v->co[0] - v2->co[0];
                        vec[1] = v->co[1] - v2->co[1];