diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-07-21 04:36:07 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-07-21 04:36:07 +0400 |
commit | 0aebd5f14475ef84b0095de4a8f034170b9aee75 (patch) | |
tree | fb10b43f22d18cc8e101ea988d2af430f147e500 /source/blender/editors/object/object_edit.c | |
parent | 5fd16476d990a59098f924d401dc9de9ef40a58a (diff) |
2.5: Make shade smooth/flat operators consistent,
and add object mode operators.
Diffstat (limited to 'source/blender/editors/object/object_edit.c')
-rw-r--r-- | source/blender/editors/object/object_edit.c | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 5ad41bd82f8..37453039cf5 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -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) |