[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53899] trunk/blender/source/blender/ editors/transform: Holding Alt now removes [-1, 1] clamping in vertex slide , Thanks to Psy-Fi for the original patch.

Campbell Barton ideasman42 at gmail.com
Sat Jan 19 00:20:17 CET 2013


Revision: 53899
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53899
Author:   campbellbarton
Date:     2013-01-18 23:20:17 +0000 (Fri, 18 Jan 2013)
Log Message:
-----------
Holding Alt now removes [-1, 1] clamping in vertex slide, Thanks to Psy-Fi for the original patch.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/transform/transform.c
    trunk/blender/source/blender/editors/transform/transform.h

Modified: trunk/blender/source/blender/editors/transform/transform.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform.c	2013-01-18 23:07:27 UTC (rev 53898)
+++ trunk/blender/source/blender/editors/transform/transform.c	2013-01-18 23:20:17 UTC (rev 53899)
@@ -5323,7 +5323,7 @@
 	if (rv3d)
 		calcNonProportionalEdgeSlide(t, sld, mval);
 
-	sld->origfaces_init = TRUE;
+	sld->origfaces_init = true;
 	sld->em = em;
 	
 	/*zero out start*/
@@ -5523,7 +5523,7 @@
 
 		BLI_smallhash_release(&sld->origfaces);
 
-		sld->origfaces_init = FALSE;
+		sld->origfaces_init = false;
 
 		/* arrays are dirty from removing faces: EDBM_index_arrays_free */
 		EDBM_update_generic(sld->em, FALSE, TRUE);
@@ -5789,8 +5789,8 @@
 	char str[128];
 	float final;
 	EdgeSlideData *sld =  t->customData;
-	int flipped = sld->flipped_vtx;
-	int is_proportional = sld->is_proportional;
+	bool flipped = sld->flipped_vtx;
+	bool is_proportional = sld->is_proportional;
 
 	final = t->values[0];
 
@@ -5843,8 +5843,7 @@
 	float *co_curr = sv->co_link_orig_2d[sv->co_link_curr];
 	float  co_curr_flip[2];
 
-	sub_v2_v2v2(co_curr_flip, co_curr, co_orig);
-	sub_v2_v2v2(co_curr_flip, co_orig, co_curr_flip);
+	flip_v2_v2v2(co_curr_flip, co_orig, co_curr);
 
 	{
 		const int start[2] = {co_orig[0], co_orig[1]};
@@ -5943,9 +5942,9 @@
 		rv3d = t->ar ? t->ar->regiondata : NULL;
 	}
 
-	sld->is_proportional = TRUE;
+	sld->is_proportional = true;
 	sld->curr_sv_index = 0;
-	sld->flipped_vtx = FALSE;
+	sld->flipped_vtx = false;
 
 	if (!rv3d) {
 		/* ok, let's try to survive this */
@@ -6170,6 +6169,7 @@
 			const float line_size = UI_GetThemeValuef(TH_OUTLINE_WIDTH) + 0.5f;
 			const int alpha_shade = -30;
 			int i;
+			bool is_constrained = !(t->flag & T_ALT_TRANSFORM);
 
 			if (v3d && v3d->zbuf)
 				glDisable(GL_DEPTH_TEST);
@@ -6185,11 +6185,27 @@
 			glLineWidth(line_size);
 			UI_ThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade);
 			glBegin(GL_LINES);
-			sv = sld->sv;
-			for (i = 0; i < sld->totsv; i++, sv++) {
-				glVertex3fv(sv->co_orig_3d);
-				glVertex3fv(sv->co_link_orig_3d[sv->co_link_curr]);
+			if (is_constrained) {
+				sv = sld->sv;
+				for (i = 0; i < sld->totsv; i++, sv++) {
+					glVertex3fv(sv->co_orig_3d);
+					glVertex3fv(sv->co_link_orig_3d[sv->co_link_curr]);
+				}
 			}
+			else {
+				sv = sld->sv;
+				for (i = 0; i < sld->totsv; i++, sv++) {
+					float a[3], b[3];
+					sub_v3_v3v3(a, sv->co_link_orig_3d[sv->co_link_curr], sv->co_orig_3d);
+					mul_v3_fl(a, 100.0f);
+					negate_v3_v3(b, a);
+					add_v3_v3(a, sv->co_orig_3d);
+					add_v3_v3(b, sv->co_orig_3d);
+
+					glVertex3fv(a);
+					glVertex3fv(b);
+				}
+			}
 			bglEnd();
 
 			glPointSize(ctrl_size);
@@ -6259,15 +6275,18 @@
 	char str[128];
 	float final;
 	VertSlideData *sld =  t->customData;
-	int flipped = sld->flipped_vtx;
-	int is_proportional = sld->is_proportional;
+	const bool flipped = sld->flipped_vtx;
+	const bool is_proportional = sld->is_proportional;
+	const bool is_constrained = !((t->flag & T_ALT_TRANSFORM) || hasNumInput(&t->num));
 
 	final = t->values[0];
 
 	snapGrid(t, &final);
 
 	/* only do this so out of range values are not displayed */
-	CLAMP(final, -1.0f, 1.0f);
+	if(is_constrained) {
+		CLAMP(final, 0.0f, 1.0f);
+	}
 
 	if (hasNumInput(&t->num)) {
 		char c[NUM_STR_REP_LEN];
@@ -6284,7 +6303,9 @@
 		             final, !is_proportional ? "ON" : "OFF", flipped ? "ON" : "OFF", (t->flag & T_ALT_TRANSFORM) ? "ON" : "OFF");
 	}
 
-	CLAMP(final, -1.0f, 1.0f);
+	if(is_constrained) {
+		CLAMP(final, 0.0f, 1.0f);
+	}
 
 	t->values[0] = final;
 

Modified: trunk/blender/source/blender/editors/transform/transform.h
===================================================================
--- trunk/blender/source/blender/editors/transform/transform.h	2013-01-18 23:07:27 UTC (rev 53898)
+++ trunk/blender/source/blender/editors/transform/transform.h	2013-01-18 23:20:17 UTC (rev 53899)
@@ -208,12 +208,12 @@
 	struct BMEditMesh *em;
 
 	/* flag that is set when origfaces is initialized */
-	int origfaces_init;
+	bool origfaces_init;
 
 	float perc;
 
-	int is_proportional;
-	int flipped_vtx;
+	bool is_proportional;
+	bool flipped_vtx;
 
 	int curr_sv_index;
 } EdgeSlideData;
@@ -237,8 +237,8 @@
 
 	float perc;
 
-	int is_proportional;
-	int flipped_vtx;
+	bool is_proportional;
+	bool flipped_vtx;
 
 	int curr_sv_index;
 } VertSlideData;




More information about the Bf-blender-cvs mailing list