[Bf-blender-cvs] [4ce4f57] wiggly-widgets: Refactoring of manipulator code to use selection evaluation and codes that can be shared with other widgets.

Antony Riakiotakis noreply at git.blender.org
Wed Oct 1 12:44:33 CEST 2014


Commit: 4ce4f57acffc230087c1b9be43829ff3e1434ef3
Author: Antony Riakiotakis
Date:   Wed Oct 1 11:10:06 2014 +0200
Branches: wiggly-widgets
https://developer.blender.org/rB4ce4f57acffc230087c1b9be43829ff3e1434ef3

Refactoring of manipulator code to use selection evaluation and codes
that can be shared with other widgets.

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

M	source/blender/editors/include/ED_transform.h
M	source/blender/editors/transform/transform_manipulator.c
M	source/blender/windowmanager/WM_api.h
M	source/blender/windowmanager/WM_types.h
M	source/blender/windowmanager/intern/wm_widgets.c

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

diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h
index 7dc7e84..9c0b8cc 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -153,7 +153,7 @@ void Transform_Properties(struct wmOperatorType *ot, int flags);
 /* view3d manipulators */
 
 int BIF_do_manipulator(struct bContext *C, const struct wmEvent *event, struct wmWidget *widget);
-void BIF_manipulator_render_3d_intersect(const struct bContext *C, struct wmWidget *widget);
+void BIF_manipulator_render_3d_intersect(const struct bContext *C, struct wmWidget *widget, int selectionbase);
 void BIF_draw_manipulator(const struct bContext *C, struct wmWidget *customdata);
 bool BIF_manipulator_poll(const struct bContext *C, struct wmWidget *customdata);
 
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index 952342b..f638e53 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -76,7 +76,7 @@
 
 #include "GPU_select.h"
 
-/* return codes for select, and drawing flags */
+/* drawing flags */
 
 #define MAN_TRANS_X		(1 << 0)
 #define MAN_TRANS_Y		(1 << 1)
@@ -95,6 +95,27 @@
 #define MAN_SCALE_Z		(1 << 10)
 #define MAN_SCALE_C		(MAN_SCALE_X | MAN_SCALE_Y | MAN_SCALE_Z)
 
+/* return codes for select */
+enum {
+	MAN_SEL_TRANS_X	= 0,
+	MAN_SEL_TRANS_Y,
+	MAN_SEL_TRANS_Z,
+	
+	MAN_SEL_ROT_X,
+	MAN_SEL_ROT_Y,
+	MAN_SEL_ROT_Z,
+	MAN_SEL_ROT_V,
+	MAN_SEL_ROT_T,
+
+	MAN_SEL_SCALE_X,
+	MAN_SEL_SCALE_Y,
+	MAN_SEL_SCALE_Z,
+	
+	/* those two stay at the end so the rest can be inferred with bitshifting */
+	MAN_SEL_SCALE_C,
+	MAN_SEL_TRANS_C,
+};
+
 /* color codes */
 
 #define MAN_RGB     0
@@ -855,15 +876,15 @@ static void manipulator_axis_order(RegionView3D *rv3d, int r_axis_order[3])
 /* viewmatrix should have been set OK, also no shademode! */
 static void draw_manipulator_axes_single(View3D *v3d, RegionView3D *rv3d, int colcode,
                                          int flagx, int flagy, int flagz, int axis,
-                                         const bool is_picksel)
+                                         const int selectionbase)
 {
 	switch (axis) {
 		case 0:
 			/* axes */
 			if (flagx) {
-				if (is_picksel) {
-					if      (flagx & MAN_SCALE_X) GPU_select_load_id(MAN_SCALE_X);
-					else if (flagx & MAN_TRANS_X) GPU_select_load_id(MAN_TRANS_X);
+				if (selectionbase != -1) {
+					if      (flagx & MAN_SCALE_X) GPU_select_load_id(selectionbase + MAN_SEL_SCALE_X);
+					else if (flagx & MAN_TRANS_X) GPU_select_load_id(selectionbase + MAN_SEL_TRANS_X);
 				}
 				else {
 					manipulator_setcolor(v3d, 'X', colcode, axisBlendAngle(rv3d->tw_idot[0]));
@@ -876,9 +897,9 @@ static void draw_manipulator_axes_single(View3D *v3d, RegionView3D *rv3d, int co
 			break;
 		case 1:
 			if (flagy) {
-				if (is_picksel) {
-					if      (flagy & MAN_SCALE_Y) GPU_select_load_id(MAN_SCALE_Y);
-					else if (flagy & MAN_TRANS_Y) GPU_select_load_id(MAN_TRANS_Y);
+				if (selectionbase != -1) {
+					if      (flagy & MAN_SCALE_Y) GPU_select_load_id(selectionbase + MAN_SEL_SCALE_Y);
+					else if (flagy & MAN_TRANS_Y) GPU_select_load_id(selectionbase + MAN_SEL_TRANS_Y);
 				}
 				else {
 					manipulator_setcolor(v3d, 'Y', colcode, axisBlendAngle(rv3d->tw_idot[1]));
@@ -891,9 +912,9 @@ static void draw_manipulator_axes_single(View3D *v3d, RegionView3D *rv3d, int co
 			break;
 		case 2:
 			if (flagz) {
-				if (is_picksel) {
-					if      (flagz & MAN_SCALE_Z) GPU_select_load_id(MAN_SCALE_Z);
-					else if (flagz & MAN_TRANS_Z) GPU_select_load_id(MAN_TRANS_Z);
+				if (selectionbase != -1) {
+					if      (flagz & MAN_SCALE_Z) GPU_select_load_id(selectionbase + MAN_SEL_SCALE_Z);
+					else if (flagz & MAN_TRANS_Z) GPU_select_load_id(selectionbase + MAN_SEL_TRANS_Z);
 				}
 				else {
 					manipulator_setcolor(v3d, 'Z', colcode, axisBlendAngle(rv3d->tw_idot[2]));
@@ -908,11 +929,11 @@ static void draw_manipulator_axes_single(View3D *v3d, RegionView3D *rv3d, int co
 }
 static void draw_manipulator_axes(View3D *v3d, RegionView3D *rv3d, int colcode,
                                   int flagx, int flagy, int flagz,
-                                  const int axis_order[3], const bool is_picksel)
+                                  const int axis_order[3], const int selectionbase)
 {
 	int i;
 	for (i = 0; i < 3; i++) {
-		draw_manipulator_axes_single(v3d, rv3d, colcode, flagx, flagy, flagz, axis_order[i], is_picksel);
+		draw_manipulator_axes_single(v3d, rv3d, colcode, flagx, flagy, flagz, axis_order[i], selectionbase);
 	}
 }
 
@@ -937,7 +958,7 @@ static void postOrtho(const bool ortho)
 
 static void draw_manipulator_rotate(
         View3D *v3d, RegionView3D *rv3d, const int drawflags, const int combo,
-        const bool is_moving, const bool is_picksel)
+        const bool is_moving, const int selectionbase)
 {
 	double plane[4];
 	float matt[4][4];
@@ -971,7 +992,7 @@ static void draw_manipulator_rotate(
 
 	/* Screen aligned help circle */
 	if (arcs) {
-		if (is_picksel == false) {
+		if (selectionbase == -1) {
 			UI_ThemeColorShade(TH_BACK, -30);
 			drawcircball(GL_LINE_LOOP, unitmat[3], size, unitmat);
 		}
@@ -979,7 +1000,7 @@ static void draw_manipulator_rotate(
 
 	/* Screen aligned trackball rot circle */
 	if (drawflags & MAN_ROT_T) {
-		if (is_picksel) GPU_select_load_id(MAN_ROT_T);
+		if (selectionbase != -1) GPU_select_load_id(selectionbase + MAN_SEL_ROT_T);
 		else UI_ThemeColor(TH_TRANSFORM);
 
 		drawcircball(GL_LINE_LOOP, unitmat[3], 0.2f * size, unitmat);
@@ -987,7 +1008,7 @@ static void draw_manipulator_rotate(
 
 	/* Screen aligned view rot circle */
 	if (drawflags & MAN_ROT_V) {
-		if (is_picksel) GPU_select_load_id(MAN_ROT_V);
+		if (selectionbase != -1) GPU_select_load_id(selectionbase + MAN_SEL_ROT_V);
 		else UI_ThemeColor(TH_TRANSFORM);
 		drawcircball(GL_LINE_LOOP, unitmat[3], 1.2f * size, unitmat);
 
@@ -1027,7 +1048,7 @@ static void draw_manipulator_rotate(
 
 	/* axes */
 	if (arcs == 0) {
-		if (!is_picksel) {
+		if (selectionbase == -1) {
 			if ((combo & V3D_MANIP_SCALE) == 0) {
 				/* axis */
 				if ((drawflags & MAN_ROT_X) || (is_moving && (drawflags & MAN_ROT_Z))) {
@@ -1066,7 +1087,7 @@ static void draw_manipulator_rotate(
 		/* Z circle */
 		if (drawflags & MAN_ROT_Z) {
 			preOrthoFront(ortho, matt, 2);
-			if (is_picksel) GPU_select_load_id(MAN_ROT_Z);
+			if (selectionbase != -1) GPU_select_load_id(selectionbase + MAN_SEL_ROT_Z);
 			else manipulator_setcolor(v3d, 'Z', colcode, 255);
 			drawcircball(GL_LINE_LOOP, unitmat[3], 1.0, unitmat);
 			postOrtho(ortho);
@@ -1074,7 +1095,7 @@ static void draw_manipulator_rotate(
 		/* X circle */
 		if (drawflags & MAN_ROT_X) {
 			preOrthoFront(ortho, matt, 0);
-			if (is_picksel) GPU_select_load_id(MAN_ROT_X);
+			if (selectionbase != -1) GPU_select_load_id(selectionbase + MAN_SEL_ROT_X);
 			else manipulator_setcolor(v3d, 'X', colcode, 255);
 			glRotatef(90.0, 0.0, 1.0, 0.0);
 			drawcircball(GL_LINE_LOOP, unitmat[3], 1.0, unitmat);
@@ -1084,7 +1105,7 @@ static void draw_manipulator_rotate(
 		/* Y circle */
 		if (drawflags & MAN_ROT_Y) {
 			preOrthoFront(ortho, matt, 1);
-			if (is_picksel) GPU_select_load_id(MAN_ROT_Y);
+			if (selectionbase != -1) GPU_select_load_id(selectionbase + MAN_SEL_ROT_Y);
 			else manipulator_setcolor(v3d, 'Y', colcode, 255);
 			glRotatef(-90.0, 1.0, 0.0, 0.0);
 			drawcircball(GL_LINE_LOOP, unitmat[3], 1.0, unitmat);
@@ -1101,7 +1122,7 @@ static void draw_manipulator_rotate(
 		/* Z circle */
 		if (drawflags & MAN_ROT_Z) {
 			preOrthoFront(ortho, rv3d->twmat, 2);
-			if (is_picksel) GPU_select_load_id(MAN_ROT_Z);
+			if (selectionbase != -1) GPU_select_load_id(selectionbase + MAN_SEL_ROT_Z);
 			else manipulator_setcolor(v3d, 'Z', colcode, 255);
 			partial_doughnut(cusize / 4.0f, 1.0f, 0, 48, 8, 48);
 			postOrtho(ortho);
@@ -1109,7 +1130,7 @@ static void draw_manipulator_rotate(
 		/* X circle */
 		if (drawflags & MAN_ROT_X) {
 			preOrthoFront(ortho, rv3d->twmat, 0);
-			if (is_picksel) GPU_select_load_id(MAN_ROT_X);
+			if (selectionbase != -1) GPU_select_load_id(selectionbase + MAN_SEL_ROT_X);
 			else manipulator_setcolor(v3d, 'X', colcode, 255);
 			glRotatef(90.0, 0.0, 1.0, 0.0);
 			partial_doughnut(cusize / 4.0f, 1.0f, 0, 48, 8, 48);
@@ -1119,7 +1140,7 @@ static void draw_manipulator_rotate(
 		/* Y circle */
 		if (drawflags & MAN_ROT_Y) {
 			preOrthoFront(ortho, rv3d->twmat, 1);
-			if (is_picksel) GPU_select_load_id(MAN_ROT_Y);
+			if (selectionbase != -1) GPU_select_load_id(selectionbase + MAN_SEL_ROT_Y);
 			else manipulator_setcolor(v3d, 'Y', colcode, 255);
 			glRotatef(-90.0, 1.0, 0.0, 0.0);
 			partial_doughnut(cusize / 4.0f, 1.0f, 0, 48, 8, 48);
@@ -1136,7 +1157,7 @@ static void draw_manipulator_rotate(
 		if (drawflags & MAN_ROT_Z) {
 			preOrthoFront(ortho, rv3d->twmat, 2);
 			glPushMatrix();
-			if (is_picksel) GPU_select_load_id(MAN_ROT_Z);
+			if (selectionbase != -1) GPU_select_load_id(selectionbase + MAN_SEL_ROT_Z);
 			else manipulator_setcolor(v3d, 'Z', colcode, 255);
 
 			partial_doughnut(0.7f * cusize, 1.0f, 31, 33, 8, 64);
@@ -1149,7 +1170,7 @@ static void draw_manipulator_rotate(
 		if (drawflags & MAN_ROT_Y) {
 			preOrthoFront(ortho, rv3d->twmat, 1);
 			glPushMatrix();
-			if (is_picksel) GPU_select_load_id(MAN_ROT_Y);
+			if (selectionbase != -1) GPU_select_load_id(selectionbase + MAN_SEL_ROT_Y);
 			else manipulator_setcolor(v3d, 'Y', colcode, 255);
 
 			glRotatef(90.0, 1.0, 0.0, 0.0);
@@ -1164,7 +1185,7 @@ static void draw_manipulator_rotate(
 		if (drawflags & MAN_ROT_X) {
 			preOrthoFront(ortho, rv3d->twmat, 0);
 			glPushMatrix();
-			if (is_picksel) GPU_select_load_id(MAN_ROT_X);
+			if (selectionbase != -1) GPU_select_load_id(MAN_SEL_ROT_X);
 			else manipulator_setcolor(v3d, 'X', colcode, 255);
 
 			glRotatef(-90.0, 0.0, 1.0, 0.0);
@@ -1247,7 +1268,7 @@ static void drawsolidcube(float size)
 
 static void draw_manipulator_scale(
         View3D *v3d, RegionView3D *rv3d, const int drawflags, const int combo, const int colcode,
-        const bool is_mo

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list