From 6335401a4959d48680b9163d6d75e8c1ebc23832 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 13 Nov 2012 02:28:07 +0000 Subject: todo from 2.4x, add back smooth option to edge loop cut. --- source/blender/editors/mesh/editmesh_loopcut.c | 48 +++++++++++++++++++------- 1 file changed, 35 insertions(+), 13 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index bf4ee0eb61f..035f930e00a 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -307,7 +307,8 @@ static void ringsel_find_edge(RingSelOpData *lcd, int cuts) static void ringsel_finish(bContext *C, wmOperator *op) { RingSelOpData *lcd = op->customdata; - int cuts = RNA_int_get(op->ptr, "number_cuts"); + const int cuts = RNA_int_get(op->ptr, "number_cuts"); + const float smoothness = RNA_float_get(op->ptr, "smoothness"); if (lcd->eed) { BMEditMesh *em = lcd->em; @@ -319,7 +320,7 @@ static void ringsel_finish(bContext *C, wmOperator *op) * Note though that it will break edgeslide in this specific case. * See [#31939]. */ BM_mesh_esubdivide(em->bm, BM_ELEM_SELECT, - 0.0f, 0.0f, 0.0f, + smoothness, 0.0f, 0.0f, cuts, SUBDIV_SELECT_LOOPCUT, SUBD_PATH, 0, TRUE, 0); @@ -413,6 +414,7 @@ static int ringcut_cancel(bContext *C, wmOperator *op) static int ringcut_invoke(bContext *C, wmOperator *op, wmEvent *evt) { + ScrArea *sa = CTX_wm_area(C); Object *obedit = CTX_data_edit_object(C); RingSelOpData *lcd; BMEdge *edge; @@ -438,13 +440,17 @@ static int ringcut_invoke(bContext *C, wmOperator *op, wmEvent *evt) lcd->eed = edge; ringsel_find_edge(lcd, 1); } - ED_area_headerprint(CTX_wm_area(C), "Select a ring to be cut, use mouse-wheel or page-up/down for number of cuts"); + ED_area_headerprint(sa, + "Select a ring to be cut, " + "use mouse-wheel or page-up/down for number of cuts, " + "Hold Alt for smooth"); return OPERATOR_RUNNING_MODAL; } static int loopcut_modal(bContext *C, wmOperator *op, wmEvent *event) { + float smoothness = RNA_float_get(op->ptr, "smoothness"); int cuts = RNA_int_get(op->ptr, "number_cuts"); RingSelOpData *lcd = op->customdata; int show_cuts = 0; @@ -491,11 +497,17 @@ static int loopcut_modal(bContext *C, wmOperator *op, wmEvent *event) case WHEELUPMOUSE: /* change number of cuts */ if (event->val == KM_RELEASE) break; - - cuts++; - RNA_int_set(op->ptr, "number_cuts", cuts); - ringsel_find_edge(lcd, cuts); - show_cuts = TRUE; + if (event->alt == 0) { + cuts++; + RNA_int_set(op->ptr, "number_cuts", cuts); + ringsel_find_edge(lcd, cuts); + show_cuts = TRUE; + } + else { + smoothness = min_ff(smoothness + 0.05f, 1.0f); + RNA_float_set(op->ptr, "smoothness", smoothness); + show_cuts = TRUE; + } ED_region_tag_redraw(lcd->ar); break; @@ -505,10 +517,17 @@ static int loopcut_modal(bContext *C, wmOperator *op, wmEvent *event) if (event->val == KM_RELEASE) break; - cuts = max_ii(cuts - 1, 0); - RNA_int_set(op->ptr, "number_cuts", cuts); - ringsel_find_edge(lcd, cuts); - show_cuts = TRUE; + if (event->alt == 0) { + cuts = max_ii(cuts - 1, 0); + RNA_int_set(op->ptr, "number_cuts", cuts); + ringsel_find_edge(lcd, cuts); + show_cuts = TRUE; + } + else { + smoothness = max_ff(smoothness - 0.05f, 0.0f); + RNA_float_set(op->ptr, "smoothness", smoothness); + show_cuts = TRUE; + } ED_region_tag_redraw(lcd->ar); break; @@ -552,7 +571,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, wmEvent *event) if (show_cuts) { char buf[64]; - BLI_snprintf(buf, sizeof(buf), "Number of Cuts: %d", cuts); + BLI_snprintf(buf, sizeof(buf), "Number of Cuts: %d, Smooth: %.2f (Alt)", cuts, smoothness); ED_area_headerprint(CTX_wm_area(C), buf); } @@ -604,4 +623,7 @@ void MESH_OT_loopcut(wmOperatorType *ot) prop = RNA_def_int(ot->srna, "number_cuts", 1, 1, INT_MAX, "Number of Cuts", "", 1, 10); /* avoid re-using last var because it can cause _very_ high poly meshes and annoy users (or worse crash) */ RNA_def_property_flag(prop, PROP_SKIP_SAVE); + + prop = RNA_def_float(ot->srna, "smoothness", 0.0f, 0.0f, FLT_MAX, "Smoothness", "Smoothness factor", 0.0f, 1.0f); + RNA_def_property_flag(prop, PROP_SKIP_SAVE); } -- cgit v1.2.3