[Bf-blender-cvs] [9f16790] master: Code Cleanup: avoid using G_PICKSEL for transform manipulator
Campbell Barton
noreply at git.blender.org
Thu Jan 16 10:54:53 CET 2014
Commit: 9f167908402dae589f8e230115f0439faa4a086c
Author: Campbell Barton
Date: Thu Jan 16 20:54:14 2014 +1100
https://developer.blender.org/rB9f167908402dae589f8e230115f0439faa4a086c
Code Cleanup: avoid using G_PICKSEL for transform manipulator
===================================================================
M source/blender/editors/transform/transform_manipulator.c
===================================================================
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index a2edb2d..ddbb05f 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -914,9 +914,9 @@ static void draw_manipulator_axes(View3D *v3d, RegionView3D *rv3d, int colcode,
}
}
-static void preOrthoFront(int ortho, float twmat[4][4], int axis)
+static void preOrthoFront(const bool ortho, float twmat[4][4], int axis)
{
- if (ortho == 0) {
+ if (ortho == false) {
float omat[4][4];
copy_m4_m4(omat, twmat);
orthogonalize_m4(omat, axis);
@@ -926,14 +926,16 @@ static void preOrthoFront(int ortho, float twmat[4][4], int axis)
}
}
-static void postOrtho(int ortho)
+static void postOrtho(const bool ortho)
{
- if (ortho == 0) {
+ if (ortho == false) {
glPopMatrix();
}
}
-static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, int drawflags, int combo)
+static void draw_manipulator_rotate(
+ View3D *v3d, RegionView3D *rv3d, const int drawflags, const int combo,
+ const bool is_moving, const bool is_picksel)
{
double plane[4];
float matt[4][4];
@@ -941,11 +943,8 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
float cywid = 0.33f * 0.01f * (float)U.tw_handlesize;
float cusize = cywid * 0.65f;
int arcs = (G.debug_value != 2);
- int colcode;
- int ortho;
-
- if (moving) colcode = MAN_MOVECOL;
- else colcode = MAN_RGB;
+ const int colcode = (is_moving) ? MAN_MOVECOL : MAN_RGB;
+ bool ortho;
/* when called while moving in mixed mode, do not draw when... */
if ((drawflags & MAN_ROT_C) == 0) return;
@@ -970,7 +969,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
/* Screen aligned help circle */
if (arcs) {
- if ((G.f & G_PICKSEL) == 0) {
+ if (is_picksel == false) {
UI_ThemeColorShade(TH_BACK, -30);
drawcircball(GL_LINE_LOOP, unitmat[3], size, unitmat);
}
@@ -978,7 +977,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
/* Screen aligned trackball rot circle */
if (drawflags & MAN_ROT_T) {
- if (G.f & G_PICKSEL) glLoadName(MAN_ROT_T);
+ if (is_picksel) glLoadName(MAN_ROT_T);
UI_ThemeColor(TH_TRANSFORM);
drawcircball(GL_LINE_LOOP, unitmat[3], 0.2f * size, unitmat);
@@ -986,11 +985,11 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
/* Screen aligned view rot circle */
if (drawflags & MAN_ROT_V) {
- if (G.f & G_PICKSEL) glLoadName(MAN_ROT_V);
+ if (is_picksel) glLoadName(MAN_ROT_V);
UI_ThemeColor(TH_TRANSFORM);
drawcircball(GL_LINE_LOOP, unitmat[3], 1.2f * size, unitmat);
- if (moving) {
+ if (is_moving) {
float vec[3];
vec[0] = 0; // XXX (float)(t->imval[0] - t->center2d[0]);
vec[1] = 0; // XXX (float)(t->imval[1] - t->center2d[1]);
@@ -1009,7 +1008,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
ortho = is_orthogonal_m4(rv3d->twmat);
/* apply the transform delta */
- if (moving) {
+ if (is_moving) {
copy_m4_m4(matt, rv3d->twmat); // to copy the parts outside of [3][3]
// XXX mul_m4_m3m4(matt, t->mat, rv3d->twmat);
if (ortho) {
@@ -1026,10 +1025,10 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
/* axes */
if (arcs == 0) {
- if (!(G.f & G_PICKSEL)) {
+ if (!is_picksel) {
if ((combo & V3D_MANIP_SCALE) == 0) {
/* axis */
- if ((drawflags & MAN_ROT_X) || (moving && (drawflags & MAN_ROT_Z))) {
+ if ((drawflags & MAN_ROT_X) || (is_moving && (drawflags & MAN_ROT_Z))) {
preOrthoFront(ortho, rv3d->twmat, 2);
manipulator_setcolor(v3d, 'X', colcode, 255);
glBegin(GL_LINES);
@@ -1038,7 +1037,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
glEnd();
postOrtho(ortho);
}
- if ((drawflags & MAN_ROT_Y) || (moving && (drawflags & MAN_ROT_X))) {
+ if ((drawflags & MAN_ROT_Y) || (is_moving && (drawflags & MAN_ROT_X))) {
preOrthoFront(ortho, rv3d->twmat, 0);
manipulator_setcolor(v3d, 'Y', colcode, 255);
glBegin(GL_LINES);
@@ -1047,7 +1046,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
glEnd();
postOrtho(ortho);
}
- if ((drawflags & MAN_ROT_Z) || (moving && (drawflags & MAN_ROT_Y))) {
+ if ((drawflags & MAN_ROT_Z) || (is_moving && (drawflags & MAN_ROT_Y))) {
preOrthoFront(ortho, rv3d->twmat, 1);
manipulator_setcolor(v3d, 'Z', colcode, 255);
glBegin(GL_LINES);
@@ -1060,12 +1059,12 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
}
}
- if (arcs == 0 && moving) {
+ if (arcs == 0 && is_moving) {
/* Z circle */
if (drawflags & MAN_ROT_Z) {
preOrthoFront(ortho, matt, 2);
- if (G.f & G_PICKSEL) glLoadName(MAN_ROT_Z);
+ if (is_picksel) glLoadName(MAN_ROT_Z);
manipulator_setcolor(v3d, 'Z', colcode, 255);
drawcircball(GL_LINE_LOOP, unitmat[3], 1.0, unitmat);
postOrtho(ortho);
@@ -1073,7 +1072,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
/* X circle */
if (drawflags & MAN_ROT_X) {
preOrthoFront(ortho, matt, 0);
- if (G.f & G_PICKSEL) glLoadName(MAN_ROT_X);
+ if (is_picksel) glLoadName(MAN_ROT_X);
glRotatef(90.0, 0.0, 1.0, 0.0);
manipulator_setcolor(v3d, 'X', colcode, 255);
drawcircball(GL_LINE_LOOP, unitmat[3], 1.0, unitmat);
@@ -1083,7 +1082,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
/* Y circle */
if (drawflags & MAN_ROT_Y) {
preOrthoFront(ortho, matt, 1);
- if (G.f & G_PICKSEL) glLoadName(MAN_ROT_Y);
+ if (is_picksel) glLoadName(MAN_ROT_Y);
glRotatef(-90.0, 1.0, 0.0, 0.0);
manipulator_setcolor(v3d, 'Y', colcode, 255);
drawcircball(GL_LINE_LOOP, unitmat[3], 1.0, unitmat);
@@ -1100,7 +1099,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
/* Z circle */
if (drawflags & MAN_ROT_Z) {
preOrthoFront(ortho, rv3d->twmat, 2);
- if (G.f & G_PICKSEL) glLoadName(MAN_ROT_Z);
+ if (is_picksel) glLoadName(MAN_ROT_Z);
manipulator_setcolor(v3d, 'Z', colcode, 255);
partial_doughnut(cusize / 4.0f, 1.0f, 0, 48, 8, 48);
postOrtho(ortho);
@@ -1108,7 +1107,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
/* X circle */
if (drawflags & MAN_ROT_X) {
preOrthoFront(ortho, rv3d->twmat, 0);
- if (G.f & G_PICKSEL) glLoadName(MAN_ROT_X);
+ if (is_picksel) glLoadName(MAN_ROT_X);
glRotatef(90.0, 0.0, 1.0, 0.0);
manipulator_setcolor(v3d, 'X', colcode, 255);
partial_doughnut(cusize / 4.0f, 1.0f, 0, 48, 8, 48);
@@ -1118,7 +1117,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
/* Y circle */
if (drawflags & MAN_ROT_Y) {
preOrthoFront(ortho, rv3d->twmat, 1);
- if (G.f & G_PICKSEL) glLoadName(MAN_ROT_Y);
+ if (is_picksel) glLoadName(MAN_ROT_Y);
glRotatef(-90.0, 1.0, 0.0, 0.0);
manipulator_setcolor(v3d, 'Y', colcode, 255);
partial_doughnut(cusize / 4.0f, 1.0f, 0, 48, 8, 48);
@@ -1135,7 +1134,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
if (drawflags & MAN_ROT_Z) {
preOrthoFront(ortho, rv3d->twmat, 2);
glPushMatrix();
- if (G.f & G_PICKSEL) glLoadName(MAN_ROT_Z);
+ if (is_picksel) glLoadName(MAN_ROT_Z);
manipulator_setcolor(v3d, 'Z', colcode, 255);
partial_doughnut(0.7f * cusize, 1.0f, 31, 33, 8, 64);
@@ -1148,7 +1147,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
if (drawflags & MAN_ROT_Y) {
preOrthoFront(ortho, rv3d->twmat, 1);
glPushMatrix();
- if (G.f & G_PICKSEL) glLoadName(MAN_ROT_Y);
+ if (is_picksel) glLoadName(MAN_ROT_Y);
manipulator_setcolor(v3d, 'Y', colcode, 255);
glRotatef(90.0, 1.0, 0.0, 0.0);
@@ -1163,7 +1162,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
if (drawflags & MAN_ROT_X) {
preOrthoFront(ortho, rv3d->twmat, 0);
glPushMatrix();
- if (G.f & G_PICKSEL) glLoadName(MAN_ROT_X);
+ if (is_picksel) glLoadName(MAN_ROT_X);
manipulator_setcolor(v3d, 'X', colcode, 255);
glRotatef(-90.0, 0.0, 1.0, 0.0);
@@ -1244,7 +1243,9 @@ static void drawsolidcube(float size)
}
-static void draw_manipulator_scale(View3D *v3d, RegionView3D *rv3d, int moving, int drawflags, int combo, int colcode)
+static void draw_manipulator_scale(
+ View3D *v3d, RegionView3D *rv3d, const int drawflags, const int combo, const int colcode,
+ const bool is_moving, const bool is_picksel)
{
float cywid = 0.25f * 0.01f * (float)U.tw_handlesize;
float cusize = cywid * 0.75f, dz;
@@ -1264,7 +1265,7 @@ static void draw_manipulator_scale(View3D *v3d, RegionView3D *rv3d, int moving,
int shift = 0; // XXX
/* center circle, do not add to selection when shift is pressed (planar constraint) */
- if ((G.f & G_PICKSEL) && shift == 0) glLoadName(MAN_SCALE_C);
+ if (is_picksel && shift == 0) glLoadName(MAN_SCALE_C);
manipulator_setcolor(v3d, 'C', colcode, 255);
glPushMatrix();
@@ -1279,7 +1280,7 @@ static void draw_manipulator_scale(View3D *v3d, RegionView3D *rv3d, int moving,
dz = 1.0f - 4.0f * cusize;
}
- if (moving) {
+ if (is_moving) {
float matt[4][4];
copy_m4_m4(matt, rv3d->twmat); // to copy the parts outside of [3][3]
@@ -1305,7 +1306,7 @@ static void draw_manipulator_scale(View3D *v3d, RegionView3D *rv3d, int moving,
case 0: /* X cube */
if (drawflags & MAN_SCALE_X) {
glTranslatef(dz, 0.0, 0.0);
- if (G.f & G_PICKSEL) glLoadName(MAN_SCALE_X);
+ if (is_picksel) glLoadName(MAN_SCALE_X);
manipulator_setcolor(v3d, 'X', colcode, axisBlendAngle(rv3d->twangle[0]));
drawsolidcube(cusize);
glTranslatef(-dz, 0.0, 0.0);
@@ -1314,7 +1315,7 @@ static void draw_manipulator_scale(View3D *v3d, RegionView3D *rv3d, int moving,
case 1: /* Y cube */
if (drawflags & MAN_SCALE_Y) {
glTranslatef(0.0, dz, 0.0);
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list