[Bf-blender-cvs] [5c8d5c7] master: View3d: ensure locked views are on an axis - behavior wasn't well defined.

Campbell Barton noreply at git.blender.org
Wed Feb 12 01:28:04 CET 2014


Commit: 5c8d5c70cf9b01ba067c625bb0e5c0d26c76cb79
Author: Campbell Barton
Date:   Wed Feb 12 11:26:02 2014 +1100
https://developer.blender.org/rB5c8d5c70cf9b01ba067c625bb0e5c0d26c76cb79

View3d: ensure locked views are on an axis - behavior wasn't well defined.

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

M	source/blender/editors/include/ED_view3d.h
M	source/blender/editors/screen/screen_ops.c
M	source/blender/editors/space_view3d/view3d_edit.c
M	source/blender/editors/space_view3d/view3d_view.c

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

diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index f84d42a..8032872 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -308,6 +308,7 @@ void ED_view3d_offscreen_sky_color_get(struct Scene *scene, float sky_color[3]);
 struct Base *ED_view3d_give_base_under_cursor(struct bContext *C, const int mval[2]);
 void ED_view3d_quadview_update(struct ScrArea *sa, struct ARegion *ar, bool do_clip);
 void ED_view3d_update_viewmat(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, float viewmat[4][4], float winmat[4][4]);
+char ED_view3d_lock_view_from_index(int index);
 bool ED_view3d_lock(struct RegionView3D *rv3d);
 
 uint64_t ED_view3d_datamask(struct Scene *scene, struct View3D *v3d);
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 4c57346..799db37 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -2896,6 +2896,7 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
 		/* lock views and set them */
 		if (sa->spacetype == SPACE_VIEW3D) {
 			View3D *v3d = sa->spacedata.first;
+			int index_qsplit = 0;
 
 			/* run ED_view3d_lock() so the correct 'rv3d->viewquat' is set,
 			 * otherwise when restoring rv3d->localvd the 'viewquat' won't
@@ -2907,9 +2908,9 @@ static int region_quadview_exec(bContext *C, wmOperator *op)
 			const char viewlock = (rv3d->viewlock_quad & RV3D_VIEWLOCK_INIT) ?
 			                      (rv3d->viewlock_quad & ~RV3D_VIEWLOCK_INIT) : RV3D_LOCKED;
 
-			region_quadview_init_rv3d(sa, ar,              viewlock, RV3D_VIEW_FRONT, RV3D_ORTHO);
-			region_quadview_init_rv3d(sa, (ar = ar->next), viewlock, RV3D_VIEW_TOP,   RV3D_ORTHO);
-			region_quadview_init_rv3d(sa, (ar = ar->next), viewlock, RV3D_VIEW_RIGHT, RV3D_ORTHO);
+			region_quadview_init_rv3d(sa, ar,              viewlock, ED_view3d_lock_view_from_index(index_qsplit++), RV3D_ORTHO);
+			region_quadview_init_rv3d(sa, (ar = ar->next), viewlock, ED_view3d_lock_view_from_index(index_qsplit++), RV3D_ORTHO);
+			region_quadview_init_rv3d(sa, (ar = ar->next), viewlock, ED_view3d_lock_view_from_index(index_qsplit++), RV3D_ORTHO);
 			if (v3d->camera) region_quadview_init_rv3d(sa, (ar = ar->next), 0, RV3D_VIEW_CAMERA,     RV3D_CAMOB);
 			else             region_quadview_init_rv3d(sa, (ar = ar->next), 0, RV3D_VIEW_PERSPORTHO, RV3D_PERSP);
 
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index c055a2e..fccc4d8 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -85,26 +85,6 @@
 /* for ndof prints */
 // #define DEBUG_NDOF_MOTION
 
-/**
- * Mostly this function just checks ``rv3d->viewlock & RV3D_LOCKED`` however there is a
- * special case where the flag is set but the user already switched out of an axis locked view.
- *
- * The 'view' in the function name refers to #RegionView3D.view which we may be locked.
- *
- * Functions which change the 'view' should call this check first, or...
- * only apply to the user view (in the instance of a quad-view setup).
- */
-bool ED_view3d_view_lock_check(View3D *UNUSED(v3d), RegionView3D *rv3d)
-{
-	if (rv3d->viewlock & RV3D_LOCKED) {
-		if ((RV3D_VIEW_IS_AXIS(rv3d->view) || rv3d->view == RV3D_VIEW_CAMERA)) {
-			return true;
-		}
-	}
-
-	return false;
-}
-
 bool ED_view3d_offset_lock_check(struct View3D *v3d, struct RegionView3D *rv3d)
 {
 	return (rv3d->persp != RV3D_CAMOB) && (v3d->ob_centre_cursor || v3d->ob_centre);
@@ -410,6 +390,24 @@ void ED_view3d_quadview_update(ScrArea *sa, ARegion *ar, bool do_clip)
 		view3d_boxview_copy(sa, ar_sync ? ar_sync : sa->regionbase.last);
 	}
 
+	/* ensure locked regions have an axis, locked user views don't make much sense */
+	if (viewlock & RV3D_LOCKED) {
+		int index_qsplit = 0;
+		for (ar = sa->regionbase.first; ar; ar = ar->next) {
+			if (ar->alignment == RGN_ALIGN_QSPLIT) {
+				rv3d = ar->regiondata;
+				if (rv3d->viewlock) {
+					if (!RV3D_VIEW_IS_AXIS(rv3d->view)) {
+						rv3d->view = ED_view3d_lock_view_from_index(index_qsplit);
+						rv3d->persp = RV3D_ORTHO;
+						ED_view3d_lock(rv3d);
+					}
+				}
+				index_qsplit++;
+			}
+		}
+	}
+
 	ED_area_tag_redraw(sa);
 }
 
@@ -1006,7 +1004,7 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 	vod = op->customdata;
 
 	/* poll should check but in some cases fails, see poll func for details */
-	if (ED_view3d_view_lock_check(vod->v3d, vod->rv3d)) {
+	if (vod->rv3d->viewlock & RV3D_LOCKED) {
 		viewops_data_free(C, op);
 		return OPERATOR_PASS_THROUGH;
 	}
@@ -2282,7 +2280,7 @@ static int viewdolly_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 	vod = op->customdata;
 
 	/* poll should check but in some cases fails, see poll func for details */
-	if (ED_view3d_view_lock_check(vod->v3d, vod->rv3d)) {
+	if (vod->rv3d->viewlock & RV3D_LOCKED) {
 		viewops_data_free(C, op);
 		return OPERATOR_PASS_THROUGH;
 	}
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index d06f786..9944029 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -803,6 +803,17 @@ static void obmat_to_viewmat(RegionView3D *rv3d, Object *ob)
 	mat3_to_quat(rv3d->viewquat, tmat);
 }
 
+char ED_view3d_lock_view_from_index(int index)
+{
+	switch (index) {
+		case 0:  return RV3D_VIEW_FRONT;
+		case 1:  return RV3D_VIEW_TOP;
+		case 2:  return RV3D_VIEW_RIGHT;
+		default: return RV3D_VIEW_USER;
+	}
+
+}
+
 bool ED_view3d_lock(RegionView3D *rv3d)
 {
 	switch (rv3d->view) {




More information about the Bf-blender-cvs mailing list