mark and clear seam, set and unset sharp and vertex smoothing is now ctrl/alt 1,...
authorShaul Kedem <shaul_kedem@yahoo.com>
Wed, 4 Feb 2009 02:58:21 +0000 (02:58 +0000)
committerShaul Kedem <shaul_kedem@yahoo.com>
Wed, 4 Feb 2009 02:58:21 +0000 (02:58 +0000)
source/blender/editors/mesh/editmesh_mods.c
source/blender/editors/mesh/mesh_intern.h
source/blender/editors/mesh/mesh_ops.c

index 7860a1a7b10f02c56a876dd8208888c133da3b4f..6d4a259589e453021cedb426bfed66af6d1409a7 100644 (file)
@@ -3768,10 +3768,13 @@ void MESH_OT_selection_type(wmOperatorType *ot)
 }
 /* ************************* SEAMS AND EDGES **************** */
 
-void editmesh_mark_seam(EditMesh *em, int clear)
+static int editmesh_mark_seam(bContext *C, wmOperator *op)
 {
-       Mesh *me= NULL; // XXX
+       Object *obedit= CTX_data_edit_object(C);
+       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       Mesh *me= ((Mesh *)obedit->data);
        EditEdge *eed;
+       int clear = RNA_boolean_get(op->ptr, "clear");
        
        /* auto-enable seams drawing */
        if(clear==0) {
@@ -3797,11 +3800,33 @@ void editmesh_mark_seam(EditMesh *em, int clear)
                }
        }
 
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+
+       return OPERATOR_FINISHED;
 }
 
