[Bf-blender-cvs] [a1164eb3ddb] master: View3D: support both orbit select & depth

Campbell Barton noreply at git.blender.org
Sat Apr 29 18:38:24 CEST 2017


Commit: a1164eb3ddbdc9ad1c8393bcf125c289cbb0966c
Author: Campbell Barton
Date:   Sun Apr 30 02:38:38 2017 +1000
Branches: master
https://developer.blender.org/rBa1164eb3ddbdc9ad1c8393bcf125c289cbb0966c

View3D: support both orbit select & depth

When using both preferences, use cursor depth when nothings selected.

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

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

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

diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index f712c790663..4e3f279e12e 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -700,22 +700,21 @@ static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3])
 }
 
 enum eViewOpsOrbit {
-	VIEWOPS_ORBIT_DEFAULT = 0,
-	VIEWOPS_ORBIT_SELECT = 1,
-	VIEWOPS_ORBIT_DEPTH = 2,
+	VIEWOPS_ORBIT_SELECT = (1 << 0),
+	VIEWOPS_ORBIT_DEPTH = (1 << 1),
 };
 
 static enum eViewOpsOrbit viewops_orbit_mode_ex(bool use_select, bool use_depth)
 {
+	enum eViewOpsOrbit flag = 0;
 	if (use_select) {
-		return VIEWOPS_ORBIT_SELECT;
+		flag |= VIEWOPS_ORBIT_SELECT;
 	}
-	else if (use_depth) {
-		return VIEWOPS_ORBIT_DEPTH;
-	}
-	else {
-		return VIEWOPS_ORBIT_DEFAULT;
+	if (use_depth) {
+		flag |= VIEWOPS_ORBIT_DEPTH;
 	}
+
+	return flag;
 }
 
 static enum eViewOpsOrbit viewops_orbit_mode(void)
@@ -736,7 +735,7 @@ static void viewops_data_create_ex(
 	RegionView3D *rv3d = vod->rv3d;
 
 	/* we need the depth info before changing any viewport options */
-	if (orbit_mode == VIEWOPS_ORBIT_DEPTH) {
+	if (orbit_mode & VIEWOPS_ORBIT_DEPTH) {
 		float fallback_depth_pt[3];
 
 		view3d_operator_needs_opengl(C); /* needed for zbuf drawing */
@@ -775,15 +774,16 @@ static void viewops_data_create_ex(
 	vod->origkey = event->type; /* the key that triggered the operator.  */
 	copy_v3_v3(vod->ofs, rv3d->ofs);
 
-	if (orbit_mode == VIEWOPS_ORBIT_SELECT) {
-
-		vod->use_dyn_ofs = true;
-
-		view3d_orbit_calc_center(C, vod->dyn_ofs);
-
-		negate_v3(vod->dyn_ofs);
+	if (orbit_mode & VIEWOPS_ORBIT_SELECT) {
+		float ofs[3];
+		if (view3d_orbit_calc_center(C, ofs) || (vod->use_dyn_ofs == false)) {
+			vod->use_dyn_ofs = true;
+			negate_v3_v3(vod->dyn_ofs, ofs);
+			orbit_mode &= ~VIEWOPS_ORBIT_DEPTH;
+		}
 	}
-	else if (orbit_mode == VIEWOPS_ORBIT_DEPTH) {
+
+	if (orbit_mode & VIEWOPS_ORBIT_DEPTH) {
 		if (vod->use_dyn_ofs) {
 			if (rv3d->is_persp) {
 				float my_origin[3]; /* original G.vd->ofs */




More information about the Bf-blender-cvs mailing list