Fix #20604: Make Normals Consistent (Ctrl N) doesn't respect selection.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 8 Jan 2010 14:41:32 +0000 (14:41 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 8 Jan 2010 14:41:32 +0000 (14:41 +0000)
source/blender/editors/mesh/editmesh_add.c
source/blender/editors/mesh/editmesh_mods.c
source/blender/editors/mesh/mesh_intern.h

index d7f421331e5ef7341d59dfde59be885061f21050..572cf214c6a8c562619d354f504cfdc867b61972 100644 (file)
@@ -1265,7 +1265,7 @@ static void make_prim(Object *obedit, int type, float mat[4][4], int tot, int se
        EM_select_flush(em); /* flushes vertex -> edge -> face selection */
        
        if(type!=PRIM_PLANE && type!=PRIM_MONKEY)
-               righthandfaces(em, 1);  /* otherwise monkey has eyes in wrong direction */
+               EM_recalc_normal_direction(em, 0, 0);   /* otherwise monkey has eyes in wrong direction */
 
        BKE_mesh_end_editmesh(obedit->data, em);
 }
index 827b28f954bb54c11bef1da0500d3111c969040e..dee831b7fd038b7eb79bafb4ebb636396a5c33f1 100644 (file)
@@ -3800,8 +3800,7 @@ void MESH_OT_mark_sharp(wmOperatorType *ot)
 
 /* **************** NORMALS ************** */
 
-/* XXX value of select is messed up, it means two things */
-void righthandfaces(EditMesh *em, int select)  /* makes faces righthand turning */
+void EM_recalc_normal_direction(EditMesh *em, int inside, int select)  /* makes faces righthand turning */
 {
        EditEdge *eed, *ed1, *ed2, *ed3, *ed4;
        EditFace *efa, *startvl;
@@ -3893,16 +3892,12 @@ void righthandfaces(EditMesh *em, int select)   /* makes faces righthand turning *
                        cent_tri_v3(cent, startvl->v1->co, startvl->v2->co, startvl->v3->co);
                }
                /* first normal is oriented this way or the other */
-               if(select) {
-                       if(select==2) {
-                               if(cent[0]*nor[0]+cent[1]*nor[1]+cent[2]*nor[2] > 0.0) flipface(em, startvl);
-                       }
-                       else {
-                               if(cent[0]*nor[0]+cent[1]*nor[1]+cent[2]*nor[2] < 0.0) flipface(em, startvl);
-                       }
+               if(inside) {
+                       if(cent[0]*nor[0]+cent[1]*nor[1]+cent[2]*nor[2] > 0.0) flipface(em, startvl);
+               }
+               else {
+                       if(cent[0]*nor[0]+cent[1]*nor[1]+cent[2]*nor[2] < 0.0) flipface(em, startvl);
                }
-               else if(cent[0]*nor[0]+cent[1]*nor[1]+cent[2]*nor[2] < 0.0) flipface(em, startvl);
-
 
                eed= startvl->e1;
                if(eed->v1==startvl->v1) eed->f2= 1; 
@@ -4012,7 +4007,7 @@ void righthandfaces(EditMesh *em, int select)     /* makes faces righthand turning *
 }
 
 
-static int righthandfaces_exec(bContext *C, wmOperator *op)
+static int normals_make_consistent_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
        EditMesh *em= BKE_mesh_get_editmesh(((Mesh *)obedit->data));
@@ -4020,7 +4015,7 @@ static int righthandfaces_exec(bContext *C, wmOperator *op)
        /* 'standard' behaviour - check if selected, then apply relevant selection */
        
        // XXX  need other args
-       righthandfaces(em, RNA_boolean_get(op->ptr, "inside"));
+       EM_recalc_normal_direction(em, RNA_boolean_get(op->ptr, "inside"), 1);
        
        BKE_mesh_end_editmesh(obedit->data, em);
 
@@ -4038,7 +4033,7 @@ void MESH_OT_normals_make_consistent(wmOperatorType *ot)
        ot->idname= "MESH_OT_normals_make_consistent";
        
        /* api callbacks */
-       ot->exec= righthandfaces_exec;
+       ot->exec= normals_make_consistent_exec;
        ot->poll= ED_operator_editmesh;
        
        /* flags */
index 31e8cb16abcc36c842d9d1240c6c5e2eae05072d..94bdbdc73aa1fa552b0d5d5429c81d631ddd4692 100644 (file)
@@ -172,7 +172,7 @@ void MESH_OT_select_nth(struct wmOperatorType *ot);
 extern EditEdge *findnearestedge(ViewContext *vc, int *dist);
 extern void EM_automerge(Scene *scene, Object *obedit, int update);
 void editmesh_select_by_material(EditMesh *em, int index);
-void righthandfaces(EditMesh *em, int select); /* makes faces righthand turning */
+void EM_recalc_normal_direction(EditMesh *em, int inside, int select); /* makes faces righthand turning */
 void EM_select_more(EditMesh *em);
 void selectconnected_mesh_all(EditMesh *em);
 void faceloop_select(EditMesh *em, EditEdge *startedge, int select);