diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-09-16 04:18:09 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-09-16 04:18:09 +0400 |
commit | 7e2977b051d6aecd8effe89f11db5373bc0dc3b1 (patch) | |
tree | bf60d34533ecfc99e8c151490e21fbe8928806e5 | |
parent | e8ade192ff081a41275687b167e22792eadcaaa9 (diff) |
move make_prim_radius_prop into a generic function.
-rw-r--r-- | source/blender/editors/curve/editcurve_add.c | 29 | ||||
-rw-r--r-- | source/blender/editors/include/ED_object.h | 11 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_add.c | 21 | ||||
-rw-r--r-- | source/blender/editors/object/object_add.c | 22 |
4 files changed, 42 insertions, 41 deletions
diff --git a/source/blender/editors/curve/editcurve_add.c b/source/blender/editors/curve/editcurve_add.c index 9dcc51337ad..ceb9aa90aca 100644 --- a/source/blender/editors/curve/editcurve_add.c +++ b/source/blender/editors/curve/editcurve_add.c @@ -481,7 +481,7 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) if (obedit == NULL || obedit->type != OB_CURVE) { Curve *cu; - obedit = ED_object_add_type(C, OB_CURVE, loc, rot, TRUE, layer); + obedit = ED_object_add_type(C, OB_CURVE, loc, rot, true, layer); newob = true; cu = (Curve *)obedit->data; @@ -496,7 +496,7 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) } else { /* adding surface */ if (obedit == NULL || obedit->type != OB_SURF) { - obedit = ED_object_add_type(C, OB_SURF, loc, rot, TRUE, layer); + obedit = ED_object_add_type(C, OB_SURF, loc, rot, true, layer); newob = true; } else { @@ -520,7 +520,7 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) if (newob && enter_editmode) ED_undo_push(C, "Enter Editmode"); - ED_object_new_primitive_matrix(C, obedit, loc, rot, mat, TRUE); + ED_object_new_primitive_matrix(C, obedit, loc, rot, mat, true); nu = add_nurbs_primitive(C, obedit, mat, type, newob); editnurb = object_editcurve_get(obedit); @@ -567,7 +567,7 @@ void CURVE_OT_primitive_bezier_curve_add(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - ED_object_add_generic_props(ot, TRUE); + ED_object_add_generic_props(ot, true); } static int add_primitive_bezier_circle_exec(bContext *C, wmOperator *op) @@ -589,7 +589,7 @@ void CURVE_OT_primitive_bezier_circle_add(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - ED_object_add_generic_props(ot, TRUE); + ED_object_add_generic_props(ot, true); } static int add_primitive_nurbs_curve_exec(bContext *C, wmOperator *op) @@ -611,7 +611,7 @@ void CURVE_OT_primitive_nurbs_curve_add(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - ED_object_add_generic_props(ot, TRUE); + ED_object_add_generic_props(ot, true); } static int add_primitive_nurbs_circle_exec(bContext *C, wmOperator *op) @@ -633,7 +633,7 @@ void CURVE_OT_primitive_nurbs_circle_add(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - ED_object_add_generic_props(ot, TRUE); + ED_object_add_generic_props(ot, true); } static int add_primitive_curve_path_exec(bContext *C, wmOperator *op) @@ -655,7 +655,7 @@ void CURVE_OT_primitive_nurbs_path_add(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - ED_object_add_generic_props(ot, TRUE); + ED_object_add_generic_props(ot, true); } /* **************** NURBS surfaces ********************** */ @@ -678,7 +678,7 @@ void SURFACE_OT_primitive_nurbs_surface_curve_add(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - ED_object_add_generic_props(ot, TRUE); + ED_object_add_generic_props(ot, true); } static int add_primitive_nurbs_surface_circle_exec(bContext *C, wmOperator *op) @@ -700,7 +700,7 @@ void SURFACE_OT_primitive_nurbs_surface_circle_add(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - ED_object_add_generic_props(ot, TRUE); + ED_object_add_generic_props(ot, true); } static int add_primitive_nurbs_surface_surface_exec(bContext *C, wmOperator *op) @@ -722,7 +722,7 @@ void SURFACE_OT_primitive_nurbs_surface_surface_add(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - ED_object_add_generic_props(ot, TRUE); + ED_object_add_generic_props(ot, true); } static int add_primitive_nurbs_surface_cylinder_exec(bContext *C, wmOperator *op) @@ -744,7 +744,7 @@ void SURFACE_OT_primitive_nurbs_surface_cylinder_add(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - ED_object_add_generic_props(ot, TRUE); + ED_object_add_generic_props(ot, true); } static int add_primitive_nurbs_surface_sphere_exec(bContext *C, wmOperator *op) @@ -766,7 +766,7 @@ void SURFACE_OT_primitive_nurbs_surface_sphere_add(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - ED_object_add_generic_props(ot, TRUE); + ED_object_add_generic_props(ot, true); } static int add_primitive_nurbs_surface_torus_exec(bContext *C, wmOperator *op) @@ -788,5 +788,6 @@ void SURFACE_OT_primitive_nurbs_surface_torus_add(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - ED_object_add_generic_props(ot, TRUE); + ED_object_add_unit_props(ot); + ED_object_add_generic_props(ot, true); } diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index 7553cb3699c..e1e65fee848 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -141,14 +141,15 @@ void ED_object_rotation_from_view(struct bContext *C, float rot[3]); void ED_object_base_init_transform(struct bContext *C, struct Base *base, const float loc[3], const float rot[3]); float ED_object_new_primitive_matrix(struct bContext *C, struct Object *editob, const float loc[3], const float rot[3], float primmat[4][4], - int apply_diameter); + bool apply_diameter); -void ED_object_add_generic_props(struct wmOperatorType *ot, int do_editmode); -int ED_object_add_generic_get_opts(struct bContext *C, struct wmOperator *op, float loc[3], float rot[3], - bool *enter_editmode, unsigned int *layer, bool *is_view_aligned); +void ED_object_add_unit_props(struct wmOperatorType *ot); +void ED_object_add_generic_props(struct wmOperatorType *ot, bool do_editmode); +bool ED_object_add_generic_get_opts(struct bContext *C, struct wmOperator *op, float loc[3], float rot[3], + bool *enter_editmode, unsigned int *layer, bool *is_view_aligned); struct Object *ED_object_add_type(struct bContext *C, int type, const float loc[3], const float rot[3], - int enter_editmode, unsigned int layer); + bool enter_editmode, unsigned int layer); void ED_object_single_users(struct Main *bmain, struct Scene *scene, bool full, bool copy_groups); void ED_object_single_user(struct Main *bmain, struct Scene *scene, struct Object *ob); diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index f372053db55..094c9d376c9 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -96,15 +96,6 @@ static void make_prim_finish(bContext *C, Object *obedit, bool was_editmode, int WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit); } -static void make_prim_radius_prop(wmOperatorType *ot) -{ - PropertyRNA *prop; - - prop = RNA_def_float(ot->srna, "radius", 1.0f, 0.0, FLT_MAX, "Radius", "", 0.001, 100.00); - RNA_def_property_subtype(prop, PROP_DISTANCE); -} - - static int add_primitive_plane_exec(bContext *C, wmOperator *op) { Object *obedit; @@ -146,7 +137,7 @@ void MESH_OT_primitive_plane_add(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - make_prim_radius_prop(ot); + ED_object_add_unit_props(ot); ED_object_add_generic_props(ot, true); } @@ -192,7 +183,7 @@ void MESH_OT_primitive_cube_add(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - make_prim_radius_prop(ot); + ED_object_add_unit_props(ot); ED_object_add_generic_props(ot, true); } @@ -250,7 +241,7 @@ void MESH_OT_primitive_circle_add(wmOperatorType *ot) /* props */ RNA_def_int(ot->srna, "vertices", 32, 3, INT_MAX, "Vertices", "", 3, 500); - make_prim_radius_prop(ot); + ED_object_add_unit_props(ot); RNA_def_enum(ot->srna, "fill_type", fill_type_items, 0, "Fill Type", ""); ED_object_add_generic_props(ot, true); @@ -308,7 +299,7 @@ void MESH_OT_primitive_cylinder_add(wmOperatorType *ot) /* props */ RNA_def_int(ot->srna, "vertices", 32, 3, INT_MAX, "Vertices", "", 3, 500); - make_prim_radius_prop(ot); + ED_object_add_unit_props(ot); prop = RNA_def_float(ot->srna, "depth", 2.0f, 0.0, FLT_MAX, "Depth", "", 0.001, 100.00); RNA_def_property_subtype(prop, PROP_DISTANCE); RNA_def_enum(ot->srna, "end_fill_type", fill_type_items, 1, "Cap Fill Type", ""); @@ -422,7 +413,7 @@ void MESH_OT_primitive_grid_add(wmOperatorType *ot) /* props */ RNA_def_int(ot->srna, "x_subdivisions", 10, 3, INT_MAX, "X Subdivisions", "", 3, 1000); RNA_def_int(ot->srna, "y_subdivisions", 10, 3, INT_MAX, "Y Subdivisions", "", 3, 1000); - make_prim_radius_prop(ot); + ED_object_add_unit_props(ot); ED_object_add_generic_props(ot, true); } @@ -474,7 +465,7 @@ void MESH_OT_primitive_monkey_add(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - make_prim_radius_prop(ot); + ED_object_add_unit_props(ot); ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ED_object_add_generic_props(ot, true); diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index b907cba33e2..cd7c45d6c27 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -191,7 +191,7 @@ void ED_object_base_init_transform(bContext *C, Base *base, const float loc[3], * Returns standard diameter. */ float ED_object_new_primitive_matrix(bContext *C, Object *obedit, const float loc[3], const float rot[3], float primmat[4][4], - int apply_diameter) + bool apply_diameter) { Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); @@ -236,7 +236,15 @@ static void view_align_update(struct Main *UNUSED(main), struct Scene *UNUSED(sc RNA_struct_idprops_unset(ptr, "rotation"); } -void ED_object_add_generic_props(wmOperatorType *ot, int do_editmode) +void ED_object_add_unit_props(wmOperatorType *ot) +{ + PropertyRNA *prop; + + prop = RNA_def_float(ot->srna, "radius", 1.0f, 0.0, FLT_MAX, "Radius", "", 0.001, 100.00); + RNA_def_property_subtype(prop, PROP_DISTANCE); +} + +void ED_object_add_generic_props(wmOperatorType *ot, bool do_editmode) { PropertyRNA *prop; @@ -261,8 +269,8 @@ void ED_object_add_generic_props(wmOperatorType *ot, int do_editmode) RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); } -int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float loc[3], float rot[3], - bool *enter_editmode, unsigned int *layer, bool *is_view_aligned) +bool ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float loc[3], float rot[3], + bool *enter_editmode, unsigned int *layer, bool *is_view_aligned) { View3D *v3d = CTX_wm_view3d(C); unsigned int _layer; @@ -356,16 +364,16 @@ int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float loc[3], fl if (layer && *layer == 0) { BKE_report(op->reports, RPT_ERROR, "Property 'layer' has no values set"); - return 0; + return false; } - return 1; + return true; } /* For object add primitive operators. * Do not call undo push in this function (users of this function have to). */ Object *ED_object_add_type(bContext *C, int type, const float loc[3], const float rot[3], - int enter_editmode, unsigned int layer) + bool enter_editmode, unsigned int layer) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); |