[Bf-blender-cvs] [92f13f7] master: Fix T42618: Lock to view + autokey bug

Campbell Barton noreply at git.blender.org
Mon Nov 24 00:29:46 CET 2014


Commit: 92f13f7287e72d8625611a9dcd92b1c636ae8454
Author: Campbell Barton
Date:   Mon Nov 24 00:27:50 2014 +0100
Branches: master
https://developer.blender.org/rB92f13f7287e72d8625611a9dcd92b1c636ae8454

Fix T42618: Lock to view + autokey bug

in fact support for this combination wasn't added at all.

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

M	source/blender/editors/space_view3d/view3d_edit.c
M	source/blender/editors/space_view3d/view3d_view.c

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

diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index aa0e6e5..20488e5 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -1120,6 +1120,8 @@ static int viewrotate_modal(bContext *C, wmOperator *op, const wmEvent *event)
 {
 	ViewOpsData *vod = op->customdata;
 	short event_code = VIEW_PASS;
+	bool use_autokey = false;
+	int ret = OPERATOR_RUNNING_MODAL;
 
 	/* execute the events */
 	if (event->type == MOUSEMOVE) {
@@ -1154,17 +1156,25 @@ static int viewrotate_modal(bContext *C, wmOperator *op, const wmEvent *event)
 
 	if (event_code == VIEW_APPLY) {
 		viewrotate_apply(vod, event->x, event->y);
+		if (ED_screen_animation_playing(CTX_wm_manager(C))) {
+			use_autokey = true;
+		}
 	}
 	else if (event_code == VIEW_CONFIRM) {
-		ED_view3d_camera_lock_autokey(vod->v3d, vod->rv3d, C, true, true);
 		ED_view3d_depth_tag_update(vod->rv3d);
+		use_autokey = true;
+		ret = OPERATOR_FINISHED;
+	}
 
-		viewops_data_free(C, op);
+	if (use_autokey) {
+		ED_view3d_camera_lock_autokey(vod->v3d, vod->rv3d, C, true, true);
+	}
 
-		return OPERATOR_FINISHED;
+	if (ret & OPERATOR_FINISHED) {
+		viewops_data_free(C, op);
 	}
 
-	return OPERATOR_RUNNING_MODAL;
+	return ret;
 }
 
 /**
@@ -1222,26 +1232,31 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 		ED_region_tag_redraw(vod->ar);
 	}
 
-	if (event->type == MOUSEPAN) {
+	if (ELEM(event->type, MOUSEPAN, MOUSEROTATE)) {
 		/* Rotate direction we keep always same */
-		if (U.uiflag2 & USER_TRACKPAD_NATURAL)
-			viewrotate_apply(vod, 2 * event->x - event->prevx, 2 * event->y - event->prevy);
-		else
-			viewrotate_apply(vod, event->prevx, event->prevy);
-			
-		ED_view3d_depth_tag_update(vod->rv3d);
-		
-		viewops_data_free(C, op);
-		
-		return OPERATOR_FINISHED;
-	}
-	else if (event->type == MOUSEROTATE) {
-		/* MOUSEROTATE performs orbital rotation, so y axis delta is set to 0 */
-		viewrotate_apply(vod, event->prevx, event->y);
+		int x, y;
+
+		if (event->type == MOUSEPAN) {
+			if (U.uiflag2 & USER_TRACKPAD_NATURAL) {
+				x = 2 * event->x - event->prevx;
+				y = 2 * event->y - event->prevy;
+			}
+			else {
+				x = event->prevx;
+				y = event->prevy;
+			}
+		}
+		else {
+			/* MOUSEROTATE performs orbital rotation, so y axis delta is set to 0 */
+			x = event->prevx;
+			y = event->y;
+		}
+
+		viewrotate_apply(vod, x, y);
 		ED_view3d_depth_tag_update(vod->rv3d);
-		
+
 		viewops_data_free(C, op);
-		
+
 		return OPERATOR_FINISHED;
 	}
 	else {
@@ -1947,6 +1962,8 @@ static int viewmove_modal(bContext *C, wmOperator *op, const wmEvent *event)
 
 	ViewOpsData *vod = op->customdata;
 	short event_code = VIEW_PASS;
+	bool use_autokey = false;
+	int ret = OPERATOR_RUNNING_MODAL;
 
 	/* execute the events */
 	if (event->type == MOUSEMOVE) {
@@ -1973,17 +1990,25 @@ static int viewmove_modal(bContext *C, wmOperator *op, const wmEvent *event)
 
 	if (event_code == VIEW_APPLY) {
 		viewmove_apply(vod, event->x, event->y);
+		if (ED_screen_animation_playing(CTX_wm_manager(C))) {
+			use_autokey = true;
+		}
 	}
 	else if (event_code == VIEW_CONFIRM) {
-		ED_view3d_camera_lock_autokey(vod->v3d, vod->rv3d, C, false, true);
 		ED_view3d_depth_tag_update(vod->rv3d);
+		use_autokey = true;
+		ret = OPERATOR_FINISHED;
+	}
 
-		viewops_data_free(C, op);
+	if (use_autokey) {
+		ED_view3d_camera_lock_autokey(vod->v3d, vod->rv3d, C, false, true);
+	}
 
-		return OPERATOR_FINISHED;
+	if (ret & OPERATOR_FINISHED) {
+		viewops_data_free(C, op);
 	}
 
-	return OPERATOR_RUNNING_MODAL;
+	return ret;
 }
 
 static int viewmove_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@@ -2215,6 +2240,8 @@ static int viewzoom_modal(bContext *C, wmOperator *op, const wmEvent *event)
 {
 	ViewOpsData *vod = op->customdata;
 	short event_code = VIEW_PASS;
+	bool use_autokey = false;
+	int ret = OPERATOR_RUNNING_MODAL;
 
 	/* execute the events */
 	if (event->type == TIMER && event->customdata == vod->timer) {
@@ -2245,16 +2272,25 @@ static int viewzoom_modal(bContext *C, wmOperator *op, const wmEvent *event)
 
 	if (event_code == VIEW_APPLY) {
 		viewzoom_apply(vod, &event->x, U.viewzoom, (U.uiflag & USER_ZOOM_INVERT) != 0);
+		if (ED_screen_animation_playing(CTX_wm_manager(C))) {
+			use_autokey = true;
+		}
 	}
 	else if (event_code == VIEW_CONFIRM) {
-		ED_view3d_camera_lock_autokey(vod->v3d, vod->rv3d, C, false, true);
 		ED_view3d_depth_tag_update(vod->rv3d);
-		viewops_data_free(C, op);
+		use_autokey = true;
+		ret = OPERATOR_FINISHED;
+	}
 
-		return OPERATOR_FINISHED;
+	if (use_autokey) {
+		ED_view3d_camera_lock_autokey(vod->v3d, vod->rv3d, C, false, true);
 	}
 
-	return OPERATOR_RUNNING_MODAL;
+	if (ret & OPERATOR_FINISHED) {
+		viewops_data_free(C, op);
+	}
+
+	return ret;
 }
 
 static int viewzoom_exec(bContext *C, wmOperator *op)
@@ -2316,6 +2352,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op)
 	ED_view3d_depth_tag_update(rv3d);
 
 	ED_view3d_camera_lock_sync(v3d, rv3d);
+	ED_view3d_camera_lock_autokey(v3d, rv3d, C, false, true);
 
 	ED_region_tag_redraw(ar);
 
@@ -2390,8 +2427,10 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 				vod->origy = vod->oldy = vod->origy + event->x - event->prevx;
 				viewzoom_apply(vod, &event->prevx, USER_ZOOM_DOLLY, (U.uiflag & USER_ZOOM_INVERT) != 0);
 			}
