Revision: 18537
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18537
Author:   shul
Date:     2009-01-16 05:48:33 +0100 (Fri, 16 Jan 2009)

Log Message:
-----------
added ops for subdivide, subdiv multi, subdiv smooth, subdiv fractal

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/mesh/editmesh_tools.c
    branches/blender2.5/blender/source/blender/editors/mesh/mesh_intern.h
    branches/blender2.5/blender/source/blender/editors/mesh/mesh_ops.c

Modified: 
branches/blender2.5/blender/source/blender/editors/mesh/editmesh_tools.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/mesh/editmesh_tools.c    
2009-01-16 03:24:12 UTC (rev 18536)
+++ branches/blender2.5/blender/source/blender/editors/mesh/editmesh_tools.c    
2009-01-16 04:48:33 UTC (rev 18537)
@@ -52,7 +52,12 @@
 #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"
 #include "BLI_editVert.h"
@@ -74,12 +79,15 @@
 #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 @@
                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

Modified: branches/blender2.5/blender/source/blender/editors/mesh/mesh_intern.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/mesh/mesh_intern.h       
2009-01-16 03:24:12 UTC (rev 18536)
+++ branches/blender2.5/blender/source/blender/editors/mesh/mesh_intern.h       
2009-01-16 04:48:33 UTC (rev 18537)
@@ -210,6 +210,10 @@
 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
 

Modified: branches/blender2.5/blender/source/blender/editors/mesh/mesh_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/mesh/mesh_ops.c  
2009-01-16 03:24:12 UTC (rev 18536)
+++ branches/blender2.5/blender/source/blender/editors/mesh/mesh_ops.c  
2009-01-16 04:48:33 UTC (rev 18537)
@@ -74,6 +74,10 @@
        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 @@
        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);


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to