converted more mixed tab/space indentations to tabs. only whitespace changes.
[blender.git] / source / blender / editors / mesh / editmesh_tools.c
index 5525a48..83840f0 100644 (file)
@@ -980,7 +980,7 @@ static int spin_mesh(bContext *C, wmOperator *op, float *dvec, int steps, float
        cent[2]-= obedit->obmat[3][2];
        mul_m3_v3(imat, cent);
 
-       phi= degr*M_PI/360.0;
+       phi= degr*(float)M_PI/360.0f;
        phi/= steps;
        if(ts->editbutflag & B_CLOCKWISE) phi= -phi;
 
@@ -1144,10 +1144,8 @@ static int screw_mesh_exec(bContext *C, wmOperator *op)
 
        VECCOPY(nor, obedit->obmat[2]);
 
-       if(nor[0]*dvec[0]+nor[1]*dvec[1]+nor[2]*dvec[2]>0.000) {
-               dvec[0]= -dvec[0];
-               dvec[1]= -dvec[1];
-               dvec[2]= -dvec[2];
+       if(nor[0]*dvec[0]+nor[1]*dvec[1]+nor[2]*dvec[2]>0.0f) {
+               negate_v3(dvec);
        }
 
        if(spin_mesh(C, op, dvec, turns*steps, 360.0f*turns, 0)) {
@@ -1476,7 +1474,7 @@ static void alter_co(float *co, EditEdge *edge, float smooth, float fractal, int
                vec1[2]+= fac*nor2[2];
 
                /* falloff for multi subdivide */
-               smooth *= sqrt(fabs(1.0f - 2.0f*fabs(0.5f-perc)));
+               smooth *= sqrtf(fabs(1.0f - 2.0f*fabsf(0.5f-perc)));
 
                vec1[0]*= smooth*len;
                vec1[1]*= smooth*len;
@@ -2675,15 +2673,15 @@ void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float
                                        eve->f2= 0;
                                        switch(mmd->axis){
                                                case 0:
-                                                       if (fabs(eve->co[0]) < mmd->tolerance)
+                                                       if (fabsf(eve->co[0]) < mmd->tolerance)
                                                                eve->f2 |= 1;
                                                        break;
                                                case 1:
-                                                       if (fabs(eve->co[1]) < mmd->tolerance)
+                                                       if (fabsf(eve->co[1]) < mmd->tolerance)
                                                                eve->f2 |= 2;
                                                        break;
                                                case 2:
-                                                       if (fabs(eve->co[2]) < mmd->tolerance)
+                                                       if (fabsf(eve->co[2]) < mmd->tolerance)
                                                                eve->f2 |= 4;
                                                        break;
                                        }
@@ -2757,7 +2755,7 @@ void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float
 
                                // Beauty Long Edges
                                else {
-                                        for(j=0;j<2;j++) {
+                                       for(j=0;j<2;j++) {
                                                hold = -1;
                                                for(i=0;i<4;i++) {
                                                        if(length[i] < 0) {
@@ -2971,8 +2969,8 @@ void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float
                        }
                }
        }
-        if(em->selectmode & SCE_SELECT_VERTEX) {
-                for(eed = em->edges.first;eed;eed = eed->next) {
+       if(em->selectmode & SCE_SELECT_VERTEX) {
+               for(eed = em->edges.first;eed;eed = eed->next) {
                        if(eed->f & SELECT) {
                                eed->v1->f |= SELECT;
                                eed->v2->f |= SELECT;
@@ -3226,13 +3224,13 @@ static float measure_facepair(EditVert *v1, EditVert *v2, EditVert *v3, EditVert
        normal_tri_v3( noA2,v1->co, v3->co, v4->co);
 
        if(noA1[0] == noA2[0] && noA1[1] == noA2[1] && noA1[2] == noA2[2]) normalADiff = 0.0;
-       else normalADiff = RAD2DEG(angle_v2v2(noA1, noA2));
+       else normalADiff = RAD2DEGF(angle_v2v2(noA1, noA2));
                //if(!normalADiff) normalADiff = 179;
        normal_tri_v3( noB1,v2->co, v3->co, v4->co);
        normal_tri_v3( noB2,v4->co, v1->co, v2->co);
 
        if(noB1[0] == noB2[0] && noB1[1] == noB2[1] && noB1[2] == noB2[2]) normalBDiff = 0.0;
-       else normalBDiff = RAD2DEG(angle_v2v2(noB1, noB2));
+       else normalBDiff = RAD2DEGF(angle_v2v2(noB1, noB2));
                //if(!normalBDiff) normalBDiff = 179;
 
        measure += (normalADiff/360) + (normalBDiff/360);
@@ -3247,10 +3245,10 @@ static float measure_facepair(EditVert *v1, EditVert *v2, EditVert *v3, EditVert
        diff = 0.0;
 
        diff = (
-               fabs(RAD2DEG(angle_v2v2(edgeVec1, edgeVec2)) - 90) +
-               fabs(RAD2DEG(angle_v2v2(edgeVec2, edgeVec3)) - 90) +
-               fabs(RAD2DEG(angle_v2v2(edgeVec3, edgeVec4)) - 90) +
-               fabs(RAD2DEG(angle_v2v2(edgeVec4, edgeVec1)) - 90)) / 360;
+               fabsf(RAD2DEGF(angle_v2v2(edgeVec1, edgeVec2)) - 90) +
+               fabsf(RAD2DEGF(angle_v2v2(edgeVec2, edgeVec3)) - 90) +
+               fabsf(RAD2DEGF(angle_v2v2(edgeVec3, edgeVec4)) - 90) +
+               fabsf(RAD2DEGF(angle_v2v2(edgeVec4, edgeVec1)) - 90)) / 360;
        if(!diff) return 0.0;
 
        measure +=  diff;
@@ -3272,7 +3270,7 @@ static float measure_facepair(EditVert *v1, EditVert *v2, EditVert *v3, EditVert
        return measure;
 }
 
-#define T2QUV_LIMIT 0.005
+#define T2QUV_LIMIT 0.005f
 #define T2QCOL_LIMIT 3
 static int compareFaceAttribs(EditMesh *em, EditFace *f1, EditFace *f2, EditEdge *eed)
 {
@@ -3645,7 +3643,7 @@ static void edge_rotate(EditMesh *em, wmOperator *op, EditEdge *eed, int dir)
                return;
 
        /* how many edges does each face have */
-        if(face[0]->e4) fac1= 4;
+       if(face[0]->e4) fac1= 4;
        else fac1= 3;
 
        if(face[1]->e4) fac2= 4;
@@ -4063,8 +4061,8 @@ useless:
                }
                // Make sure loop is not 2 edges of same face
                if(ct > 1) {
-                  BKE_report(op->reports, RPT_ERROR, "Loop crosses itself");
-                  return 0;
+                       BKE_report(op->reports, RPT_ERROR, "Loop crosses itself");
+                       return 0;
                }
        }
        // Get # of selected verts
@@ -4181,11 +4179,11 @@ useless:
                        for(eed=em->edges.first;eed;eed=eed->next) {
                                if(editedge_containsVert(eed, ev)) {
                                        if(!(eed->f & SELECT)) {
-                                                if(!tempsv->up) {
-                                                        tempsv->up = eed;
-                                                } else if (!(tempsv->down)) {
-                                                        tempsv->down = eed;
-                                                }
+                                               if(!tempsv->up) {
+                                                       tempsv->up = eed;
+                                               } else if (!(tempsv->down)) {
+                                                       tempsv->down = eed;
+                                               }
                                        }
                                }
                        }
@@ -4197,33 +4195,33 @@ useless:
                                        for(efa = em->faces.first;efa;efa=efa->next) {
                                                if(editface_containsEdge(efa, eed)) {
                                                        if(editedge_containsVert(efa->e1, ev) && efa->e1 != eed) {
-                                                                if(!tempsv->up) {
-                                                                        tempsv->up = efa->e1;
-                                                                } else if (!(tempsv->down)) {
-                                                                        tempsv->down = efa->e1;
-                                                                }
+                                                               if(!tempsv->up) {
+                                                                       tempsv->up = efa->e1;
+                                                               } else if (!(tempsv->down)) {
+                                                                       tempsv->down = efa->e1;
+                                                               }
                                                        }
                                                        if(editedge_containsVert(efa->e2, ev) && efa->e2 != eed) {
-                                                                if(!tempsv->up) {
-                                                                        tempsv->up = efa->e2;
-                                                                } else if (!(tempsv->down)) {
-                                                                        tempsv->down = efa->e2;
-                                                                }
+                                                               if(!tempsv->up) {
+                                                                       tempsv->up = efa->e2;
+                                                               } else if (!(tempsv->down)) {
+                                                                       tempsv->down = efa->e2;
+                                                               }
                                                        }
                                                        if(editedge_containsVert(efa->e3, ev) && efa->e3 != eed) {
-                                                                if(!tempsv->up) {
-                                                                        tempsv->up = efa->e3;
-                                                                } else if (!(tempsv->down)) {
-                                                                        tempsv->down = efa->e3;
-                                                                }
+                                                               if(!tempsv->up) {
+                                                                       tempsv->up = efa->e3;
+                                                               } else if (!(tempsv->down)) {
+                                                                       tempsv->down = efa->e3;
+                                                               }
                                                        }
                                                        if(efa->e4) {
                                                                if(editedge_containsVert(efa->e4, ev) && efa->e4 != eed) {
-                                                                        if(!tempsv->up) {
-                                                                                tempsv->up = efa->e4;
-                                                                        } else if (!(tempsv->down)) {
-                                                                                tempsv->down = efa->e4;
-                                                                        }
+                                                                       if(!tempsv->up) {
+                                                                               tempsv->up = efa->e4;
+                                                                       } else if (!(tempsv->down)) {
+                                                                               tempsv->down = efa->e4;
+                                                                       }
                                                                }
                                                        }
 
@@ -4667,7 +4665,7 @@ useless:
                                                        mvalo[0] = -1;
                                        } else if(ELEM(event, RIGHTARROWKEY, WHEELUPMOUSE)) { // Scroll through Control Edges
                                                look = vertlist;
-                                                while(look) {
+                                               while(look) {
                                                        if(nearest == (EditVert*)look->link) {
                                                                if(look->next == NULL) {
                                                                        nearest =  (EditVert*)vertlist->link;
@@ -4681,7 +4679,7 @@ useless:
                                                }
                                        } else if(ELEM(event, LEFTARROWKEY, WHEELDOWNMOUSE)) { // Scroll through Control Edges
                                                look = vertlist;
-                                                while(look) {
+                                               while(look) {
                                                        if(look->next) {
                                                                if(look->next->link == nearest) {
                                                                        nearest = (EditVert*)look->link;
@@ -4819,7 +4817,7 @@ void mesh_set_face_flags(EditMesh *em, short mode)
        add_numbut(12, TOG|SHO, "Sort", 0, 0, &m_sort, NULL);
 
        if (!do_clever_numbuts((mode ? "Set Flags" : "Clear Flags"), 13, REDRAW))
-                return;
+               return;
 
        /* these 2 cant both be on */
        if (mode) /* are we seeting*/
@@ -5416,7 +5414,7 @@ static void freecollections(ListBase *allcollections)
 
 /*Begin UV Edge Collapse Code
        Like Edge subdivide, Edge Collapse should handle UV's intelligently, but since UV's are a per-face attribute, normal edge collapse will fail
-       in areas such as the boundries of 'UV islands'. So for each edge collection we need to build a set of 'welded' UV vertices and edges for it.
+       in areas such as the boundaries of 'UV islands'. So for each edge collection we need to build a set of 'welded' UV vertices and edges for it.
        The welded UV edges can then be sorted and collapsed.
 */
 typedef struct wUV{
@@ -7327,7 +7325,7 @@ void MESH_OT_sort_faces(wmOperatorType *ot)
                { 1, "VIEW_AXIS", 0, "View Axis", "" },
                { 2, "CURSOR_DISTANCE", 0, "Cursor Distance", "" },
                { 3, "MATERIAL", 0, "Material", "" },
-               { 4, "SELECTION", 0, "Selection", "" },
+               { 4, "SELECTED", 0, "Selected", "" },
                { 5, "RANDOMIZE", 0, "Randomize", "" },
                { 0, NULL, 0, NULL, NULL }};
 
@@ -7451,6 +7449,8 @@ static void mesh_set_smooth_faces(EditMesh *em, short smooth)
                        else efa->flag &= ~ME_SMOOTH;
                }
        }
+
+       recalc_editnormals(em);
 }
 
 static int mesh_faces_shade_smooth_exec(bContext *C, wmOperator *UNUSED(op))