+			ED_view3d_camera_lock_autokey(vod->v3d, vod->rv3d, C, false, true);
+
 			ED_view3d_depth_tag_update(vod->rv3d);
-			
+
 			viewops_data_free(C, op);
 			return OPERATOR_FINISHED;
 		}
@@ -2487,6 +2526,8 @@ static int viewdolly_modal(bContext *C, wmOperator *op, const wmEvent *event)
 {
 	ViewOpsData *vod = op->customdata;
 	short event_code = VIEW_PASS;
+	bool use_autokey = false;
+	int ret = OPERATOR_RUNNING_MODAL;
 
 	/* execute the events */
 	if (event->type == MOUSEMOVE) {
@@ -2513,16 +2554,25 @@ static int viewdolly_modal(bContext *C, wmOperator *op, const wmEvent *event)
 
 	if (event_code == VIEW_APPLY) {
 		viewdolly_apply(vod, event->x, event->y, (U.uiflag & USER_ZOOM_INVERT) != 0);
+		if (ED_screen_animation_playing(CTX_wm_manager(C))) {
+			use_autokey = true;
+		}
 	}
 	else if (event_code == VIEW_CONFIRM) {
-		ED_view3d_camera_lock_autokey(vod->v3d, vod->rv3d, C, false, true);
 		ED_view3d_depth_tag_update(vod->rv3d);
-		viewops_data_free(C, op);
+		use_autokey = true;
+		ret = OPERATOR_FINISHED;
+	}
 
-		return OPERATOR_FINISHED;
+	if (use_autokey) {
+		ED_view3d_camera_lock_autokey(vod->v3d, vod->rv3d, C, false, true);
 	}
 
-	return OPERATOR_RUNNING_MODAL;
+	if (ret & OPERATOR_FINISHED) {
+		viewops_data_free(C, op);
+	}
+
+	return ret;
 }
 
 static int viewdolly_exec(bContext *C, wmOperator *op)
@@ -3971,6 +4021,8 @@ static int viewroll_modal(bContext *C, wmOperator *op, const wmEvent *event)
 {
 	ViewOpsData *vod = op->customdata;
 	short event_code = VIEW_PASS;
+	bool use_autokey = false;
+	int ret = OPERATOR_RUNNING_MODAL;
 
 	/* execute the events */
 	if (event->type == MOUSEMOVE) {
@@ -3997,16 +4049,25 @@ static int viewroll_modal(bContext *C, wmOperator *op, const wmEvent *event)
 
 	if (event_code == VIEW_APPLY) {
 		viewroll_apply(vod, event->x, event->y);
+		if (ED_screen_animation_playing(CTX_wm_manager(C))) {
+			use_autokey = true;
+		}
 	}
 	else if (event_code == VIEW_CONFIRM) {
-		ED_view3d_camera_lock_autokey(vod->v3d, vod->rv3d, C, true, false);
 		ED_view3d_depth_tag_update(vod->rv3d);
-		viewops_data_free(C, op);
+		use_autokey = true;
+		ret = OPERATOR_FINISHED;
+	}
 
-		return OPERATOR_FINISHED;
+	if (use_autokey) {
+		ED_view3d_camera_lock_autokey(vod->v3d, vod->rv3d, C, true, false);
 	}
 
-	return OPERATOR_RUNNING_MODAL;
+	if (ret & OPERATOR_FINISHED) {
+		viewops_data_free(C, op);
+	}
+
+	return ret;
 }
 
 static EnumPropertyItem prop_view_roll_items[] = {
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 9faca75..4d5e10c 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -356,6 +356,7 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const w
 			view3d_smooth_view_state_restore(&sms->dst, v3d, rv3d);
 
 			ED_view3d_camera_lock_sync(v3d, rv3d);
+			ED_view3d_camera_lock_autokey(v3d, rv3d, C, true, true);
 		}
 		
 		if ((rv3d->viewlock & RV3D_LOCKED) == 0) {
@@ -382,6 +383,10 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const w
 		v3d->lens  = sms->dst.lens * step + sms->src.lens * step_inv;
 
 		ED_view3d_camera_lock_sync(v3d, rv3d);
+		if (ED_screen_animation_playing(CTX_wm_manager(C))) {
+			ED_view3d_camera_lock_autokey(v3d, rv3d, C, true, true);
+		}
+
 	}
 	
 	if (rv3d->viewlock & RV3D_BOXVIEW)




More information about the Bf-blender-cvs mailing list