2.5: Make shade smooth/flat operators consistent,

and add object mode operators.
This commit is contained in:
Brecht Van Lommel 2009-07-21 00:36:07 +00:00
parent 5fd16476d9
commit 0aebd5f144
11 changed files with 108 additions and 20 deletions

@ -75,7 +75,8 @@ void CURVE_OT_spline_type_set(struct wmOperatorType *ot);
void CURVE_OT_radius_set(struct wmOperatorType *ot);
void CURVE_OT_spline_weight_set(struct wmOperatorType *ot);
void CURVE_OT_handle_type_set(struct wmOperatorType *ot);
void CURVE_OT_smooth_set(struct wmOperatorType *ot);
void CURVE_OT_shade_smooth(struct wmOperatorType *ot);
void CURVE_OT_shade_flat(struct wmOperatorType *ot);
void CURVE_OT_tilt_clear(struct wmOperatorType *ot);
void CURVE_OT_smooth(struct wmOperatorType *ot);

@ -130,7 +130,8 @@ void ED_operatortypes_curve(void)
WM_operatortype_append(CURVE_OT_radius_set);
WM_operatortype_append(CURVE_OT_spline_weight_set);
WM_operatortype_append(CURVE_OT_handle_type_set);
WM_operatortype_append(CURVE_OT_smooth_set);
WM_operatortype_append(CURVE_OT_shade_smooth);
WM_operatortype_append(CURVE_OT_shade_flat);
WM_operatortype_append(CURVE_OT_tilt_clear);
WM_operatortype_append(CURVE_OT_smooth);

