[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18537] branches/blender2.5/blender/source /blender/editors/mesh: added ops for subdivide, subdiv multi, subdiv smooth , subdiv fractal

Campbell Barton ideasman42 at gmail.com
Fri Jan 16 12:31:00 CET 2009


Hey Shaul, good to see your working on editmesh stuff,

Every now and then I generate docs from RNA and look to see how things
are moving,
I noticed from this commit that some of the operator properties are
not in keeping with existing operators.

Operator props should follow RNA identifier rules.
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/RNA#Naming_Conventions

Some suggestions for property names...

MESH_OT_subdivide_multi(Number_of_cuts=4)
-> MESH_OT_subdivide_multi(divisions=4) # or cuts?

MESH_OT_subdivide_multi_fractal(Number_of_cuts=4, Rand_fac=5.0)
-> MESH_OT_subdivide_multi_fractal(divisions=4, randomize=5.0)

MESH_OT_subdivide_smooth(Smooth=5.0) - lowercase s

I also noticed there were no min/max limits set for these values. They
should be added for correct functionality and also help for clear
documentation so you don't need to add qualifiers to variable names
like fac/factor.



Other names that seem a bit odd (mostly just using capital letters),
not sure who added them.

MESH_OT_add_primitive_circle(Vertices=32, Radius=1.0, Fill=False) - caps
MESH_OT_add_primitive_cone(Vertices=32, Radius=1.0, Depth=1.0, Cap_end=1)
 * Cap_end should be a bool type, could be renamed to "cap"

MESH_OT_add_primitive_cylinder(Vertices=32, Radius=1.0, Depth=1.0)
MESH_OT_add_primitive_grid(X_Subdiv=10, Y_Subdiv=10, Size=1.0)
 * X_Subdiv -> x_divisions

MESH_OT_add_primitive_ico_sphere(Subdivision=2, Size=1.0)
MESH_OT_add_primitive_tube(Vertices=32, Radius=1.0, Depth=1.0)
MESH_OT_add_primitive_uv_sphere(Segments=32, Rings=24, Size=1.0)


On Thu, Jan 15, 2009 at 8:49 PM, Shaul Kedem <shaul_kedem at yahoo.com> wrote:
> 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
> Bf-blender-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
>



-- 
- Campbell


More information about the Bf-committers mailing list