diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-12-14 16:22:35 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-12-14 16:25:29 +0400 |
commit | 60a6b2422dc8459f0a46e071d549abac9af28f00 (patch) | |
tree | 871e6d4f4c12473c89bf934d12dca370a34752f6 /source/blender/editors | |
parent | ab9fabdfc61232a33648dbd3a11790f2dc46c75c (diff) |
Modeling: add optional angle limit for beauty fill
Makes this tool more useful on an entire mesh by only applying
beautify to planar surfaces.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 32 |
1 files changed, 30 insertions, 2 deletions
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)); } |