[Bf-blender-cvs] [c52485c16ac] blender2.8: Editor Transform: use the dial3d drawing in the rotation operation

mano-wii noreply at git.blender.org
Wed Oct 3 22:46:08 CEST 2018


Commit: c52485c16ac44ffdf39195034e85181fb2346311
Author: mano-wii
Date:   Wed Oct 3 16:25:10 2018 -0300
Branches: blender2.8
https://developer.blender.org/rBc52485c16ac44ffdf39195034e85181fb2346311

Editor Transform: use the dial3d drawing in the rotation operation

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

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

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

diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 49a583a3650..1a9515c82b0 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1999,6 +1999,9 @@ static void drawTransformView(const struct bContext *C, ARegion *UNUSED(ar), voi
 	/* edge slide, vert slide */
 	drawEdgeSlide(t);
 	drawVertSlide(t);
+
+	/* Rotation */
+	drawDial3d(t);
 }
 
 /* just draw a little warning message in the top-right corner of the viewport to warn that autokeying is enabled */
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 8bcfed9d716..758e2182de8 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -718,6 +718,7 @@ void restoreBones(TransDataContainer *tc);
 
 /* return 0 when no gimbal for selection */
 bool gimbal_axis(struct Object *ob, float gmat[3][3]);
+void drawDial3d(const TransInfo *t);
 
 /*********************** TransData Creation and General Handling *********** */
 void createTransData(struct bContext *C, TransInfo *t);
diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c
index 9a2c69d5a46..568fe499a75 100644
--- a/source/blender/editors/transform/transform_gizmo_3d.c
+++ b/source/blender/editors/transform/transform_gizmo_3d.c
@@ -78,6 +78,7 @@
 #include "ED_gizmo_library.h"
 #include "ED_gizmo_utils.h"
 
+#include "UI_interface.h"
 #include "UI_resources.h"
 
 /* local module include */
@@ -86,6 +87,7 @@
 #include "MEM_guardedalloc.h"
 
 #include "GPU_select.h"
+#include "GPU_state.h"
 #include "GPU_immediate.h"
 #include "GPU_matrix.h"
 
@@ -1237,6 +1239,77 @@ static void gizmo_xform_message_subscribe(
 	WM_msg_subscribe_rna_anon_prop(mbus, Window, view_layer, &msg_sub_value_gz_tag_refresh);
 }
 
+
+void drawDial3d(const TransInfo *t)
+{
+	if (t->mode == TFM_ROTATION && t->spacetype == SPACE_VIEW3D) {
+		float scale, line_with, increment, color[4], mat_basis[4][4], mat_final[4][4];
+		int axis_idx;
+
+		scale = UI_DPI_FAC * U.gizmo_size;
+		line_with = GIZMO_AXIS_LINE_WIDTH + 1.0f;
+
+		copy_m4_m3(mat_basis, t->spacemtx);
+		copy_v3_v3(mat_basis[3], t->center_global);
+
+		const TransCon *tc = &(t->con);
+		if (tc->mode & CON_APPLY) {
+			if (tc->mode & CON_AXIS0) {
+				axis_idx = MAN_AXIS_ROT_X;
+				negate_v3_v3(mat_basis[2], tc->mtx[0]);
+			}
+			else if (tc->mode &  CON_AXIS1) {
+				axis_idx = MAN_AXIS_ROT_Y;
+				negate_v3_v3(mat_basis[2], tc->mtx[1]);
+			}
+			else if (tc->mode &  CON_AXIS2) {
+				axis_idx = MAN_AXIS_ROT_Z;
+				negate_v3_v3(mat_basis[2], tc->mtx[2]);
+			}
+			else BLI_assert(0);
+		}
+		else {
+			axis_idx = MAN_AXIS_ROT_C;
+			negate_v3_v3(mat_basis[2], t->axis);
+			scale *= 1.2f;
+			line_with -= 1.0f;
+		}
+
+		BLI_assert(axis_idx >= MAN_AXIS_RANGE_ROT_START && axis_idx < MAN_AXIS_RANGE_ROT_END);
+		gizmo_get_axis_color(axis_idx, NULL, color, color);
+
+		ortho_basis_v3v3_v3(mat_basis[0], mat_basis[1], mat_basis[2]);
+		copy_m4_m4(mat_final, mat_basis);
+		scale *= ED_view3d_pixel_size_no_ui_scale(t->ar->regiondata, mat_final[3]);
+		mul_mat3_m4_fl(mat_final, scale);
+
+		if ((t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID))
+		    && activeSnap(t))
+		{
+			increment = (t->modifiers & MOD_PRECISION) ? t->snap[2] : t->snap[1];
+		}
+		else {
+			increment = t->snap[0];
+		}
+
+		GPU_depth_test(false);
+		GPU_blend(true);
+
+		/* XXX force AntiAlias. */
+		GPU_line_smooth(true);
+
+		ED_gizmotypes_dial_3d_draw_util(
+		        mat_basis, mat_final, line_with, color, NULL, 0.0f, 0.0f,
+		        ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_VALUE,
+		        0.0f, t->values[0], increment);
+
+		GPU_line_smooth(false);
+
+		GPU_depth_test(true);
+		GPU_blend(false);
+	}
+}
+
 /** \} */



More information about the Bf-blender-cvs mailing list