Add Edge sharp/smooth to 3DView shading panel, as well as new Vert sharp/smooth.
authorBastien Montagne <montagne29@wanadoo.fr>
Wed, 16 Apr 2014 13:18:14 +0000 (15:18 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Wed, 16 Apr 2014 13:26:48 +0000 (15:26 +0200)
release/scripts/startup/bl_ui/space_view3d.py
release/scripts/startup/bl_ui/space_view3d_toolbar.py
source/blender/editors/mesh/editmesh_tools.c

index 56f612abe3a3b430e7c2835dc12e760f0e420f7c..52f987be79641e6ce4249abfff16dc5f3c88e715 100644 (file)
@@ -2168,6 +2168,13 @@ class VIEW3D_MT_edit_mesh_vertices(Menu):
 
         layout.separator()
 
+        op = layout.operator("mesh.mark_sharp", text="Shade Smooth")
+        op.use_verts = True
+        op.clear = True
+        layout.operator("mesh.mark_sharp", text="Shade Sharp").use_verts = True
+
+        layout.separator()
+
         layout.operator("mesh.bevel").vertex_only = True
         layout.operator("mesh.convex_hull")
         layout.operator("mesh.vertices_smooth")
@@ -2211,7 +2218,7 @@ class VIEW3D_MT_edit_mesh_edges(Menu):
 
         layout.separator()
 
-        layout.operator("mesh.mark_sharp").clear = False
+        layout.operator("mesh.mark_sharp")
         layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
 
         layout.separator()
index 4e9dc1163e2964edf2ce7d678b671a1721e66503..2e130a85aaed8243f9e1965fe95cf1b38f692208 100644 (file)
@@ -385,10 +385,20 @@ class VIEW3D_PT_tools_shading(View3DPanel, Panel):
         layout = self.layout
 
         col = layout.column(align=True)
-        col.label(text="Shading:")
+        col.label(text="Faces:")
         row = col.row(align=True)
         row.operator("mesh.faces_shade_smooth", text="Smooth")
         row.operator("mesh.faces_shade_flat", text="Flat")
+        col.label(text="Edges:")
+        row = col.row(align=True)
+        row.operator("mesh.mark_sharp", text="Smooth").clear = True
+        row.operator("mesh.mark_sharp", text="Sharp")
+        col.label(text="Vertices:")
+        row = col.row(align=True)
+        op = row.operator("mesh.mark_sharp", text="Smooth")
+        op.use_verts = True
+        op.clear = True
+        row.operator("mesh.mark_sharp", text="Sharp").use_verts = True
 
         col = layout.column(align=True)
         col.label(text="Normals:")
index e57f6375a2a8e3e90c16cdb9a3296042b23a47b1..90e1c916029e4aef0deddbeba21633a584fc39ca 100644 (file)
@@ -823,27 +823,24 @@ static int edbm_mark_sharp_exec(bContext *C, wmOperator *op)
        BMEdge *eed;
        BMIter iter;
        const bool clear = RNA_boolean_get(op->ptr, "clear");
+       const bool use_verts = RNA_boolean_get(op->ptr, "use_verts");
 
        /* auto-enable sharp edge drawing */
        if (clear == 0) {
                me->drawflag |= ME_DRAWSHARP;
        }
 
-       if (!clear) {
-               BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) {
-                       if (!BM_elem_flag_test(eed, BM_ELEM_SELECT) || BM_elem_flag_test(eed, BM_ELEM_HIDDEN))
+       BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) {
+               if (use_verts) {
+                       if (!(BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) || BM_elem_flag_test(eed->v2, BM_ELEM_SELECT))) {
                                continue;
-                       
-                       BM_elem_flag_disable(eed, BM_ELEM_SMOOTH);
+                       }
                }
-       }
-       else {
-               BM_ITER_MESH (eed, &iter, bm, BM_EDGES_OF_MESH) {
-                       if (!BM_elem_flag_test(eed, BM_ELEM_SELECT) || BM_elem_flag_test(eed, BM_ELEM_HIDDEN))
-                               continue;
-                       
-                       BM_elem_flag_enable(eed, BM_ELEM_SMOOTH);
+               else if (!BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
+                       continue;
                }
+
+               BM_elem_flag_set(eed, BM_ELEM_SMOOTH, clear);
        }
 
        EDBM_update_generic(em, true, false);
@@ -867,11 +864,13 @@ void MESH_OT_mark_sharp(wmOperatorType *ot)
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
        
-       prop = RNA_def_boolean(ot->srna, "clear", 0, "Clear", "");
+       prop = RNA_def_boolean(ot->srna, "clear", false, "Clear", "");
+       RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+       prop = RNA_def_boolean(ot->srna, "use_verts", false, "Vertices",
+                              "Consider vertices instead of edges to select which edges to (un)tag as sharp");
        RNA_def_property_flag(prop, PROP_SKIP_SAVE);
 }
 
-
 static int edbm_vert_connect_exec(bContext *C, wmOperator *op)
 {
        Object *obedit = CTX_data_edit_object(C);