[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [52160] trunk/blender/source/blender/ editors/mesh/editmesh_loopcut.c: todo from 2.4x, add back smooth option to edge loop cut.

Campbell Barton ideasman42 at gmail.com
Tue Nov 13 03:28:10 CET 2012


Revision: 52160
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=52160
Author:   campbellbarton
Date:     2012-11-13 02:28:07 +0000 (Tue, 13 Nov 2012)
Log Message:
-----------
todo from 2.4x, add back smooth option to edge loop cut. 

Modified Paths:
--------------
    trunk/blender/source/blender/editors/mesh/editmesh_loopcut.c

Modified: trunk/blender/source/blender/editors/mesh/editmesh_loopcut.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_loopcut.c	2012-11-13 01:53:07 UTC (rev 52159)
+++ trunk/blender/source/blender/editors/mesh/editmesh_loopcut.c	2012-11-13 02:28:07 UTC (rev 52160)
@@ -307,7 +307,8 @@
 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 @@
 			 * 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_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 @@
 		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 @@
 		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 @@
 			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 @@
 	
 	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 @@
 	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);
 }




More information about the Bf-blender-cvs mailing list