From 60a6b2422dc8459f0a46e071d549abac9af28f00 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 14 Dec 2013 23:22:35 +1100 Subject: Modeling: add optional angle limit for beauty fill Makes this tool more useful on an entire mesh by only applying beautify to planar surfaces. --- source/blender/editors/mesh/editmesh_tools.c | 32 ++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'source/blender/editors/mesh') diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index fd391a31074..74812e58e06 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -3120,10 +3120,31 @@ static int edbm_beautify_fill_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BKE_editmesh_from_object(obedit); + const float angle_max = M_PI; + const float angle_limit = RNA_float_get(op->ptr, "angle_limit"); + char hflag; + + if (angle_limit >= angle_max) { + hflag = BM_ELEM_SELECT; + } + else { + BMIter iter; + BMEdge *e; + + BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) { + BM_elem_flag_set(e, BM_ELEM_TAG, + (BM_elem_flag_test(e, BM_ELEM_SELECT) && + BM_edge_calc_face_angle_ex(e, angle_max) < angle_limit)); + + } + + hflag = BM_ELEM_TAG; + } + if (!EDBM_op_call_and_selectf( em, op, "geom.out", true, - "beautify_fill faces=%hf edges=ae", - BM_ELEM_SELECT)) + "beautify_fill faces=%hf edges=%he", + BM_ELEM_SELECT, hflag)) { return OPERATOR_CANCELLED; } @@ -3135,6 +3156,8 @@ static int edbm_beautify_fill_exec(bContext *C, wmOperator *op) void MESH_OT_beautify_fill(wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ ot->name = "Beautify Faces"; ot->idname = "MESH_OT_beautify_fill"; @@ -3146,6 +3169,11 @@ void MESH_OT_beautify_fill(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* props */ + prop = RNA_def_float_rotation(ot->srna, "angle_limit", 0, NULL, 0.0f, DEG2RADF(180.0f), + "Max Angle", "Angle limit", 0.0f, DEG2RADF(180.0f)); + RNA_def_property_float_default(prop, DEG2RADF(180.0f)); } -- cgit v1.2.3