and add object mode operators.
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);
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);
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;
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? ****************/
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);
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 */
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);
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");
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");
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);
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)
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);
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);
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
+
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)