diff options
author | Shaul Kedem <shaul_kedem@yahoo.com> | 2009-01-16 07:48:33 +0300 |
---|---|---|
committer | Shaul Kedem <shaul_kedem@yahoo.com> | 2009-01-16 07:48:33 +0300 |
commit | e6b868723780eba01e37e65fc0a72b1a3a594722 (patch) | |
tree | cef9fde5b27e9bed51ddbbb0f4a61aafcc8325ad /source/blender/editors | |
parent | 2a4682bff5fabbad192a0e0c7f66543ea2d02f42 (diff) |
added ops for subdivide, subdiv multi, subdiv smooth, subdiv fractal
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 131 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_intern.h | 4 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_ops.c | 9 |
3 files changed, 144 insertions, 0 deletions
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 396e9ac8437..e801210102d 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -52,6 +52,11 @@ editmesh_tool.c: UI called tools for editmesh, geometry changes here, otherwise #include "DNA_screen_types.h" #include "DNA_view3d_types.h" #include "DNA_key_types.h" +#include "DNA_windowmanager_types.h" + +#include "RNA_types.h" +#include "RNA_define.h" +#include "RNA_access.h" #include "BLI_blenlib.h" #include "BLI_arithb.h" @@ -74,12 +79,15 @@ editmesh_tool.c: UI called tools for editmesh, geometry changes here, otherwise #include "BIF_gl.h" #include "BIF_glutil.h" +#include "WM_api.h" #include "WM_types.h" #include "BMF_Api.h" #include "ED_mesh.h" #include "ED_view3d.h" +#include "ED_util.h" +#include "ED_screen.h" #include "mesh_intern.h" @@ -6277,3 +6285,126 @@ void mesh_mirror_colors(EditMesh *em) BIF_undo_push("Mirror Color face"); } } + +static int subdivide_exec(bContext *C, wmOperator *op) +{ + Object *obedit= CTX_data_edit_object(C); + Scene *scene = CTX_data_scene(C); + EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + + esubdivideflag(obedit, em, 1, 0.0, scene->toolsettings->editbutflag, 1, 0); + + ED_undo_push(C, "Subdivide"); // Note this will become depricated + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + + return OPERATOR_FINISHED; +} + +void MESH_OT_subdivide(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Subdivide"; + ot->idname= "MESH_OT_subdivide"; + + /* api callbacks */ + ot->exec= subdivide_exec; + ot->poll= ED_operator_editmesh; +} + +static int subdivide_multi_exec(bContext *C, wmOperator *op) +{ + Object *obedit= CTX_data_edit_object(C); + Scene *scene = CTX_data_scene(C); + EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + + esubdivideflag(obedit, em, 1, 0.0, scene->toolsettings->editbutflag, RNA_int_get(op->ptr,"Number_of_cuts"), 0); + + ED_undo_push(C, "Subdivide Multi"); // Note this will become depricated + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + + return OPERATOR_FINISHED; +} + +void MESH_OT_subdivide_multi(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Subdivide Multi"; + ot->idname= "MESH_OT_subdivide_multi"; + + /* api callbacks */ + ot->exec= subdivide_multi_exec; + ot->poll= ED_operator_editmesh; + + /* flags */ + ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/; + + /* props */ + + + RNA_def_property_int_default(RNA_def_property(ot->srna, "Number_of_cuts", PROP_INT, PROP_NONE), 4); +} + +static int subdivide_multi_fractal_exec(bContext *C, wmOperator *op) +{ + Object *obedit= CTX_data_edit_object(C); + Scene *scene = CTX_data_scene(C); + EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + + esubdivideflag(obedit, em, 1, -(RNA_float_get(op->ptr,"Rand_fac")/100), scene->toolsettings->editbutflag, RNA_int_get(op->ptr,"Number_of_cuts"), 0); + + ED_undo_push(C, "Subdivide Multi Fractal"); // Note this will become depricated + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + + return OPERATOR_FINISHED; +} + +void MESH_OT_subdivide_multi_fractal(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Subdivide Multi Fractal"; + ot->idname= "MESH_OT_subdivide_multi_fractal"; + + /* api callbacks */ + ot->exec= subdivide_multi_fractal_exec; + ot->poll= ED_operator_editmesh; + + /* flags */ + ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/; + + /* props */ + + RNA_def_property_int_default(RNA_def_property(ot->srna, "Number_of_cuts", PROP_INT, PROP_NONE), 4); + RNA_def_property_float_default(RNA_def_property(ot->srna, "Rand_fac", PROP_FLOAT, PROP_NONE), 5.0); + +} + +static int subdivide_smooth_exec(bContext *C, wmOperator *op) +{ + Object *obedit= CTX_data_edit_object(C); + Scene *scene = CTX_data_scene(C); + EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + + esubdivideflag(obedit, em, 1, 0.292f*RNA_float_get(op->ptr,"Smooth"), scene->toolsettings->editbutflag | B_SMOOTH, 1, 0); + + ED_undo_push(C, "Subdivide Smooth"); // Note this will become depricated + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + + return OPERATOR_FINISHED; +} + +void MESH_OT_subdivide_smooth(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Subdivide Smooth"; + ot->idname= "MESH_OT_subdivide_smooth"; + + /* api callbacks */ + ot->exec= subdivide_smooth_exec; + ot->poll= ED_operator_editmesh; + + /* flags */ + ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/; + + /* props */ + RNA_def_property_float_default(RNA_def_property(ot->srna, "Smooth", PROP_FLOAT, PROP_NONE), 5.0); +}
\ No newline at end of file diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index 4abbdac2459..a8edd9153fa 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -210,6 +210,10 @@ int removedoublesflag(EditMesh *em, short flag, short automerge, float limit); void esubdivideflag(Object *obedit, EditMesh *em, int flag, float rad, int beauty, int numcuts, int seltype); int EdgeSlide(EditMesh *em, short immediate, float imperc); +void MESH_OT_subdivide(struct wmOperatorType *ot); +void MESH_OT_subdivide_multi(struct wmOperatorType *ot); +void MESH_OT_subdivide_multi_fractal(struct wmOperatorType *ot); +void MESH_OT_subdivide_smooth(struct wmOperatorType *ot); #endif // MESH_INTERN_H diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 76fe26d7d8a..c8d27ddcbf2 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -74,6 +74,10 @@ void ED_operatortypes_mesh(void) WM_operatortype_append(MESH_OT_hide_mesh); WM_operatortype_append(MESH_OT_reveal_mesh); WM_operatortype_append(MESH_OT_righthandfaces); + WM_operatortype_append(MESH_OT_subdivide); + WM_operatortype_append(MESH_OT_subdivide_multi); + WM_operatortype_append(MESH_OT_subdivide_multi_fractal); + WM_operatortype_append(MESH_OT_subdivide_smooth); WM_operatortype_append(MESH_OT_select_linked_flat_faces); WM_operatortype_append(MESH_OT_select_sharp_edges); WM_operatortype_append(MESH_OT_add_primitive_plane); @@ -114,6 +118,11 @@ void ED_keymap_mesh(wmWindowManager *wm) RNA_int_set(WM_keymap_add_item(keymap, "MESH_OT_righthandfaces", NKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0)->ptr, "select", 2); RNA_int_set(WM_keymap_add_item(keymap, "MESH_OT_righthandfaces", NKEY, KM_PRESS, KM_CTRL, 0)->ptr, "select", 1); + WM_keymap_add_item(keymap, "MESH_OT_subdivide", WKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "MESH_OT_subdivide_multi", WKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + WM_keymap_add_item(keymap, "MESH_OT_subdivide_multi_fractal", WKEY, KM_PRESS, KM_ALT, 0); + WM_keymap_add_item(keymap, "MESH_OT_subdivide_smooth", WKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); + /* add */ WM_keymap_add_item(keymap, "MESH_OT_add_primitive_plane", ZEROKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "MESH_OT_add_primitive_cube", ONEKEY, KM_PRESS, KM_CTRL, 0); |