-void editmesh_mark_sharp(EditMesh *em, int set)
+void MESH_OT_mark_seam(wmOperatorType *ot)
 {
-       Mesh *me= NULL;
+       /* identifiers */
+       ot->name= "Mark seam";
+       ot->idname= "MESH_OT_mark_seam";
+       
+       /* api callbacks */
+       ot->exec= editmesh_mark_seam;
+       ot->poll= ED_operator_editmesh;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       
+       RNA_def_boolean(ot->srna, "clear", 0, "Clear", "");
+}
+
+static int editmesh_mark_sharp(bContext *C, wmOperator *op)
+{
+       Object *obedit= CTX_data_edit_object(C);
+       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       Mesh *me= ((Mesh *)obedit->data);
+       int set = RNA_boolean_get(op->ptr, "set");
        EditEdge *eed;
 
        /* auto-enable sharp edge drawing */
@@ -3823,6 +3848,25 @@ void editmesh_mark_sharp(EditMesh *em, int set)
                }
        }
 
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+
+       return OPERATOR_FINISHED;
+}
+
+void MESH_OT_mark_sharp(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Mark sharp";
+       ot->idname= "MESH_OT_mark_sharp";
+       
+       /* api callbacks */
+       ot->exec= editmesh_mark_sharp;
+       ot->poll= ED_operator_editmesh;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       
+       RNA_def_boolean(ot->srna, "set", 0, "Set", "");
 }
 
 void BME_Menu()        {
@@ -3879,10 +3923,10 @@ void Edge_Menu(EditMesh *em)
        switch(ret)
        {
        case 1:
-               editmesh_mark_seam(em, 0);
+               //editmesh_mark_seam(em, 0);
                break;
        case 2:
-               editmesh_mark_seam(em, 1);
+               //editmesh_mark_seam(em, 1);
                break;
        case 3:
 //             edge_rotate_selected(em, 2);
@@ -4403,9 +4447,13 @@ void editmesh_align_view_to_selected(Object *obedit, EditMesh *em, View3D *v3d,
 
 /* **************** VERTEX DEFORMS *************** */
 
-void vertexsmooth(Object *obedit, EditMesh *em)
+static int smooth_vertex(bContext *C, wmOperator *op)
 {
-       Scene *scene= NULL; // XXX
+       Scene *scene= CTX_data_scene(C);
+       Object *obedit= CTX_data_edit_object(C);
+       Mesh *me= obedit->data;
+       EditMesh *em= me->edit_mesh; 
+
        EditVert *eve, *eve_mir = NULL;
        EditEdge *eed;
        float *adror, *adr, fac;
@@ -4413,7 +4461,7 @@ void vertexsmooth(Object *obedit, EditMesh *em)
        int teller=0;
        ModifierData *md= obedit->modifiers.first;
 
-       if(em==NULL) return;
+       if(em==NULL) return OPERATOR_CANCELLED;
 
        /* count */
        eve= em->verts.first;
@@ -4421,7 +4469,7 @@ void vertexsmooth(Object *obedit, EditMesh *em)
                if(eve->f & SELECT) teller++;
                eve= eve->next;
        }
-       if(teller==0) return;
+       if(teller==0) return OPERATOR_CANCELLED;
        
        adr=adror= (float *)MEM_callocN(3*sizeof(float *)*teller, "vertsmooth");
        eve= em->verts.first;
@@ -4530,8 +4578,25 @@ void vertexsmooth(Object *obedit, EditMesh *em)
 
        recalc_editnormals(em);
 
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+
 //     DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
 
+       return OPERATOR_FINISHED;
+}
+
+void MESH_OT_smooth_vertex(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Smooth Vertex";
+       ot->idname= "MESH_OT_smooth_vertex";
+       
+       /* api callbacks */
+       ot->exec= smooth_vertex;
+       ot->poll= ED_operator_editmesh;
+       
+       /* flags */
+       ot->flag= OPTYPE_UNDO;
 }
 
 void vertexnoise(Object *obedit, EditMesh *em)
index a8a417f1622f6d68baf6bbbdd820e634aa327b42..94e56b3f7d947eb511219165d67d61d85b547f48 100644 (file)
@@ -193,6 +193,9 @@ void MESH_OT_select_random(struct wmOperatorType *ot);
 void MESH_OT_vertices_to_sphere(struct wmOperatorType *ot);
 void MESH_OT_selection_type(struct wmOperatorType *ot);
 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);
 
 extern EditEdge *findnearestedge(ViewContext *vc, int *dist);
 extern void EM_automerge(int update);
index 4497745c87f42f242e7777ce049aa998b2d62fb5..9c688725b5089c67b76d89c8f4a1d7a683584ee2 100644 (file)
@@ -161,6 +161,9 @@ void ED_operatortypes_mesh(void)
        WM_operatortype_append(MESH_OT_similar_edge_select);
        WM_operatortype_append(MESH_OT_similar_face_select);
        WM_operatortype_append(MESH_OT_select_multi_loop);
+       WM_operatortype_append(MESH_OT_mark_seam);
+       WM_operatortype_append(MESH_OT_mark_sharp);
+       WM_operatortype_append(MESH_OT_smooth_vertex);
        
 }
 
@@ -198,7 +201,15 @@ void ED_keymap_mesh(wmWindowManager *wm)
        
        WM_keymap_add_item(keymap, "MESH_OT_select_random", SPACEKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "MESH_OT_vertices_to_sphere", SKEY, KM_PRESS, KM_CTRL|KM_SHIFT , 0);
-       
+
+       WM_keymap_add_item(keymap, "MESH_OT_mark_seam", ONEKEY, KM_PRESS, KM_CTRL , 0);
+       RNA_boolean_set(WM_keymap_add_item(keymap, "MESH_OT_mark_seam", ONEKEY, KM_PRESS, KM_ALT , 0)->ptr,"clear",1);
+
+       WM_keymap_add_item(keymap, "MESH_OT_mark_sharp", TWOKEY, KM_PRESS, KM_CTRL , 0);
+       RNA_boolean_set(WM_keymap_add_item(keymap, "MESH_OT_mark_sharp", TWOKEY, KM_PRESS, KM_ALT , 0)->ptr,"set",1);
+
+       WM_keymap_add_item(keymap, "MESH_OT_smooth_vertex", THREEKEY, KM_PRESS, KM_CTRL , 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);