Fix T42145: EditMesh Bevel tools had no clamping option.
Missing feature already present in Bevel modifier, useful and rather simple to add.
This commit is contained in:
parent
67943af47a
commit
a62b806d70
Notes:
blender-bot
2024-04-11 14:26:06 +02:00
Referenced by issue #42145, Ctrl+B (Bevel edges) & Ctrl+Shift+B (Bevel vertices) has no clamp option.
|
@ -1676,7 +1676,8 @@ static BMOpDefine bmo_bevel_def = {
|
|||
{"offset_type", BMO_OP_SLOT_INT}, /* how to measure offset (enum) */
|
||||
{"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 */
|
||||
{"vertex_only", BMO_OP_SLOT_BOOL}, /* only bevel vertices, not 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 */
|
||||
{{'\0'}},
|
||||
},
|
||||
|
|
|
@ -35,12 +35,13 @@
|
|||
|
||||
void bmo_bevel_exec(BMesh *bm, BMOperator *op)
|
||||
{
|
||||
const float offset = BMO_slot_float_get(op->slots_in, "offset");
|
||||
const int offset_type = BMO_slot_int_get(op->slots_in, "offset_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 float profile = BMO_slot_float_get(op->slots_in, "profile");
|
||||
const int material = BMO_slot_int_get(op->slots_in, "material");
|
||||
const float offset = BMO_slot_float_get(op->slots_in, "offset");
|
||||
const int offset_type = BMO_slot_int_get(op->slots_in, "offset_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 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");
|
||||
|
||||
if (offset > 0) {
|
||||
BMOIter siter;
|
||||
|
@ -61,7 +62,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
|
|||
}
|
||||
}
|
||||
|
||||
BM_mesh_bevel(bm, offset, offset_type, seg, profile, vonly, false, false, NULL, -1, material);
|
||||
BM_mesh_bevel(bm, offset, offset_type, seg, profile, vonly, false, clamp_overlap, NULL, -1, material);
|
||||
|
||||
BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "faces.out", BM_FACE, BM_ELEM_TAG);
|
||||
}
|
||||
|
|
|
@ -75,7 +75,8 @@ typedef struct {
|
|||
|
||||
static void edbm_bevel_update_header(bContext *C, wmOperator *op)
|
||||
{
|
||||
const char *str = IFACE_("Confirm: (Enter/LMB), Cancel: (Esc/RMB), Mode: %s (M), Offset: %s, Segments: %d");
|
||||
const char *str = IFACE_("Confirm: (Enter/LMB), Cancel: (Esc/RMB), Mode: %s (M), Clamp Overlap: %s (C), "
|
||||
"Offset: %s, Segments: %d");
|
||||
|
||||
char msg[HEADER_LENGTH];
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
|
@ -96,7 +97,9 @@ static void edbm_bevel_update_header(bContext *C, wmOperator *op)
|
|||
|
||||
RNA_property_enum_name_gettexted(C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &type_str);
|
||||
|
||||
BLI_snprintf(msg, HEADER_LENGTH, str, type_str, offset_str, RNA_int_get(op->ptr, "segments"));
|
||||
BLI_snprintf(msg, HEADER_LENGTH, str, type_str,
|
||||
WM_bool_as_string(RNA_boolean_get(op->ptr, "clamp_overlap")),
|
||||
offset_str, RNA_int_get(op->ptr, "segments"));
|
||||
|
||||
ED_area_headerprint(sa, msg);
|
||||
}
|
||||
|
@ -150,6 +153,7 @@ static bool edbm_bevel_calc(wmOperator *op)
|
|||
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 clamp_overlap = RNA_boolean_get(op->ptr, "clamp_overlap");
|
||||
int material = RNA_int_get(op->ptr, "material");
|
||||
|
||||
/* revert to original mesh */
|
||||
|
@ -161,8 +165,9 @@ static bool edbm_bevel_calc(wmOperator *op)
|
|||
material = CLAMPIS(material, -1, em->ob->totcol - 1);
|
||||
|
||||
EDBM_op_init(em, &bmop, op,
|
||||
"bevel geom=%hev offset=%f segments=%i vertex_only=%b offset_type=%i profile=%f material=%i",
|
||||
BM_ELEM_SELECT, offset, segments, vertex_only, offset_type, profile, material);
|
||||
"bevel geom=%hev offset=%f segments=%i vertex_only=%b offset_type=%i profile=%f clamp_overlap=%b "
|
||||
"material=%i",
|
||||
BM_ELEM_SELECT, offset, segments, vertex_only, offset_type, profile, clamp_overlap, material);
|
||||
|
||||
BMO_op_exec(em->bm, &bmop);
|
||||
|
||||
|
@ -408,6 +413,18 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
edbm_bevel_update_header(C, op);
|
||||
handled = true;
|
||||
break;
|
||||
case CKEY:
|
||||
if (event->val == KM_RELEASE)
|
||||
break;
|
||||
|
||||
{
|
||||
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "clamp_overlap");
|
||||
RNA_property_enum_set(op->ptr, prop, !RNA_property_boolean_get(op->ptr, prop));
|
||||
}
|
||||
edbm_bevel_calc(op);
|
||||
edbm_bevel_update_header(C, op);
|
||||
handled = true;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Modal numinput inactive, try to handle numeric inputs last... */
|
||||
|
@ -467,6 +484,8 @@ void MESH_OT_bevel(wmOperatorType *ot)
|
|||
RNA_def_property_float_array_funcs_runtime(prop, NULL, NULL, mesh_ot_bevel_offset_range_func);
|
||||
RNA_def_int(ot->srna, "segments", 1, 1, 50, "Segments", "Segments for curved edge", 1, 8);
|
||||
RNA_def_float(ot->srna, "profile", 0.5f, 0.15f, 1.0f, "Profile", "Controls profile shape (0.5 = round)", 0.15f, 1.0f);
|
||||
RNA_def_boolean(ot->srna, "vertex_only", false, "Vertex only", "Bevel only vertices");
|
||||
RNA_def_boolean(ot->srna, "vertex_only", false, "Vertex Only", "Bevel only vertices");
|
||||
RNA_def_boolean(ot->srna, "clamp_overlap", false, "Clamp Overlap",
|
||||
"Do not allow beveled edges/vertices to overlap each other");
|
||||
RNA_def_int(ot->srna, "material", -1, -1, INT_MAX, "Material", "Material for bevel faces (-1 means use adjacent faces)", -1, 100);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue