[Bf-blender-cvs] [9e4709e9a55] blender2.8: Manipulator: fix 2D icon buttons in the 3D view

Campbell Barton noreply at git.blender.org
Mon May 14 14:48:05 CEST 2018


Commit: 9e4709e9a556eb2717c7e3c8eafd8dc50ffa801b
Author: Campbell Barton
Date:   Mon May 14 14:46:37 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB9e4709e9a556eb2717c7e3c8eafd8dc50ffa801b

Manipulator: fix 2D icon buttons in the 3D view

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

M	source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c

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

diff --git a/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c
index 73520d1801d..fbf783c31f7 100644
--- a/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c
+++ b/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c
@@ -98,7 +98,7 @@ static void button2d_geom_draw_backdrop(
 }
 
 static void button2d_draw_intern(
-        const bContext *UNUSED(C), wmManipulator *mpr,
+        const bContext *C, wmManipulator *mpr,
         const bool select, const bool highlight)
 {
 	ButtonManipulator2D *button = (ButtonManipulator2D *)mpr;
@@ -131,7 +131,23 @@ static void button2d_draw_intern(
 	gpuPushMatrix();
 	gpuMultMatrix(matrix_final);
 
-	if (select == false) {
+	bool is_3d = (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) != 0;
+	if (is_3d) {
+		RegionView3D *rv3d = CTX_wm_region_view3d(C);
+		float matrix_align[4][4];
+		float matrix_final_unit[4][4];
+		normalize_m4_m4(matrix_final_unit, matrix_final);
+		mul_m4_m4m4(matrix_align, rv3d->viewmat, matrix_final_unit);
+		zero_v3(matrix_align[3]);
+		transpose_m4(matrix_align);
+		gpuMultMatrix(matrix_align);
+	}
+
+	if (select) {
+		BLI_assert(is_3d);
+		button2d_geom_draw_backdrop(mpr, color, select);
+	}
+	else {
 		glEnable(GL_BLEND);
 		if (button->shape_batch[0] != NULL) {
 			glEnable(GL_LINE_SMOOTH);
@@ -150,12 +166,21 @@ static void button2d_draw_intern(
 		}
 		else if (button->icon != ICON_NONE) {
 			button2d_geom_draw_backdrop(mpr, color, select);
-			gpuPopMatrix();
-			need_to_pop = false;
-			UI_icon_draw(
-			        mpr->matrix_basis[3][0] - (ICON_DEFAULT_WIDTH / 2.0) * UI_DPI_FAC,
-			        mpr->matrix_basis[3][1] - (ICON_DEFAULT_HEIGHT / 2.0) * UI_DPI_FAC,
-			        button->icon);
+			float size[2];
+			if (is_3d) {
+				const float fac = 2.0f;
+				gpuTranslate2f(-(fac / 2), -(fac / 2));
+				gpuScale2f(fac / (ICON_DEFAULT_WIDTH *  UI_DPI_FAC), fac / (ICON_DEFAULT_HEIGHT * UI_DPI_FAC));
+				size[0] = 1.0f;
+				size[1] = 1.0f;
+			}
+			else {
+				size[0] = mpr->matrix_basis[3][0] - (ICON_DEFAULT_WIDTH / 2.0) * UI_DPI_FAC;
+				size[1] = mpr->matrix_basis[3][1] - (ICON_DEFAULT_HEIGHT / 2.0) * UI_DPI_FAC;
+				gpuPopMatrix();
+				need_to_pop = false;
+			}
+			UI_icon_draw(size[0], size[1], button->icon);
 		}
 		glDisable(GL_BLEND);
 	}



More information about the Bf-blender-cvs mailing list