[Bf-blender-cvs] [a62b806] master: Fix T42145: EditMesh Bevel tools had no clamping option.

Bastien Montagne noreply at git.blender.org
Wed Oct 8 16:45:40 CEST 2014


Commit: a62b806d70a8d4f9dacaa55aa32e9b00fee654e2
Author: Bastien Montagne
Date:   Wed Oct 8 16:41:00 2014 +0200
Branches: master
https://developer.blender.org/rBa62b806d70a8d4f9dacaa55aa32e9b00fee654e2

Fix T42145: EditMesh Bevel tools had no clamping option.

Missing feature already present in Bevel modifier, useful and rather simple to add.

===================================================================

M	source/blender/bmesh/intern/bmesh_opdefines.c
M	source/blender/bmesh/operators/bmo_bevel.c
M	source/blender/editors/mesh/editmesh_bevel.c

===================================================================

diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c
index e2be90e..aba805c 100644
--- a/source/blender/bmesh/intern/bmesh_opdefines.c
+++ b/source/blender/bmesh/intern/bmesh_opdefines.c
@@ -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'}},
 	},
diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c
index 213a083..864c4da 100644
--- a/source/blender/bmesh/operators/bmo_bevel.c
+++ b/source/blender/bmesh/operators/bmo_bevel.c
@@ -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);
 	}
diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c
index 48d5113..0e48cbc 100644
--- a/source/blender/editors/mesh/editmesh_bevel.c
+++ b/source/blender/editors/mesh/editmesh_bevel.c
@@ -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);
 }




More information about the Bf-blender-cvs mailing list