[Bf-blender-cvs] [fecec7dd688] blender2.8: 3D View: Show view-aligned rotation manipulators

Campbell Barton noreply at git.blender.org
Thu Jun 14 11:38:10 CEST 2018


Commit: fecec7dd6889785e4f11aa95f40ad30b225a01c8
Author: Campbell Barton
Date:   Thu Jun 14 11:29:38 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBfecec7dd6889785e4f11aa95f40ad30b225a01c8

3D View: Show view-aligned rotation manipulators

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

M	source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
M	source/blender/editors/transform/transform_manipulator_3d.c

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

diff --git a/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
index a3034597f56..643a379cbb0 100644
--- a/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
+++ b/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
@@ -94,6 +94,9 @@ typedef struct DialInteraction {
 #define DIAL_WIDTH       1.0f
 #define DIAL_RESOLUTION 48
 
+/* Could make option, negative to clip more (don't show when view aligned). */
+#define DIAL_CLIP_BIAS 0.02
+
 /**
  * We can't use this for the #wmManipulatorType.matrix_basis_get callback, it conflicts with depth picking.
  */
@@ -347,6 +350,7 @@ static void manipulator_dial_draw_select(const bContext *C, wmManipulator *mpr,
 
 		copy_v3_v3(clip_plane, rv3d->viewinv[2]);
 		clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], mpr->matrix_basis[3]);
+		clip_plane[3] += DIAL_CLIP_BIAS * mpr->scale_final;
 		glEnable(GL_CLIP_DISTANCE0);
 	}
 
@@ -373,7 +377,7 @@ static void manipulator_dial_draw(const bContext *C, wmManipulator *mpr)
 
 		copy_v3_v3(clip_plane, rv3d->viewinv[2]);
 		clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], mpr->matrix_basis[3]);
-		clip_plane[3] -= 0.02f * mpr->scale_final;
+		clip_plane[3] += DIAL_CLIP_BIAS * mpr->scale_final;
 
 		glEnable(GL_CLIP_DISTANCE0);
 	}
diff --git a/source/blender/editors/transform/transform_manipulator_3d.c b/source/blender/editors/transform/transform_manipulator_3d.c
index 0e96bc79c4d..75da0fc2d23 100644
--- a/source/blender/editors/transform/transform_manipulator_3d.c
+++ b/source/blender/editors/transform/transform_manipulator_3d.c
@@ -254,16 +254,18 @@ static bool manipulator_is_axis_visible(
         const RegionView3D *rv3d, const int twtype,
         const float idot[3], const int axis_type, const int axis_idx)
 {
-	bool is_plane = false;
-	const uint aidx_norm = manipulator_orientation_axis(axis_idx, &is_plane);
-	/* don't draw axis perpendicular to the view */
-	if (aidx_norm < 3) {
-		float idot_axis = idot[aidx_norm];
-		if (is_plane) {
-			idot_axis = 1.0f - idot_axis;
-		}
-		if (idot_axis < g_tw_axis_range[is_plane].min) {
-			return false;
+	if ((axis_idx >= MAN_AXIS_RANGE_ROT_START && axis_idx < MAN_AXIS_RANGE_ROT_END) == 0) {
+		bool is_plane = false;
+		const uint aidx_norm = manipulator_orientation_axis(axis_idx, &is_plane);
+		/* don't draw axis perpendicular to the view */
+		if (aidx_norm < 3) {
+			float idot_axis = idot[aidx_norm];
+			if (is_plane) {
+				idot_axis = 1.0f - idot_axis;
+			}
+			if (idot_axis < g_tw_axis_range[is_plane].min) {
+				return false;
+			}
 		}
 	}
 
@@ -340,25 +342,31 @@ static void manipulator_get_axis_color(
 	const float alpha_hi = 1.0f;
 	float alpha_fac;
 
-	bool is_plane = false;
-	const int axis_idx_norm = manipulator_orientation_axis(axis_idx, &is_plane);
-	/* get alpha fac based on axis angle, to fade axis out when hiding it because it points towards view */
-	if (axis_idx_norm < 3) {
-		const float idot_min = g_tw_axis_range[is_plane].min;
-		const float idot_max = g_tw_axis_range[is_plane].max;
-		float idot_axis = idot[axis_idx_norm];
-		if (is_plane) {
-			idot_axis = 1.0f - idot_axis;
-		}
-		alpha_fac = (
-		        (idot_axis > idot_max) ?
-		        1.0f : (idot_axis < idot_min) ?
-		        0.0f : ((idot_axis - idot_min) / (idot_max - idot_min)));
-	}
-	else {
+	if (axis_idx >= MAN_AXIS_RANGE_ROT_START && axis_idx < MAN_AXIS_RANGE_ROT_END) {
+		/* Never fade rotation rings. */
 		/* trackball rotation axis is a special case, we only draw a slight overlay */
 		alpha_fac = (axis_idx == MAN_AXIS_ROT_T) ? 0.1f : 1.0f;
 	}
+	else {
+		bool is_plane = false;
+		const int axis_idx_norm = manipulator_orientation_axis(axis_idx, &is_plane);
+		/* get alpha fac based on axis angle, to fade axis out when hiding it because it points towards view */
+		if (axis_idx_norm < 3) {
+			const float idot_min = g_tw_axis_range[is_plane].min;
+			const float idot_max = g_tw_axis_range[is_plane].max;
+			float idot_axis = idot[axis_idx_norm];
+			if (is_plane) {
+				idot_axis = 1.0f - idot_axis;
+			}
+			alpha_fac = (
+			        (idot_axis > idot_max) ?
+			        1.0f : (idot_axis < idot_min) ?
+			        0.0f : ((idot_axis - idot_min) / (idot_max - idot_min)));
+		}
+		else {
+			alpha_fac = 1.0f;
+		}
+	}
 
 	switch (axis_idx) {
 		case MAN_AXIS_TRANS_X:



More information about the Bf-blender-cvs mailing list