diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenloader/intern/versioning_290.c | 14 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_opdefines.c | 11 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_operators.h | 6 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_bevel.c | 4 | ||||
-rw-r--r-- | source/blender/bmesh/tools/bmesh_bevel.c | 56 | ||||
-rw-r--r-- | source/blender/bmesh/tools/bmesh_bevel.h | 2 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_bevel.c | 71 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_modifier_types.h | 14 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_modifier.c | 6 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_bevel.c | 16 |
10 files changed, 133 insertions, 67 deletions
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c index a84d9711491..b6caa018756 100644 --- a/source/blender/blenloader/intern/versioning_290.c +++ b/source/blender/blenloader/intern/versioning_290.c @@ -413,5 +413,19 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) } FOREACH_NODETREE_END; } + + /* Refactor bevel affect type to use an enum. */ + if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "char", "affect_type")) { + for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) { + LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) { + if (md->type == eModifierType_Bevel) { + BevelModifierData *bmd = (BevelModifierData *)md; + const bool use_vertex_bevel = bmd->flags & MOD_BEVEL_VERT_DEPRECATED; + bmd->affect_type = use_vertex_bevel ? MOD_BEVEL_AFFECT_VERTICES : + MOD_BEVEL_AFFECT_EDGES; + } + } + } + } } } diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 67c0fdba12b..4117ad67dd3 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -1755,6 +1755,12 @@ static BMO_FlagSet bmo_enum_bevel_vmesh_method[] = { {0, NULL}, }; +static BMO_FlagSet bmo_enum_bevel_affect_type[] = { + {BEVEL_AFFECT_VERTICES, "VERTICES"}, + {BEVEL_AFFECT_EDGES, "EDGES"}, + {0, NULL}, +}; + /* * Bevel. * @@ -1768,10 +1774,11 @@ static BMOpDefine bmo_bevel_def = { {"offset_type", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_bevel_offset_type}, /* how to measure the offset */ {"profile_type", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, - bmo_enum_bevel_profile_type}, /* The profile type to use for bevel. */ + bmo_enum_bevel_profile_type}, /* The profile type to use for bevel. */ {"segments", BMO_OP_SLOT_INT}, /* number of segments in bevel */ {"profile", BMO_OP_SLOT_FLT}, /* profile shape, 0->1 (.5=>round) */ - {"vertex_only", BMO_OP_SLOT_BOOL}, /* only bevel vertices, not edges */ + {"affect", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, + bmo_enum_bevel_affect_type}, /* Whether to bevel vertices or edges. */ {"clamp_overlap", BMO_OP_SLOT_BOOL}, /* do not allow beveled edges/vertices to overlap each other */ {"material", BMO_OP_SLOT_INT}, /* material for bevel faces, -1 means get from adjacent faces */ {"loop_slide", BMO_OP_SLOT_BOOL}, /* prefer to slide along edges to having even widths */ diff --git a/source/blender/bmesh/intern/bmesh_operators.h b/source/blender/bmesh/intern/bmesh_operators.h index 29fcf7ca0ca..c0e59758120 100644 --- a/source/blender/bmesh/intern/bmesh_operators.h +++ b/source/blender/bmesh/intern/bmesh_operators.h @@ -139,6 +139,12 @@ enum { BEVEL_VMESH_CUTOFF, }; +/* Bevel affect option. */ +enum { + BEVEL_AFFECT_VERTICES = 0, + BEVEL_AFFECT_EDGES = 1, +}; + /* Normal Face Strength values */ enum { FACE_STRENGTH_WEAK = -16384, diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c index 67f875ac262..4e708b595e0 100644 --- a/source/blender/bmesh/operators/bmo_bevel.c +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -35,7 +35,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op) const int offset_type = BMO_slot_int_get(op->slots_in, "offset_type"); const int profile_type = BMO_slot_int_get(op->slots_in, "profile_type"); const int seg = BMO_slot_int_get(op->slots_in, "segments"); - const bool vonly = BMO_slot_bool_get(op->slots_in, "vertex_only"); + const int affect_type = BMO_slot_int_get(op->slots_in, "affect"); const float profile = BMO_slot_float_get(op->slots_in, "profile"); const bool clamp_overlap = BMO_slot_bool_get(op->slots_in, "clamp_overlap"); const int material = BMO_slot_int_get(op->slots_in, "material"); @@ -79,7 +79,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op) profile_type, seg, profile, - vonly, + affect_type, false, clamp_overlap, NULL, diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index 8650d899398..236c759c06a 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -266,7 +266,7 @@ typedef struct BevVert { int selcount; /** Count of wire edges. */ int wirecount; - /** Offset for this vertex, if vertex_only bevel. */ + /** Offset for this vertex, if vertex only bevel. */ float offset; /** Any seams on attached edges? */ bool any_seam; @@ -325,14 +325,14 @@ typedef struct BevelParams { int offset_type; /** Profile type: radius, superellipse, or custom */ int profile_type; + /** Bevel vertices only or edges. */ + int affect_type; /** Number of segments in beveled edge profile. */ int seg; /** User profile setting. */ float profile; /** Superellipse parameter for edge profile. */ float pro_super_r; - /** Bevel vertices only. */ - bool vertex_only; /** Bevel amount affected by weights on edges or verts. */ bool use_weights; /** Should bevel prefer to slide along edges rather than keep widths spec? */ @@ -350,9 +350,9 @@ typedef struct BevelParams { char _pad[1]; /** The struct used to store the custom profile input. */ const struct CurveProfile *custom_profile; - /** Vertex group array, maybe set if vertex_only. */ + /** Vertex group array, maybe set if vertex only. */ const struct MDeformVert *dvert; - /** Vertex group index, maybe set if vertex_only. */ + /** Vertex group index, maybe set if vertex only. */ int vertex_group; /** If >= 0, material number for bevel; else material comes from adjacent faces. */ int mat_nr; @@ -1604,7 +1604,7 @@ static void set_profile_params(BevelParams *bp, BevVert *bv, BoundVert *bndv) zero_v3(pro->proj_dir); do_linear_interp = false; } - else if (bp->vertex_only) { + else if (bp->affect_type == BEVEL_AFFECT_VERTICES) { copy_v3_v3(pro->start, start); copy_v3_v3(pro->middle, bv->v->co); copy_v3_v3(pro->end, end); @@ -2526,7 +2526,7 @@ static void build_boundary_vertex_only(BevelParams *bp, BevVert *bv, bool constr BoundVert *v; float co[3]; - BLI_assert(bp->vertex_only); + BLI_assert(bp->affect_type == BEVEL_AFFECT_VERTICES); e = efirst = &bv->edges[0]; do { @@ -2799,7 +2799,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct) return; } - if (bp->vertex_only) { + if (bp->affect_type == BEVEL_AFFECT_VERTICES) { build_boundary_vertex_only(bp, bv, construct); return; } @@ -4332,7 +4332,7 @@ static int tri_corner_test(BevelParams *bp, BevVert *bv) int in_plane_e = 0; /* The superellipse snapping of this case isn't helpful with custom profiles enabled. */ - if (bp->vertex_only || bp->profile_type == BEVEL_PROFILE_CUSTOM) { + if (bp->affect_type == BEVEL_AFFECT_VERTICES || bp->profile_type == BEVEL_PROFILE_CUSTOM) { return -1; } if (bv->vmesh->count != 3) { @@ -5156,7 +5156,7 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv, BoundVert else { fc = NULL; } - if (bp->vertex_only) { + if (bp->affect_type == BEVEL_AFFECT_VERTICES) { e = bndv->efirst; } else { @@ -5177,7 +5177,7 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv, BoundVert bmv3 = mesh_vert(vm, i, j + 1, k + 1)->v; bmv4 = mesh_vert(vm, i, j + 1, k)->v; BLI_assert(bmv1 && bmv2 && bmv3 && bmv4); - if (bp->vertex_only) { + if (bp->affect_type == BEVEL_AFFECT_VERTICES) { if (j < k) { if (k == ns2 && j == ns2 - 1) { r_f = bev_create_quad_ex(bm, @@ -5204,7 +5204,7 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv, BoundVert r_f = bev_create_quad(bm, bmv1, bmv2, bmv3, bmv4, f2, f2, f2, f2, mat_nr); } else { /* j == k */ - /* Only one edge attached to v, since vertex_only. */ + /* Only one edge attached to v, since vertex only. */ if (e->is_seam) { r_f = bev_create_quad_ex( bm, bmv1, bmv2, bmv3, bmv4, f2, f2, f2, f2, bme, NULL, bme, NULL, f2, mat_nr); @@ -5262,7 +5262,7 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv, BoundVert } } while ((bndv = bndv->next) != vm->boundstart); bmv1 = mesh_vert(vm, 0, ns2, ns2)->v; - if (bp->vertex_only || count_bound_vert_seams(bv) <= 1) { + if (bp->affect_type == BEVEL_AFFECT_VERTICES || count_bound_vert_seams(bv) <= 1) { bev_merge_uvs(bm, bmv1); } } @@ -5572,7 +5572,7 @@ static void bevel_vert_two_edges(BevelParams *bp, BMesh *bm, BevVert *bv) BoundVert *bndv; int ns, k; - BLI_assert(vm->count == 2 && bp->vertex_only); + BLI_assert(vm->count == 2 && bp->affect_type == BEVEL_AFFECT_VERTICES); v1 = mesh_vert(vm, 0, 0, 0)->v; v2 = mesh_vert(vm, 1, 0, 0)->v; @@ -5733,7 +5733,7 @@ static void build_vmesh(BevelParams *bp, BMesh *bm, BevVert *bv) switch (vm->mesh_kind) { case M_NONE: - if (n == 2 && bp->vertex_only) { + if (n == 2 && bp->affect_type == BEVEL_AFFECT_VERTICES) { bevel_vert_two_edges(bp, bm, bv); } break; @@ -6034,7 +6034,7 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) BM_ITER_ELEM (bme, &iter, v, BM_EDGES_OF_VERT) { int face_count = BM_edge_face_count(bme); BM_BEVEL_EDGE_TAG_DISABLE(bme); - if (BM_elem_flag_test(bme, BM_ELEM_TAG) && !bp->vertex_only) { + if (BM_elem_flag_test(bme, BM_ELEM_TAG) && bp->affect_type != BEVEL_AFFECT_VERTICES) { BLI_assert(face_count == 2); nsel++; if (!first_bme) { @@ -6045,14 +6045,14 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) /* Good to start face chain from this edge. */ first_bme = bme; } - if (face_count > 0 || bp->vertex_only) { + if (face_count > 0 || bp->affect_type == BEVEL_AFFECT_VERTICES) { tot_edges++; } if (BM_edge_is_wire(bme)) { tot_wire++; /* If edge beveling, exclude wire edges from edges array. * Mark this edge as "chosen" so loop below won't choose it. */ - if (!bp->vertex_only) { + if (bp->affect_type != BEVEL_AFFECT_VERTICES) { BM_BEVEL_EDGE_TAG_ENABLE(bme); } } @@ -6061,7 +6061,8 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) first_bme = v->e; } - if ((nsel == 0 && !bp->vertex_only) || (tot_edges < 2 && bp->vertex_only)) { + if ((nsel == 0 && bp->affect_type != BEVEL_AFFECT_VERTICES) || + (tot_edges < 2 && bp->affect_type == BEVEL_AFFECT_VERTICES)) { /* Signal this vert isn't being beveled. */ BM_elem_flag_disable(v, BM_ELEM_TAG); return NULL; @@ -6091,7 +6092,7 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) for (i = 0; i < tot_edges; i++) { e = &bv->edges[i]; bme = e->e; - if (BM_elem_flag_test(bme, BM_ELEM_TAG) && !bp->vertex_only) { + if (BM_elem_flag_test(bme, BM_ELEM_TAG) && bp->affect_type != BEVEL_AFFECT_VERTICES) { e->is_bev = true; e->seg = bp->seg; } @@ -6130,7 +6131,7 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) } } - if (bp->vertex_only) { + if (bp->affect_type == BEVEL_AFFECT_VERTICES) { /* Modify the offset by the vertex group or bevel weight if they are specified. */ if (bp->dvert != NULL && bp->vertex_group != -1) { weight = BKE_defvert_find_weight(bp->dvert + BM_elem_index_get(v), bp->vertex_group); @@ -6220,7 +6221,7 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) e->offset_r_spec *= weight; } } - else if (bp->vertex_only) { + else if (bp->affect_type == BEVEL_AFFECT_VERTICES) { /* Weight has already been applied to bv->offset, if present. * Transfer to e->offset_[lr]_spec according to offset_type. */ float edge_dir[3]; @@ -7371,7 +7372,7 @@ static void bevel_limit_offset(BevelParams *bp, BMesh *bm) } for (i = 0; i < bv->edgecount; i++) { eh = &bv->edges[i]; - if (bp->vertex_only) { + if (bp->affect_type == BEVEL_AFFECT_VERTICES) { collision_offset = vertex_collide_offset(bp, eh); if (collision_offset < limited_offset) { limited_offset = collision_offset; @@ -7431,7 +7432,7 @@ void BM_mesh_bevel(BMesh *bm, const int profile_type, const int segments, const float profile, - const bool vertex_only, + const bool affect_type, const bool use_weights, const bool limit_offset, const struct MDeformVert *dvert, @@ -7462,11 +7463,12 @@ void BM_mesh_bevel(BMesh *bm, bp.seg = segments; bp.profile = profile; bp.pro_super_r = -logf(2.0) / logf(sqrtf(profile)); /* Convert to superellipse exponent. */ - bp.vertex_only = vertex_only; + bp.affect_type = affect_type; bp.use_weights = use_weights; bp.loop_slide = loop_slide; bp.limit_offset = limit_offset; - bp.offset_adjust = !vertex_only && !ELEM(offset_type, BEVEL_AMT_PERCENT, BEVEL_AMT_ABSOLUTE); + bp.offset_adjust = bp.affect_type != BEVEL_AFFECT_VERTICES && + !ELEM(offset_type, BEVEL_AMT_PERCENT, BEVEL_AMT_ABSOLUTE); bp.dvert = dvert; bp.vertex_group = vertex_group; bp.mat_nr = mat; @@ -7581,7 +7583,7 @@ void BM_mesh_bevel(BMesh *bm, } /* Build polygons for edges. */ - if (!bp.vertex_only) { + if (bp.affect_type != BEVEL_AFFECT_VERTICES) { BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { if (BM_elem_flag_test(e, BM_ELEM_TAG)) { bevel_build_edge_polygons(bm, &bp, e); diff --git a/source/blender/bmesh/tools/bmesh_bevel.h b/source/blender/bmesh/tools/bmesh_bevel.h index 667482960d3..317ca05b68a 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.h +++ b/source/blender/bmesh/tools/bmesh_bevel.h @@ -30,7 +30,7 @@ void BM_mesh_bevel(BMesh *bm, const int profile_type, const int segments, const float profile, - const bool vertex_only, + const bool affect_type, const bool use_weights, const bool limit_offset, const struct MDeformVert *dvert, diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c index 4c207e27c30..61b40dd3e60 100644 --- a/source/blender/editors/mesh/editmesh_bevel.c +++ b/source/blender/editors/mesh/editmesh_bevel.c @@ -115,7 +115,7 @@ enum { BEV_MODAL_SEGMENTS_DOWN, BEV_MODAL_OFFSET_MODE_CHANGE, BEV_MODAL_CLAMP_OVERLAP_TOGGLE, - BEV_MODAL_VERTEX_ONLY_TOGGLE, + BEV_MODAL_AFFECT_CHANGE, BEV_MODAL_HARDEN_NORMALS_TOGGLE, BEV_MODAL_MARK_SEAM_TOGGLE, BEV_MODAL_MARK_SHARP_TOGGLE, @@ -146,7 +146,7 @@ static void edbm_bevel_update_status_text(bContext *C, wmOperator *op) 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; + const char *mode_str, *omiter_str, *imiter_str, *vmesh_str, *profile_type_str, *affect_str; PropertyRNA *prop; #define WM_MODALKEY(_id) \ @@ -182,6 +182,9 @@ static void edbm_bevel_update_status_text(bContext *C, wmOperator *op) prop = RNA_struct_find_property(op->ptr, "vmesh_method"); RNA_property_enum_name_gettexted( C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &vmesh_str); + prop = RNA_struct_find_property(op->ptr, "affect"); + RNA_property_enum_name_gettexted( + C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &affect_str); BLI_snprintf(status_text, sizeof(status_text), @@ -192,7 +195,7 @@ static void edbm_bevel_update_status_text(bContext *C, wmOperator *op) "%s: Segments (%d), " "%s: Profile (%.3f), " "%s: Clamp Overlap (%s), " - "%s: Vertex Only (%s), " + "%s: Affect (%s), " "%s: Outer Miter (%s), " "%s: Inner Miter (%s), " "%s: Harden Normals (%s), " @@ -212,8 +215,8 @@ static void edbm_bevel_update_status_text(bContext *C, wmOperator *op) RNA_float_get(op->ptr, "profile"), WM_MODALKEY(BEV_MODAL_CLAMP_OVERLAP_TOGGLE), WM_bool_as_string(RNA_boolean_get(op->ptr, "clamp_overlap")), - WM_MODALKEY(BEV_MODAL_VERTEX_ONLY_TOGGLE), - WM_bool_as_string(RNA_boolean_get(op->ptr, "vertex_only")), + WM_MODALKEY(BEV_MODAL_AFFECT_CHANGE), + affect_str, WM_MODALKEY(BEV_MODAL_OUTER_MITER_CHANGE), omiter_str, WM_MODALKEY(BEV_MODAL_INNER_MITER_CHANGE), @@ -333,7 +336,7 @@ static bool edbm_bevel_calc(wmOperator *op) const int profile_type = RNA_enum_get(op->ptr, "profile_type"); const int segments = RNA_int_get(op->ptr, "segments"); const float profile = RNA_float_get(op->ptr, "profile"); - const bool vertex_only = RNA_boolean_get(op->ptr, "vertex_only"); + const bool affect = RNA_enum_get(op->ptr, "affect"); const bool clamp_overlap = RNA_boolean_get(op->ptr, "clamp_overlap"); const int material_init = RNA_int_get(op->ptr, "material"); const bool loop_slide = RNA_boolean_get(op->ptr, "loop_slide"); @@ -367,7 +370,7 @@ static bool edbm_bevel_calc(wmOperator *op) EDBM_op_init(em, &bmop, op, - "bevel geom=%hev offset=%f segments=%i vertex_only=%b offset_type=%i " + "bevel geom=%hev offset=%f segments=%i affect=%i offset_type=%i " "profile_type=%i profile=%f clamp_overlap=%b material=%i loop_slide=%b " "mark_seam=%b mark_sharp=%b harden_normals=%b face_strength_mode=%i " "miter_outer=%i miter_inner=%i spread=%f smoothresh=%f custom_profile=%p " @@ -375,7 +378,7 @@ static bool edbm_bevel_calc(wmOperator *op) BM_ELEM_SELECT, offset, segments, - vertex_only, + affect, offset_type, profile_type, profile, @@ -654,11 +657,11 @@ wmKeyMap *bevel_modal_keymap(wmKeyConfig *keyconf) 0, "Toggle clamp overlap", "Toggle clamp overlap flag"}, - {BEV_MODAL_VERTEX_ONLY_TOGGLE, - "VERTEX_ONLY_TOGGLE", + {BEV_MODAL_AFFECT_CHANGE, + "AFFECT_CHANGE", 0, - "Toggle vertex only", - "Toggle vertex only flag"}, + "Change affect type", + "Change which geometry type the operation affects, edges or vertices"}, {BEV_MODAL_HARDEN_NORMALS_TOGGLE, "HARDEN_NORMALS_TOGGLE", 0, @@ -830,9 +833,13 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event) edbm_bevel_calc_initial_length(op, event, true); break; - case BEV_MODAL_VERTEX_ONLY_TOGGLE: { - bool vertex_only = RNA_boolean_get(op->ptr, "vertex_only"); - RNA_boolean_set(op->ptr, "vertex_only", !vertex_only); + case BEV_MODAL_AFFECT_CHANGE: { + int affect_type = RNA_enum_get(op->ptr, "affect"); + affect_type++; + if (affect_type > BEVEL_AFFECT_EDGES) { + affect_type = BEVEL_AFFECT_VERTICES; + } + RNA_enum_set(op->ptr, "affect", affect_type); edbm_bevel_calc(op); edbm_bevel_update_status_text(C, op); handled = true; @@ -945,10 +952,16 @@ static void edbm_bevel_ui(bContext *C, wmOperator *op) int profile_type = RNA_enum_get(&ptr, "profile_type"); int offset_type = RNA_enum_get(&ptr, "offset_type"); + bool affect_type = RNA_enum_get(&ptr, "affect"); uiLayoutSetPropSep(layout, true); uiLayoutSetPropDecorate(layout, false); + row = uiLayoutRow(layout, false); + uiItemR(row, &ptr, "affect", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + + uiItemS(layout); + uiItemR(layout, &ptr, "offset_type", 0, NULL, ICON_NONE); if (offset_type == BEVEL_AMT_PERCENT) { @@ -971,26 +984,31 @@ static void edbm_bevel_ui(bContext *C, wmOperator *op) col = uiLayoutColumn(layout, true); uiItemR(col, &ptr, "harden_normals", 0, NULL, ICON_NONE); - uiItemR(col, &ptr, "vertex_only", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "clamp_overlap", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "loop_slide", 0, NULL, ICON_NONE); col = uiLayoutColumnWithHeading(layout, true, IFACE_("Mark")); + uiLayoutSetActive(col, affect_type == BEVEL_AFFECT_EDGES); uiItemR(col, &ptr, "mark_seam", 0, IFACE_("Seams"), ICON_NONE); uiItemR(col, &ptr, "mark_sharp", 0, IFACE_("Sharp"), ICON_NONE); uiItemS(layout); - uiItemR(layout, &ptr, "miter_outer", 0, IFACE_("Miter Outer"), ICON_NONE); - uiItemR(layout, &ptr, "miter_inner", 0, IFACE_("Inner"), ICON_NONE); + col = uiLayoutColumn(layout, false); + uiLayoutSetActive(col, affect_type == BEVEL_AFFECT_EDGES); + uiItemR(col, &ptr, "miter_outer", 0, IFACE_("Miter Outer"), ICON_NONE); + uiItemR(col, &ptr, "miter_inner", 0, IFACE_("Inner"), ICON_NONE); if (RNA_enum_get(&ptr, "miter_inner") == BEVEL_MITER_ARC) { - uiItemR(layout, &ptr, "spread", 0, NULL, ICON_NONE); + uiItemR(col, &ptr, "spread", 0, NULL, ICON_NONE); } uiItemS(layout); + col = uiLayoutColumn(layout, false); + uiLayoutSetActive(col, affect_type == BEVEL_AFFECT_EDGES); + uiItemR(col, &ptr, "vmesh_method", 0, IFACE_("Intersection Type"), ICON_NONE); + uiItemR(layout, &ptr, "face_strength_mode", 0, IFACE_("Face Strength"), ICON_NONE); - uiItemR(layout, &ptr, "vmesh_method", 0, IFACE_("Intersection Type"), ICON_NONE); uiItemS(layout); @@ -1074,6 +1092,12 @@ void MESH_OT_bevel(wmOperatorType *ot) {0, NULL, 0, NULL, NULL}, }; + static const EnumPropertyItem prop_affect_items[] = { + {BEVEL_AFFECT_VERTICES, "VERTICES", 0, "Vertices", "Affect only vertices"}, + {BEVEL_AFFECT_EDGES, "EDGES", 0, "Edges", "Affect only edges"}, + {0, NULL, 0, NULL, NULL}, + }; + /* identifiers */ ot->name = "Bevel"; ot->description = "Cut into selected items at an angle to create bevel or chamfer"; @@ -1134,7 +1158,12 @@ void MESH_OT_bevel(wmOperatorType *ot) PROFILE_HARD_MIN, 1.0f); - RNA_def_boolean(ot->srna, "vertex_only", false, "Vertex Only", "Bevel only vertices"); + prop = RNA_def_enum(ot->srna, + "affect", + prop_affect_items, + BEVEL_AFFECT_EDGES, + "Affect", + "Affect Edges or Vertices"); RNA_def_boolean(ot->srna, "clamp_overlap", diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 50b4739e09f..661799b4256 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -409,7 +409,9 @@ typedef struct BevelModifierData { short miter_outer; /** The method to use for creating >2-way intersections */ short vmesh_method; - char _pad0[2]; + /** Whether to affect vertices or edges. */ + char affect_type; + char _pad; /** Controls profile shape (0->1, .5 is round). */ float profile; /** if the MOD_BEVEL_ANGLE is set, @@ -428,7 +430,9 @@ typedef struct BevelModifierData { /* BevelModifierData->flags and BevelModifierData->lim_flags */ enum { - MOD_BEVEL_VERT = (1 << 1), +#ifdef DNA_DEPRECATED_ALLOW + MOD_BEVEL_VERT_DEPRECATED = (1 << 1), +#endif MOD_BEVEL_INVERT_VGROUP = (1 << 2), MOD_BEVEL_ANGLE = (1 << 3), MOD_BEVEL_WEIGHT = (1 << 4), @@ -489,6 +493,12 @@ enum { MOD_BEVEL_VMESH_CUTOFF = 1, }; +/* BevelModifier->affect_type */ +enum { + MOD_BEVEL_AFFECT_VERTICES = 0, + MOD_BEVEL_AFFECT_EDGES = 1, +}; + typedef struct FluidModifierData { ModifierData modifier; diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index eb1a09f9c76..4d0d8cf1b6c 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -4047,8 +4047,8 @@ static void rna_def_modifier_bevel(BlenderRNA *brna) }; static const EnumPropertyItem prop_affect_items[] = { - {0, "EDGES", 0, "Edges", "Affect only edges"}, - {MOD_BEVEL_VERT, "VERTICES", 0, "Vertices", "Affect only vertices"}, + {MOD_BEVEL_AFFECT_VERTICES, "VERTICES", 0, "Vertices", "Affect only vertices"}, + {MOD_BEVEL_AFFECT_EDGES, "EDGES", 0, "Edges", "Affect only edges"}, {0, NULL, 0, NULL, NULL}, }; @@ -4081,7 +4081,7 @@ static void rna_def_modifier_bevel(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_BevelModifier_update_segments"); prop = RNA_def_property(srna, "affect", PROP_ENUM, PROP_NONE); /* as an enum */ - RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags"); + RNA_def_property_enum_sdna(prop, NULL, "affect_type"); RNA_def_property_enum_items(prop, prop_affect_items); RNA_def_property_ui_text(prop, "Affect", "Affect edges or vertices"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c index ae392458539..a9708de83bf 100644 --- a/source/blender/modifiers/intern/MOD_bevel.c +++ b/source/blender/modifiers/intern/MOD_bevel.c @@ -117,7 +117,6 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * MDeformVert *dvert = NULL; BevelModifierData *bmd = (BevelModifierData *)md; const float threshold = cosf(bmd->bevel_angle + 0.000000175f); - const bool vertex_only = (bmd->flags & MOD_BEVEL_VERT) != 0; const bool do_clamp = !(bmd->flags & MOD_BEVEL_OVERLAP_OK); const int offset_type = bmd->val_flags; const int profile_type = bmd->profile_type; @@ -131,7 +130,6 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * const int miter_outer = bmd->miter_outer; const int miter_inner = bmd->miter_inner; const float spread = bmd->spread; - const int vmesh_method = bmd->vmesh_method; const bool invert_vgroup = (bmd->flags & MOD_BEVEL_INVERT_VGROUP) != 0; bm = BKE_mesh_to_bmesh_ex(mesh, @@ -152,7 +150,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * MOD_get_vgroup(ctx->object, mesh, bmd->defgrp_name, &dvert, &vgroup); } - if (vertex_only) { + if (bmd->affect_type == MOD_BEVEL_AFFECT_VERTICES) { BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { if (bmd->lim_flags & MOD_BEVEL_WEIGHT) { weight = BM_elem_float_data_get(&bm->vdata, v, CD_BWEIGHT); @@ -230,7 +228,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * profile_type, bmd->res, bmd->profile, - vertex_only, + bmd->affect_type, bmd->lim_flags & MOD_BEVEL_WEIGHT, do_clamp, dvert, @@ -246,7 +244,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * spread, mesh->smoothresh, bmd->custom_profile, - vmesh_method); + bmd->vmesh_method); result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL, mesh); @@ -286,7 +284,7 @@ static void panel_draw(const bContext *C, Panel *panel) PointerRNA ob_ptr; modifier_panel_get_property_pointers(C, panel, &ob_ptr, &ptr); - bool edge_bevel = RNA_enum_get(&ptr, "affect") != MOD_BEVEL_VERT; + bool edge_bevel = RNA_enum_get(&ptr, "affect") != MOD_BEVEL_AFFECT_VERTICES; uiItemR(layout, &ptr, "affect", UI_ITEM_R_EXPAND, NULL, ICON_NONE); @@ -331,7 +329,7 @@ static void profile_panel_draw(const bContext *C, Panel *panel) int profile_type = RNA_enum_get(&ptr, "profile_type"); int miter_inner = RNA_enum_get(&ptr, "miter_inner"); int miter_outer = RNA_enum_get(&ptr, "miter_outer"); - bool edge_bevel = RNA_enum_get(&ptr, "affect") != MOD_BEVEL_VERT; + bool edge_bevel = RNA_enum_get(&ptr, "affect") != MOD_BEVEL_AFFECT_VERTICES; uiItemR(layout, &ptr, "profile_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); @@ -368,7 +366,7 @@ static void geometry_panel_draw(const bContext *C, Panel *panel) PointerRNA ptr; modifier_panel_get_property_pointers(C, panel, NULL, &ptr); - bool edge_bevel = RNA_enum_get(&ptr, "affect") != MOD_BEVEL_VERT; + bool edge_bevel = RNA_enum_get(&ptr, "affect") != MOD_BEVEL_AFFECT_VERTICES; uiLayoutSetPropSep(layout, true); @@ -402,7 +400,7 @@ static void shading_panel_draw(const bContext *C, Panel *panel) PointerRNA ptr; modifier_panel_get_property_pointers(C, panel, NULL, &ptr); - bool edge_bevel = RNA_enum_get(&ptr, "affect") != MOD_BEVEL_VERT; + bool edge_bevel = RNA_enum_get(&ptr, "affect") != MOD_BEVEL_AFFECT_VERTICES; uiLayoutSetPropSep(layout, true); |