Add Edge sharp/smooth to 3DView shading panel, as well as new Vert sharp/smooth.

This commit is contained in:
Bastien Montagne 2014-04-16 15:18:14 +02:00
parent d1b1d194dc
commit 7d45ddae33
3 changed files with 32 additions and 16 deletions

View 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()

View 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:")

View 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);