@ -4550,14 +4550,14 @@ void CURVE_OT_delete(wmOperatorType *ot)
RNA_def_enum(ot->srna, "type", type_items, 0, "Type", "Which elements to delete.");
}
/********************** set smooth operator *********************/
/********************** shade smooth/flat operator *********************/
static int set_smooth_exec(bContext *C, wmOperator *op)
static int shade_smooth_exec(bContext *C, wmOperator *op)
{
Object *obedit= CTX_data_edit_object(C);
ListBase *editnurb= curve_get_editcurve(obedit);
Nurb *nu;
int clear= RNA_boolean_get(op->ptr, "clear");
int clear= (strcmp(op->idname, "CURVE_OT_shade_flat") == 0);
if(obedit->type != OB_CURVE)
return OPERATOR_CANCELLED;
@ -4575,21 +4575,32 @@ static int set_smooth_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
void CURVE_OT_smooth_set(wmOperatorType *ot)
void CURVE_OT_shade_smooth(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Set Smooth";
ot->idname= "CURVE_OT_smooth_set";
ot->name= "Shade Smooth";
ot->idname= "CURVE_OT_shade_smooth";
/* api callbacks */
ot->exec= set_smooth_exec;
ot->exec= shade_smooth_exec;
ot->poll= ED_operator_editsurfcurve;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
/* properties */
RNA_def_boolean(ot->srna, "clear", 0, "Clear", "Clear smooth shading to solid for selection instead of enabling it.");
void CURVE_OT_shade_flat(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Shade Flat";
ot->idname= "CURVE_OT_shade_flat";
/* api callbacks */
ot->exec= shade_smooth_exec;
ot->poll= ED_operator_editsurfcurve;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
/************** join operator, to be used externally? ****************/

@ -7134,7 +7134,7 @@ void MESH_OT_faces_shade_smooth(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
static int mesh_faces_shade_solid_exec(bContext *C, wmOperator *op)
static int mesh_faces_shade_flat_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Object *obedit= CTX_data_edit_object(C);
@ -7148,14 +7148,14 @@ static int mesh_faces_shade_solid_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
void MESH_OT_faces_shade_solid(wmOperatorType *ot)
void MESH_OT_faces_shade_flat(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Shade Flat";
ot->idname= "MESH_OT_faces_shade_solid";
ot->idname= "MESH_OT_faces_shade_flat";
/* api callbacks */
ot->exec= mesh_faces_shade_solid_exec;
ot->exec= mesh_faces_shade_flat_exec;
ot->poll= ED_operator_editmesh;
/* flags */

@ -217,7 +217,7 @@ void MESH_OT_quads_convert_to_tris(struct wmOperatorType *ot);
void MESH_OT_tris_convert_to_quads(struct wmOperatorType *ot);
void MESH_OT_edge_flip(struct wmOperatorType *ot);
void MESH_OT_faces_shade_smooth(struct wmOperatorType *ot);
void MESH_OT_faces_shade_solid(struct wmOperatorType *ot);
void MESH_OT_faces_shade_flat(struct wmOperatorType *ot);
void MESH_OT_split(struct wmOperatorType *ot);
void MESH_OT_extrude_repeat(struct wmOperatorType *ot);
void MESH_OT_edge_rotate(struct wmOperatorType *ot);

@ -147,7 +147,7 @@ static int face_specials_invoke(bContext *C, wmOperator *op, wmEvent *event)
uiItemO(layout, NULL, 0, "MESH_OT_flip_normals");
// uiItemO(layout, "Bevel", 0, "MESH_OT_bevel"); // bevelmenu(em)
uiItemO(layout, NULL, 0, "MESH_OT_faces_shade_smooth");
uiItemO(layout, NULL, 0, "MESH_OT_faces_shade_solid");
uiItemO(layout, NULL, 0, "MESH_OT_faces_shade_flat");
uiItemO(layout, NULL, 0, "MESH_OT_quads_convert_to_tris");
uiItemO(layout, NULL, 0, "MESH_OT_tris_convert_to_quads");
uiItemO(layout, NULL, 0, "MESH_OT_edge_flip");
@ -205,7 +205,7 @@ static int specials_invoke(bContext *C, wmOperator *op, wmEvent *event)
uiItemO(layout, "Smooth", 0, "MESH_OT_vertices_smooth");
// uiItemO(layout, "Bevel", 0, "MESH_OT_bevel"); // bevelmenu(em)
uiItemO(layout, NULL, 0, "MESH_OT_faces_shade_smooth");
uiItemO(layout, NULL, 0, "MESH_OT_faces_shade_solid");
uiItemO(layout, NULL, 0, "MESH_OT_faces_shade_flat");
//uiItemO(layout, "Blend From Shape", 0, "MESH_OT_blend_from_shape");
//uiItemO(layout, "Propagate to All Shapes", 0, "MESH_OT_shape_propagate_to_all");
uiItemO(layout, "Select Vertex Path", 0, "MESH_OT_select_vertex_path");
@ -284,7 +284,7 @@ void ED_operatortypes_mesh(void)
WM_operatortype_append(MESH_OT_tris_convert_to_quads);
WM_operatortype_append(MESH_OT_edge_flip);
WM_operatortype_append(MESH_OT_faces_shade_smooth);
WM_operatortype_append(MESH_OT_faces_shade_solid);
WM_operatortype_append(MESH_OT_faces_shade_flat);
WM_operatortype_append(MESH_OT_delete);

@ -6388,6 +6388,76 @@ void OBJECT_OT_join(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
/********************** Smooth/Flat *********************/
static int shade_smooth_exec(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
Object *ob;
Curve *cu;
Nurb *nu;
int clear= (strcmp(op->idname, "OBJECT_OT_shade_flat") == 0);
int done= 0;
CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
ob= base->object;
if(ob->type==OB_MESH) {
mesh_set_smooth_flag(ob, !clear);
DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
done= 1;
}
else if ELEM(ob->type, OB_SURF, OB_CURVE) {
cu= ob->data;
for(nu=cu->nurb.first; nu; nu=nu->next) {
if(!clear) nu->flag |= ME_SMOOTH;
else nu->flag &= ~ME_SMOOTH;
nu= nu->next;
}
DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
done= 1;
}
}
CTX_DATA_END;
return (done)? OPERATOR_FINISHED: OPERATOR_CANCELLED;
}
void OBJECT_OT_shade_flat(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Shade Flat";
ot->idname= "OBJECT_OT_shade_flat";
/* api callbacks */
ot->exec= shade_smooth_exec;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
void OBJECT_OT_shade_smooth(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Shade Smooth";
ot->idname= "OBJECT_OT_shade_smooth";
/* api callbacks */
ot->exec= shade_smooth_exec;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
/* ********************** */
void image_aspect(Scene *scene, View3D *v3d)

@ -65,6 +65,8 @@ void OBJECT_OT_object_add(struct wmOperatorType *ot);
void OBJECT_OT_duplicate(struct wmOperatorType *ot);
void OBJECT_OT_delete(struct wmOperatorType *ot);
void OBJECT_OT_join(struct wmOperatorType *ot);
void OBJECT_OT_shade_smooth(struct wmOperatorType *ot);
void OBJECT_OT_shade_flat(struct wmOperatorType *ot);
void OBJECT_OT_mesh_add(struct wmOperatorType *ot);
void OBJECT_OT_curve_add(struct wmOperatorType *ot);

@ -87,6 +87,8 @@ void ED_operatortypes_object(void)
WM_operatortype_append(OBJECT_OT_duplicates_make_real);
WM_operatortype_append(OBJECT_OT_duplicate);
WM_operatortype_append(OBJECT_OT_join);
WM_operatortype_append(OBJECT_OT_shade_smooth);
WM_operatortype_append(OBJECT_OT_shade_flat);
WM_operatortype_append(GROUP_OT_group_create);
WM_operatortype_append(GROUP_OT_objects_remove);
WM_operatortype_append(GROUP_OT_objects_add_active);

@ -900,3 +900,4 @@ void SCENE_OT_render_layer_remove(wmOperatorType *ot)
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}

@ -2263,7 +2263,7 @@ static void view3d_edit_mesh_facesmenu(bContext *C, uiLayout *layout, void *arg_
uiItemS(layout);
uiItemO(layout, NULL, 0, "MESH_OT_faces_shade_smooth");
uiItemO(layout, NULL, 0, "MESH_OT_faces_shade_solid");
uiItemO(layout, NULL, 0, "MESH_OT_faces_shade_flat");
}
static void view3d_edit_mesh_normalsmenu(bContext *C, uiLayout *layout, void *arg_unused)