diff options
Diffstat (limited to 'source/blender/editors/mesh')
-rw-r--r-- | source/blender/editors/mesh/editmesh_bevel.c | 128 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_intersect.c | 17 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_select_similar.c | 2 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_undo.c | 1 |
4 files changed, 54 insertions, 94 deletions
diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c index a90d6530453..b8badd207fe 100644 --- a/source/blender/editors/mesh/editmesh_bevel.c +++ b/source/blender/editors/mesh/editmesh_bevel.c @@ -127,15 +127,10 @@ enum { static float get_bevel_offset(wmOperator *op) { - float val; - if (RNA_enum_get(op->ptr, "offset_type") == BEVEL_AMT_PERCENT) { - val = RNA_float_get(op->ptr, "offset_pct"); - } - else { - val = RNA_float_get(op->ptr, "offset"); + return RNA_float_get(op->ptr, "offset_pct"); } - return val; + return RNA_float_get(op->ptr, "offset"); } static void edbm_bevel_update_status_text(bContext *C, wmOperator *op) @@ -145,14 +140,12 @@ static void edbm_bevel_update_status_text(bContext *C, wmOperator *op) char *p = buf; int available_len = sizeof(buf); Scene *sce = CTX_data_scene(C); - char offset_str[NUM_STR_REP_LEN]; - const char *mode_str, *omiter_str, *imiter_str, *vmesh_str, *profile_type_str, *affect_str; - PropertyRNA *prop; #define WM_MODALKEY(_id) \ WM_modalkeymap_operator_items_to_string_buf( \ op->type, (_id), true, UI_MAX_SHORTCUT_STR, &available_len, &p) + char offset_str[NUM_STR_REP_LEN]; if (RNA_enum_get(op->ptr, "offset_type") == BEVEL_AMT_PERCENT) { BLI_snprintf(offset_str, NUM_STR_REP_LEN, "%.1f%%", RNA_float_get(op->ptr, "offset_pct")); } @@ -167,6 +160,8 @@ static void edbm_bevel_update_status_text(bContext *C, wmOperator *op) true); } + PropertyRNA *prop; + const char *mode_str, *omiter_str, *imiter_str, *vmesh_str, *profile_type_str, *affect_str; prop = RNA_struct_find_property(op->ptr, "offset_type"); RNA_property_enum_name_gettexted( C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &mode_str); @@ -240,18 +235,17 @@ static void edbm_bevel_update_status_text(bContext *C, wmOperator *op) static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal) { Scene *scene = CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); ToolSettings *ts = CTX_data_tool_settings(C); - BevelData *opdata; ViewLayer *view_layer = CTX_data_view_layer(C); - float pixels_per_inch; - int i, otype; if (is_modal) { RNA_float_set(op->ptr, "offset", 0.0f); RNA_float_set(op->ptr, "offset_pct", 0.0f); } - op->customdata = opdata = MEM_mallocN(sizeof(BevelData), "beveldata_mesh_operator"); + op->customdata = MEM_mallocN(sizeof(BevelData), "beveldata_mesh_operator"); + BevelData *opdata = op->customdata; uint objects_used_len = 0; opdata->max_obj_scale = FLT_MIN; @@ -261,7 +255,7 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal) { uint ob_store_len = 0; Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( - view_layer, CTX_wm_view3d(C), &ob_store_len); + view_layer, v3d, &ob_store_len); opdata->ob_store = MEM_malloc_arrayN(ob_store_len, sizeof(*opdata->ob_store), __func__); for (uint ob_index = 0; ob_index < ob_store_len; ob_index++) { Object *obedit = objects[ob_index]; @@ -278,12 +272,12 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal) } opdata->is_modal = is_modal; - otype = RNA_enum_get(op->ptr, "offset_type"); + int otype = RNA_enum_get(op->ptr, "offset_type"); opdata->value_mode = (otype == BEVEL_AMT_PERCENT) ? OFFSET_VALUE_PERCENT : OFFSET_VALUE; opdata->segments = (float)RNA_int_get(op->ptr, "segments"); - pixels_per_inch = U.dpi * U.pixelsize; + float pixels_per_inch = U.dpi * U.pixelsize; - for (i = 0; i < NUM_VALUE_KINDS; i++) { + for (int i = 0; i < NUM_VALUE_KINDS; i++) { opdata->shift_value[i] = -1.0f; opdata->initial_length[i] = -1.0f; /* note: scale for OFFSET_VALUE will get overwritten in edbm_bevel_invoke */ @@ -304,7 +298,6 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal) /* avoid the cost of allocating a bm copy */ if (is_modal) { - View3D *v3d = CTX_wm_view3d(C); ARegion *region = CTX_wm_region(C); for (uint ob_index = 0; ob_index < opdata->ob_store_len; ob_index++) { @@ -491,23 +484,21 @@ static int edbm_bevel_exec(bContext *C, wmOperator *op) static void edbm_bevel_calc_initial_length(wmOperator *op, const wmEvent *event, bool mode_changed) { - BevelData *opdata; - float mlen[2], len, value, sc, st; - int vmode; - - opdata = op->customdata; - mlen[0] = opdata->mcenter[0] - event->mval[0]; - mlen[1] = opdata->mcenter[1] - event->mval[1]; - len = len_v2(mlen); - vmode = opdata->value_mode; + BevelData *opdata = op->customdata; + const float mlen[2] = { + opdata->mcenter[0] - event->mval[0], + opdata->mcenter[1] - event->mval[1], + }; + float len = len_v2(mlen); + int vmode = opdata->value_mode; if (mode_changed || opdata->initial_length[vmode] == -1.0f) { /* If current value is not default start value, adjust len so that * the scaling and offset in edbm_bevel_mouse_set_value will * start at current value */ - value = (vmode == SEGMENTS_VALUE) ? opdata->segments : - RNA_float_get(op->ptr, value_rna_name[vmode]); - sc = opdata->scale[vmode]; - st = value_start[vmode]; + float value = (vmode == SEGMENTS_VALUE) ? opdata->segments : + RNA_float_get(op->ptr, value_rna_name[vmode]); + float sc = opdata->scale[vmode]; + float st = value_start[vmode]; if (value != value_start[vmode]) { len = (st + sc * (len - MVAL_PIXEL_MARGIN) - value) / sc; } @@ -518,18 +509,17 @@ static void edbm_bevel_calc_initial_length(wmOperator *op, const wmEvent *event, static int edbm_bevel_invoke(bContext *C, wmOperator *op, const wmEvent *event) { RegionView3D *rv3d = CTX_wm_region_view3d(C); - BevelData *opdata; - float center_3d[3]; if (!edbm_bevel_init(C, op, true)) { return OPERATOR_CANCELLED; } - opdata = op->customdata; + BevelData *opdata = op->customdata; opdata->launch_event = WM_userdef_event_type_from_keymap_type(event->type); /* initialize mouse values */ + float center_3d[3]; if (!calculateTransformCenter(C, V3D_AROUND_CENTER_MEDIAN, center_3d, opdata->mcenter)) { /* in this case the tool will likely do nothing, * ideally this will never happen and should be checked for above */ @@ -561,13 +551,13 @@ static void edbm_bevel_mouse_set_value(wmOperator *op, const wmEvent *event) { BevelData *opdata = op->customdata; int vmode = opdata->value_mode; - float mdiff[2]; - float value; - mdiff[0] = opdata->mcenter[0] - event->mval[0]; - mdiff[1] = opdata->mcenter[1] - event->mval[1]; + const float mdiff[2] = { + opdata->mcenter[0] - event->mval[0], + opdata->mcenter[1] - event->mval[1], + }; - value = ((len_v2(mdiff) - MVAL_PIXEL_MARGIN) - opdata->initial_length[vmode]); + float value = ((len_v2(mdiff) - MVAL_PIXEL_MARGIN) - opdata->initial_length[vmode]); /* Scale according to value mode */ value = value_start[vmode] + value * opdata->scale[vmode]; @@ -599,12 +589,10 @@ static void edbm_bevel_mouse_set_value(wmOperator *op, const wmEvent *event) static void edbm_bevel_numinput_set_value(wmOperator *op) { BevelData *opdata = op->customdata; - float value; - int vmode; - vmode = opdata->value_mode; - value = (vmode == SEGMENTS_VALUE) ? opdata->segments : - RNA_float_get(op->ptr, value_rna_name[vmode]); + int vmode = opdata->value_mode; + float value = (vmode == SEGMENTS_VALUE) ? opdata->segments : + RNA_float_get(op->ptr, value_rna_name[vmode]); applyNumInput(&opdata->num_input[vmode], &value); CLAMP(value, value_clamp_min[vmode], value_clamp_max[vmode]); if (vmode == SEGMENTS_VALUE) { @@ -616,82 +604,61 @@ static void edbm_bevel_numinput_set_value(wmOperator *op) } } -/* Hide one of offset or offset_pct, depending on offset_type */ -static bool edbm_bevel_poll_property(const bContext *UNUSED(C), - wmOperator *op, - const PropertyRNA *prop) -{ - const char *prop_id = RNA_property_identifier(prop); - - if (STRPREFIX(prop_id, "offset")) { - int offset_type = RNA_enum_get(op->ptr, "offset_type"); - - if (STREQ(prop_id, "offset") && offset_type == BEVEL_AMT_PERCENT) { - return false; - } - if (STREQ(prop_id, "offset_pct") && offset_type != BEVEL_AMT_PERCENT) { - return false; - } - } - - return true; -} - wmKeyMap *bevel_modal_keymap(wmKeyConfig *keyconf) { static const EnumPropertyItem modal_items[] = { {BEV_MODAL_CANCEL, "CANCEL", 0, "Cancel", "Cancel bevel"}, {BEV_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", "Confirm bevel"}, - {BEV_MODAL_VALUE_OFFSET, "VALUE_OFFSET", 0, "Change offset", "Value changes offset"}, - {BEV_MODAL_VALUE_PROFILE, "VALUE_PROFILE", 0, "Change profile", "Value changes profile"}, - {BEV_MODAL_VALUE_SEGMENTS, "VALUE_SEGMENTS", 0, "Change segments", "Value changes segments"}, - {BEV_MODAL_SEGMENTS_UP, "SEGMENTS_UP", 0, "Increase segments", "Increase segments"}, - {BEV_MODAL_SEGMENTS_DOWN, "SEGMENTS_DOWN", 0, "Decrease segments", "Decrease segments"}, + {BEV_MODAL_VALUE_OFFSET, "VALUE_OFFSET", 0, "Change Offset", "Value changes offset"}, + {BEV_MODAL_VALUE_PROFILE, "VALUE_PROFILE", 0, "Change Profile", "Value changes profile"}, + {BEV_MODAL_VALUE_SEGMENTS, "VALUE_SEGMENTS", 0, "Change Segments", "Value changes segments"}, + {BEV_MODAL_SEGMENTS_UP, "SEGMENTS_UP", 0, "Increase Segments", "Increase segments"}, + {BEV_MODAL_SEGMENTS_DOWN, "SEGMENTS_DOWN", 0, "Decrease Segments", "Decrease segments"}, {BEV_MODAL_OFFSET_MODE_CHANGE, "OFFSET_MODE_CHANGE", 0, - "Change offset mode", + "Change Offset Mode", "Cycle through offset modes"}, {BEV_MODAL_CLAMP_OVERLAP_TOGGLE, "CLAMP_OVERLAP_TOGGLE", 0, - "Toggle clamp overlap", + "Toggle Clamp Overlap", "Toggle clamp overlap flag"}, {BEV_MODAL_AFFECT_CHANGE, "AFFECT_CHANGE", 0, - "Change affect type", + "Change Affect Type", "Change which geometry type the operation affects, edges or vertices"}, {BEV_MODAL_HARDEN_NORMALS_TOGGLE, "HARDEN_NORMALS_TOGGLE", 0, - "Toggle harden normals", + "Toggle Harden Normals", "Toggle harden normals flag"}, {BEV_MODAL_MARK_SEAM_TOGGLE, "MARK_SEAM_TOGGLE", 0, - "Toggle mark seam", + "Toggle Mark Seam", "Toggle mark seam flag"}, {BEV_MODAL_MARK_SHARP_TOGGLE, "MARK_SHARP_TOGGLE", 0, - "Toggle mark sharp", + "Toggle Mark Sharp", "Toggle mark sharp flag"}, {BEV_MODAL_OUTER_MITER_CHANGE, "OUTER_MITER_CHANGE", 0, - "Change outer miter", + "Change Outer Miter", "Cycle through outer miter kinds"}, {BEV_MODAL_INNER_MITER_CHANGE, "INNER_MITER_CHANGE", 0, - "Change inner miter", + "Change Inner Miter", "Cycle through inner miter kinds"}, {BEV_MODAL_PROFILE_TYPE_CHANGE, "PROFILE_TYPE_CHANGE", 0, "Cycle through profile types", ""}, {BEV_MODAL_VERTEX_MESH_CHANGE, "VERTEX_MESH_CHANGE", 0, - "Change intersection method", + "Change Intersection Method", "Cycle through intersection methods"}, {0, NULL, 0, NULL, NULL}, }; @@ -1109,7 +1076,6 @@ void MESH_OT_bevel(wmOperatorType *ot) ot->modal = edbm_bevel_modal; ot->cancel = edbm_bevel_cancel; ot->poll = ED_operator_editmesh; - ot->poll_property = edbm_bevel_poll_property; ot->ui = edbm_bevel_ui; /* flags */ diff --git a/source/blender/editors/mesh/editmesh_intersect.c b/source/blender/editors/mesh/editmesh_intersect.c index 528ad57b9bf..e2112f91060 100644 --- a/source/blender/editors/mesh/editmesh_intersect.c +++ b/source/blender/editors/mesh/editmesh_intersect.c @@ -121,11 +121,10 @@ static void edbm_intersect_select(BMEditMesh *em, struct Mesh *me, bool do_selec } /* -------------------------------------------------------------------- */ -/* Cut intersections into geometry */ - /** \name Simple Intersect (self-intersect) - * \{ - */ + * + * Cut intersections into geometry. + * \{ */ enum { ISECT_SEL = 0, @@ -331,15 +330,11 @@ void MESH_OT_intersect(struct wmOperatorType *ot) /** \} */ /* -------------------------------------------------------------------- */ -/* Boolean (a kind of intersect) */ - /** \name Boolean Intersect * * \note internally this is nearly exactly the same as 'MESH_OT_intersect', * however from a user perspective they are quite different, so expose as different tools. - * - * \{ - */ + * \{ */ static int edbm_intersect_boolean_exec(bContext *C, wmOperator *op) { @@ -488,9 +483,7 @@ void MESH_OT_intersect_boolean(struct wmOperatorType *ot) /** \} */ /* -------------------------------------------------------------------- */ -/* Face Split by Edges */ - -/** \name Face/Edge Split +/** \name Face Split by Edges * \{ */ static void bm_face_split_by_edges(BMesh *bm, diff --git a/source/blender/editors/mesh/editmesh_select_similar.c b/source/blender/editors/mesh/editmesh_select_similar.c index f94d3ba5a70..00349983c57 100644 --- a/source/blender/editors/mesh/editmesh_select_similar.c +++ b/source/blender/editors/mesh/editmesh_select_similar.c @@ -83,7 +83,7 @@ static const EnumPropertyItem prop_similar_types[] = { {SIMFACE_SIDES, "SIDES", 0, "Polygon Sides", ""}, {SIMFACE_PERIMETER, "PERIMETER", 0, "Perimeter", ""}, {SIMFACE_NORMAL, "NORMAL", 0, "Normal", ""}, - {SIMFACE_COPLANAR, "COPLANAR", 0, "Co-planar", ""}, + {SIMFACE_COPLANAR, "COPLANAR", 0, "Coplanar", ""}, {SIMFACE_SMOOTH, "SMOOTH", 0, "Flat/Smooth", ""}, {SIMFACE_FACEMAP, "FACE_MAP", 0, "Face-Map", ""}, #ifdef WITH_FREESTYLE diff --git a/source/blender/editors/mesh/editmesh_undo.c b/source/blender/editors/mesh/editmesh_undo.c index 41d840c4a2d..43cad2db185 100644 --- a/source/blender/editors/mesh/editmesh_undo.c +++ b/source/blender/editors/mesh/editmesh_undo.c @@ -118,6 +118,7 @@ typedef struct UndoMesh { #ifdef USE_ARRAY_STORE +/* -------------------------------------------------------------------- */ /** \name Array Store * \{ */ |