flip_editnormals is back, alt+3key
authorShaul Kedem <shaul_kedem@yahoo.com>
Thu, 5 Feb 2009 01:32:37 +0000 (01:32 +0000)
committerShaul Kedem <shaul_kedem@yahoo.com>
Thu, 5 Feb 2009 01:32:37 +0000 (01:32 +0000)
source/blender/editors/mesh/editmesh_lib.c
source/blender/editors/mesh/editmesh_mods.c
source/blender/editors/mesh/mesh_intern.h
source/blender/editors/mesh/mesh_ops.c

index 40e2179ddbefe67a6a98f86d595bb3da2e8cdbc5..0ee4d2f8274a4a9466c5021372e3f4439ce40cb6 100644 (file)
@@ -1895,42 +1895,7 @@ static int check_vnormal_flip(float *n, float *vnorm)
 }
 #endif
 
-void flipface(EditMesh *em, EditFace *efa)
-{
-       if(efa->v4) {
-               SWAP(EditVert *, efa->v2, efa->v4);
-               SWAP(EditEdge *, efa->e1, efa->e4);
-               SWAP(EditEdge *, efa->e2, efa->e3);
-               EM_data_interp_from_faces(em, efa, NULL, efa, 0, 3, 2, 1);
-       }
-       else {
-               SWAP(EditVert *, efa->v2, efa->v3);
-               SWAP(EditEdge *, efa->e1, efa->e3);
-               efa->e2->dir= 1-efa->e2->dir;
-               EM_data_interp_from_faces(em, efa, NULL, efa, 0, 2, 1, 3);
-       }
-
-       if(efa->v4) CalcNormFloat4(efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co, efa->n);
-       else CalcNormFloat(efa->v1->co, efa->v2->co, efa->v3->co, efa->n);
-}
-
 
-void flip_editnormals(EditMesh *em)
-{
-       EditFace *efa;
-       
-       efa= em->faces.first;
-       while(efa) {
-               if( efa->f & SELECT ){
-                       flipface(em, efa);
-               }
-               efa= efa->next;
-       }
-       
-       /* update vertex normals too */
-       recalc_editnormals(em);
-       
-}
 
 /* does face centers too */
 void recalc_editnormals(EditMesh *em)
index 6d4a259589e453021cedb426bfed66af6d1409a7..8870894df4b5371f44204a733236cbe559424284 100644 (file)
@@ -4731,3 +4731,57 @@ void MESH_OT_vertices_to_sphere(wmOperatorType *ot)
        /* props */
        RNA_def_float(ot->srna, "percent", 100.0f, 0.0f, 100.0f, "Percent", "DOC_BROKEN", 0.01f, 100.0f);
 }
+
+void flipface(EditMesh *em, EditFace *efa)
+{
+       if(efa->v4) {
+               SWAP(EditVert *, efa->v2, efa->v4);
+               SWAP(EditEdge *, efa->e1, efa->e4);
+               SWAP(EditEdge *, efa->e2, efa->e3);
+               EM_data_interp_from_faces(em, efa, NULL, efa, 0, 3, 2, 1);
+       }
+       else {
+               SWAP(EditVert *, efa->v2, efa->v3);
+               SWAP(EditEdge *, efa->e1, efa->e3);
+               efa->e2->dir= 1-efa->e2->dir;
+               EM_data_interp_from_faces(em, efa, NULL, efa, 0, 2, 1, 3);
+       }
+
+       if(efa->v4) CalcNormFloat4(efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co, efa->n);
+       else CalcNormFloat(efa->v1->co, efa->v2->co, efa->v3->co, efa->n);
+}
+
+
+static int flip_editnormals(bContext *C, wmOperator *op)
+{
+       Object *obedit= CTX_data_edit_object(C);
+       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       EditFace *efa;
+       
+       efa= em->faces.first;
+       while(efa) {
+               if( efa->f & SELECT ){
+                       flipface(em, efa);
+               }
+               efa= efa->next;
+       }
+       
+       /* update vertex normals too */
+       recalc_editnormals(em);
+
+       return OPERATOR_FINISHED;
+}
+
+void MESH_OT_flip_editnormals(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Flip Normals";
+       ot->idname= "MESH_OT_flip_editnormals";
+       
+       /* api callbacks */
+       ot->exec= flip_editnormals;
+       ot->poll= ED_operator_editmesh;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
index 94e56b3f7d947eb511219165d67d61d85b547f48..d1d0c46413056407d20535815ab3667cdccbda90 100644 (file)
@@ -196,6 +196,7 @@ void MESH_OT_select_multi_loop(struct wmOperatorType *ot);
 void MESH_OT_mark_seam(struct wmOperatorType *ot);
 void MESH_OT_mark_sharp(struct wmOperatorType *ot);
 void MESH_OT_smooth_vertex(struct wmOperatorType *ot);
+void MESH_OT_flip_editnormals(struct wmOperatorType *ot);
 
 extern EditEdge *findnearestedge(ViewContext *vc, int *dist);
 extern void EM_automerge(int update);
index 9c688725b5089c67b76d89c8f4a1d7a683584ee2..d4d21f61b61f1f5f6f31c65d29bb3699eed6432b 100644 (file)
@@ -164,6 +164,7 @@ void ED_operatortypes_mesh(void)
        WM_operatortype_append(MESH_OT_mark_seam);
        WM_operatortype_append(MESH_OT_mark_sharp);
        WM_operatortype_append(MESH_OT_smooth_vertex);
+       WM_operatortype_append(MESH_OT_flip_editnormals);
        
 }
 
@@ -210,6 +211,8 @@ void ED_keymap_mesh(wmWindowManager *wm)
 
        WM_keymap_add_item(keymap, "MESH_OT_smooth_vertex", THREEKEY, KM_PRESS, KM_CTRL , 0);
 
+       WM_keymap_add_item(keymap, "MESH_OT_flip_editnormals", THREEKEY, KM_PRESS, KM_ALT , 0);
+
        /* temp hotkeys! */
        WM_keymap_add_item(keymap, "MESH_OT_similar_vertex_select", GKEY, KM_PRESS, KM_SHIFT, 0);
        WM_keymap_add_item(keymap, "MESH_OT_similar_edge_select", GKEY, KM_PRESS, KM_SHIFT2|KM_CTRL, 0);