[Bf-blender-cvs] [aef307c] master: Fix T38019: Edge/Vertex Slide recognises Even and Flipped as if they were numerical values

Bastien Montagne noreply at git.blender.org
Thu Jan 2 12:05:30 CET 2014


Commit: aef307cf31bee6f894069a3a995c8de1db73c9c3
Author: Bastien Montagne
Date:   Thu Jan 2 09:33:59 2014 +0100
https://developer.blender.org/rBaef307cf31bee6f894069a3a995c8de1db73c9c3

Fix T38019: Edge/Vertex Slide recognises Even and Flipped as if they were numerical values

Further tweaked/simplified events handling in transform code, hope this time it works OK...

===================================================================

M	source/blender/editors/transform/transform.c

===================================================================

diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index bb97a22..8dac8f0 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -943,7 +943,14 @@ int transformEvent(TransInfo *t, const wmEvent *event)
 
 	t->redraw |= handleMouseInput(t, &t->mouse, event);
 
-	if (event->type == MOUSEMOVE) {
+	/* Handle modal numinput events first, if already activated. */
+	if (((event->val == KM_PRESS) || (event->type == EVT_MODAL_MAP)) &&
+	    hasNumInput(&t->num) && handleNumInput(t->context, &(t->num), event))
+	{
+		t->redraw |= TREDRAW_HARD;
+		handled = true;
+	}
+	else if (event->type == MOUSEMOVE) {
 		if (t->modifiers & MOD_CONSTRAINT_SELECT)
 			t->con.mode |= CON_SELECT;
 
@@ -964,115 +971,61 @@ int transformEvent(TransInfo *t, const wmEvent *event)
 	}
 	/* handle modal keymap first */
 	else if (event->type == EVT_MODAL_MAP) {
-		/* Handle modal numinput events first, if already activated. */
-		if (hasNumInput(&t->num) && handleNumInput(t->context, &(t->num), event)) {
-			t->redraw |= TREDRAW_HARD;
-			handled = true;
-		}
-		else {
-			switch (event->val) {
-				case TFM_MODAL_CANCEL:
-					t->state = TRANS_CANCEL;
+		switch (event->val) {
+			case TFM_MODAL_CANCEL:
+				t->state = TRANS_CANCEL;
+				handled = true;
+				break;
+			case TFM_MODAL_CONFIRM:
+				t->state = TRANS_CONFIRM;
+				handled = true;
+				break;
+			case TFM_MODAL_TRANSLATE:
+				/* only switch when... */
+				if (ELEM5(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_EDGE_SLIDE, TFM_VERT_SLIDE)) {
+					resetTransModal(t);
+					resetTransRestrictions(t);
+					restoreTransObjects(t);
+					initTranslation(t);
+					initSnapping(t, NULL); // need to reinit after mode change
+					t->redraw |= TREDRAW_HARD;
+					WM_event_add_mousemove(t->context);
 					handled = true;
-					break;
-				case TFM_MODAL_CONFIRM:
-					t->state = TRANS_CONFIRM;
+				}
+				else if (t->mode == TFM_SEQ_SLIDE) {
+					t->flag ^= T_ALT_TRANSFORM;
+					t->redraw |= TREDRAW_HARD;
 					handled = true;
-					break;
-				case TFM_MODAL_TRANSLATE:
-					/* only switch when... */
-					if (ELEM5(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_EDGE_SLIDE, TFM_VERT_SLIDE)) {
-						resetTransModal(t);
-						resetTransRestrictions(t);
-						restoreTransObjects(t);
-						initTranslation(t);
-						initSnapping(t, NULL); // need to reinit after mode change
-						t->redraw |= TREDRAW_HARD;
-						WM_event_add_mousemove(t->context);
-						handled = true;
-					}
-					else if (t->mode == TFM_SEQ_SLIDE) {
-						t->flag ^= T_ALT_TRANSFORM;
-						t->redraw |= TREDRAW_HARD;
-						handled = true;
-					}
-					else {
-						if (t->obedit && t->obedit->type == OB_MESH) {
-							if ((t->mode == TFM_TRANSLATION) && (t->spacetype == SPACE_VIEW3D)) {
-								resetTransModal(t);
-								resetTransRestrictions(t);
-								restoreTransObjects(t);
-
-								/* first try edge slide */
-								initEdgeSlide(t);
-								/* if that fails, do vertex slide */
-								if (t->state == TRANS_CANCEL) {
-									t->state = TRANS_STARTING;
-									initVertSlide(t);
-								}
-								/* vert slide can fail on unconnected vertices (rare but possible) */
-								if (t->state == TRANS_CANCEL) {
-									t->state = TRANS_STARTING;
-									resetTransRestrictions(t);
-									restoreTransObjects(t);
-									initTranslation(t);
-								}
-								initSnapping(t, NULL); // need to reinit after mode change
-								t->redraw |= TREDRAW_HARD;
-								handled = true;
-								WM_event_add_mousemove(t->context);
-							}
-						}
-						else if (t->options & (CTX_MOVIECLIP | CTX_MASK)) {
-							if (t->mode == TFM_TRANSLATION) {
-								restoreTransObjects(t);
-
-								t->flag ^= T_ALT_TRANSFORM;
-								t->redraw |= TREDRAW_HARD;
-								handled = true;
-							}
-						}
-					}
-					break;
-				case TFM_MODAL_ROTATE:
-					/* only switch when... */
-					if (!(t->options & CTX_TEXTURE) && !(t->options & (CTX_MOVIECLIP | CTX_MASK))) {
-						if (ELEM6(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_TRANSLATION, TFM_EDGE_SLIDE, TFM_VERT_SLIDE)) {
+				}
+				else {
+					if (t->obedit && t->obedit->type == OB_MESH) {
+						if ((t->mode == TFM_TRANSLATION) && (t->spacetype == SPACE_VIEW3D)) {
 							resetTransModal(t);
 							resetTransRestrictions(t);
-							
-							if (t->mode == TFM_ROTATION) {
-								restoreTransObjects(t);
-								initTrackball(t);
+							restoreTransObjects(t);
+
+							/* first try edge slide */
+							initEdgeSlide(t);
+							/* if that fails, do vertex slide */
+							if (t->state == TRANS_CANCEL) {
+								t->state = TRANS_STARTING;
+								initVertSlide(t);
 							}
-							else {
+							/* vert slide can fail on unconnected vertices (rare but possible) */
+							if (t->state == TRANS_CANCEL) {
+								t->state = TRANS_STARTING;
+								resetTransRestrictions(t);
 								restoreTransObjects(t);
-								initRotation(t);
+								initTranslation(t);
 							}
 							initSnapping(t, NULL); // need to reinit after mode change
 							t->redraw |= TREDRAW_HARD;
 							handled = true;
+							WM_event_add_mousemove(t->context);
 						}
 					}
-					break;
-				case TFM_MODAL_RESIZE:
-					/* only switch when... */
-					if (ELEM5(t->mode, TFM_ROTATION, TFM_TRANSLATION, TFM_TRACKBALL, TFM_EDGE_SLIDE, TFM_VERT_SLIDE)) {
-						resetTransModal(t);
-						resetTransRestrictions(t);
-						restoreTransObjects(t);
-						initResize(t);
-						initSnapping(t, NULL); // need to reinit after mode change
-						t->redraw |= TREDRAW_HARD;
-						handled = true;
-					}
-					else if (t->mode == TFM_SHRINKFATTEN) {
-						t->flag ^= T_ALT_TRANSFORM;
-						t->redraw |= TREDRAW_HARD;
-						handled = true;
-					}
-					else if (t->mode == TFM_RESIZE) {
-						if (t->options & CTX_MOVIECLIP) {
+					else if (t->options & (CTX_MOVIECLIP | CTX_MASK)) {
+						if (t->mode == TFM_TRANSLATION) {
 							restoreTransObjects(t);
 
 							t->flag ^= T_ALT_TRANSFORM;
@@ -1080,379 +1033,407 @@ int transformEvent(TransInfo *t, const wmEvent *event)
 							handled = true;
 						}
 					}
-					break;
-					
-				case TFM_MODAL_SNAP_INV_ON:
-					t->modifiers |= MOD_SNAP_INVERT;
-					t->redraw |= TREDRAW_HARD;
-					handled = true;
-					break;
-				case TFM_MODAL_SNAP_INV_OFF:
-					t->modifiers &= ~MOD_SNAP_INVERT;
-					t->redraw |= TREDRAW_HARD;
-					handled = true;
-					break;
-				case TFM_MODAL_SNAP_TOGGLE:
-					t->modifiers ^= MOD_SNAP;
-					t->redraw |= TREDRAW_HARD;
-					handled = true;
-					break;
-				case TFM_MODAL_AXIS_X:
-					if ((t->flag & T_NO_CONSTRAINT) == 0) {
-						if (cmode == 'X') {
-							stopConstraint(t);
+				}
+				break;
+			case TFM_MODAL_ROTATE:
+				/* only switch when... */
+				if (!(t->options & CTX_TEXTURE) && !(t->options & (CTX_MOVIECLIP | CTX_MASK))) {
+					if (ELEM6(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_TRANSLATION, TFM_EDGE_SLIDE, TFM_VERT_SLIDE)) {
+						resetTransModal(t);
+						resetTransRestrictions(t);
+						
+						if (t->mode == TFM_ROTATION) {
+							restoreTransObjects(t);
+							initTrackball(t);
 						}
 						else {
-							if (t->flag & T_2D_EDIT) {
-								setUserConstraint(t, V3D_MANIP_GLOBAL, (CON_AXIS0), IFACE_("along X"));
-							}
-							else {
-								setUserConstraint(t, t->current_orientation, (CON_AXIS0), IFACE_("along %s X"));
-							}
+							restoreTransObjects(t);
+							initRotation(t);
 						}
+						initSnapping(t, NULL); // need to reinit after mode change
 						t->redraw |= TREDRAW_HARD;
 						handled = true;
 					}
-					break;
-				case TFM_MODAL_AXIS_Y:
-					if ((t->flag & T_NO_CONSTRAINT) == 0) {
-						if (cmode == 'Y') {
-							stopConstraint(t);
-						}
-						else {
-							if (t->flag & T_2D_EDIT) {
-								setUserConstraint(t, V3D_MANIP_GLOBAL, (CON_AXIS1), IFACE_("along Y"));
-							}
-							else {
-								setUserConstraint(t, t->current_orientation, (CON_AXIS1), IFACE_("along %s Y"));
-							}
-						}
+				}
+				break;
+			case TFM_MODAL_RESIZE:
+				/* only switch when... */
+				if (ELEM5(t->mode, TFM_ROTATION, TFM_TRANSLATION, TFM_TRACKBALL, TFM_EDGE_SLIDE, TFM_VERT_SLIDE)) {
+					resetTransModal(t);
+					resetTransRestrictions(t);
+					restoreTransObjects(t);
+					initResize(t);
+					initSnapping(t, NULL); // need to reinit after mode change
+					t->redraw |= TREDRAW_HARD;
+					handled = true;
+				}
+				else if (t->mode == TFM_SHRINKFATTEN) {
+					t->flag ^= T_ALT_TRANSFORM;
+					t->redraw |= TREDRAW_HARD;
+					handled = true;
+				}
+				else if (t->mode == TFM_RESIZE) {
+					if (t->options & CTX_MOVIECLIP) {
+						restoreTransObjects(t);
+
+						t->flag ^= T_ALT_TRANSFORM;
 						t->redraw |= TREDRAW_HARD;
 						handled = true;
 					}
-					break;
-				case TFM_MODAL_AXIS_Z:
-					if ((t->flag & (T_NO_CONSTRAINT | T_2D_EDIT)) == 0) {
-						if (cmode == 'Z') {
-							stopConstraint(t);
-						}
-						else {
-							setUserConstraint(t, t->current_orientation, (CON_AXIS2), IFACE_("along %s Z"));
-						}
-						t->redraw |= TREDRAW_HARD;
-						handled = true;
+				}
+				break;
+				
+			case TFM_MODAL_SNAP_INV_ON:
+				t->modifiers |= MOD_SNAP_INVERT;
+				t->redraw |= TREDRAW_HARD;
+				handled = true;
+				break;
+			case TFM_MODAL_SNAP_INV_OFF:
+				t->modifiers &= ~MOD_SNAP_INVERT;
+				t->redraw |= TREDRAW_HARD;
+				handled = true;
+				break;
+			case TFM_MODAL_SNAP_TOGGLE:
+				t->modifiers ^= MOD_SNAP;
+				t->redraw |= TREDRAW_HARD;
+				handled = true;
+				break;
+			case TFM_MODAL_AXIS_X:
+				if ((t->flag & T_NO_CONSTRAINT) == 0) {
+					if (cmode == 'X') {
+						stopConstraint(t);
 					}
-					break;
-				case TFM_MODAL_PLANE_X:
-					if ((t->flag & (T_NO_CONSTRAINT | T_2D_EDIT)) == 0) {
-						if (cmode == 'X') {
-							stopConstraint(t);
+					else {
+						if (t->flag & T_2D_EDIT) {
+							setUserConstraint(t, V3D_MANIP_GLOBAL, (CON_AXIS0), IFACE_("along X"));
 						}
 						else {
-							setUserConstraint(t, t->current_orientation, (CON_AXIS1 | CON_AXIS2), IFACE_("locking %s X"));
+							setUserConstraint(t, t->current_orientation, (CON_AXIS0), IFACE_("along %s X"));
 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list