Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_manipulator.c
| Show First 20 Lines • Show All 270 Lines • ▼ Show 20 Lines | static int calc_manipulator_stats(const bContext *C) | ||||
| Base *base; | Base *base; | ||||
| Object *ob = OBACT; | Object *ob = OBACT; | ||||
| bGPdata *gpd = CTX_data_gpencil_data(C); | bGPdata *gpd = CTX_data_gpencil_data(C); | ||||
| const bool is_gp_edit = ((gpd) && (gpd->flag & GP_DATA_STROKE_EDITMODE)); | const bool is_gp_edit = ((gpd) && (gpd->flag & GP_DATA_STROKE_EDITMODE)); | ||||
| int a, totsel = 0; | int a, totsel = 0; | ||||
| /* transform widget matrix */ | /* transform widget matrix */ | ||||
| unit_m4(rv3d->twmat); | unit_m4(rv3d->twmat); | ||||
| unit_m4(rv3d->twmattrans); | |||||
| unit_m4(rv3d->twmatrots); | |||||
| unit_m4(rv3d->twmatscale); | |||||
| rv3d->twdrawflag = 0xFFFF; | rv3d->twdrawflag = 0xFFFF; | ||||
| /* transform widget centroid/center */ | /* transform widget centroid/center */ | ||||
| INIT_MINMAX(scene->twmin, scene->twmax); | INIT_MINMAX(scene->twmin, scene->twmax); | ||||
| zero_v3(scene->twcent); | zero_v3(scene->twcent); | ||||
| if (is_gp_edit) { | if (is_gp_edit) { | ||||
| ▲ Show 20 Lines • Show All 364 Lines • ▼ Show 20 Lines | switch (v3d->twmode) { | ||||
| case V3D_MANIP_VIEW: | case V3D_MANIP_VIEW: | ||||
| { | { | ||||
| float mat[3][3]; | float mat[3][3]; | ||||
| copy_m3_m4(mat, rv3d->viewinv); | copy_m3_m4(mat, rv3d->viewinv); | ||||
| normalize_m3(mat); | normalize_m3(mat); | ||||
| copy_m4_m3(rv3d->twmat, mat); | copy_m4_m3(rv3d->twmat, mat); | ||||
| break; | break; | ||||
| } | } | ||||
| // V3D_MANIP_MULTI_TRANSF - allows for users to set different orientations to different transformations simulataneously | |||||
| case V3D_MANIP_MULTI_TRANSF: | |||||
| { | |||||
| /* Set up the twtype so that all transformations are automatically set */ | |||||
| v3d->twtype = V3D_MANIP_TRANSLATE | V3D_MANIP_ROTATE | V3D_MANIP_SCALE; | |||||
| char types_tranf[] = { v3d->twtrans, v3d->twrots, v3d->twscale }; | |||||
| float *mtx_tranf[3]; | |||||
swerner: I see compiler warnings in all lines using mtx_tranf. It is an array of float*, where all the… | |||||
| mtx_tranf[0] = rv3d->twmattrans; | |||||
| mtx_tranf[1] = rv3d->twmatrots; | |||||
| mtx_tranf[2] = rv3d->twmatscale; | |||||
| for (int i = 0; i < 3; i++) | |||||
| { | |||||
| switch (types_tranf[i]) | |||||
| { | |||||
| case V3D_MANIP_GLOBAL: | |||||
| { | |||||
| break; /* nothing to do */ | |||||
| } | |||||
| case V3D_MANIP_GIMBAL: | |||||
| { | |||||
| float mat[3][3]; | |||||
| if (gimbal_axis(ob, mat)) { | |||||
| copy_m4_m3(mtx_tranf[i], mat); | |||||
| break; | |||||
| } | |||||
| /* if not gimbal, fall through to normal */ | |||||
| /* fall-through */ | |||||
| } | |||||
| case V3D_MANIP_NORMAL: | |||||
| { | |||||
| if (obedit || ob->mode & OB_MODE_POSE) { | |||||
| float mat[3][3]; | |||||
| ED_getTransformOrientationMatrix(C, mat, v3d->around); | |||||
| copy_m4_m3(mtx_tranf[i], mat); | |||||
| break; | |||||
| } | |||||
| /* no break we define 'normal' as 'local' in Object mode */ | |||||
| /* fall-through */ | |||||
| } | |||||
| case V3D_MANIP_LOCAL: | |||||
| { | |||||
| if (ob->mode & OB_MODE_POSE) { | |||||
| /* each bone moves on its own local axis, but to avoid confusion, | |||||
| * use the active pones axis for display [#33575], this works as expected on a single bone | |||||
| * and users who select many bones will understand whats going on and what local means | |||||
| * when they start transforming */ | |||||
| float mat[3][3]; | |||||
| ED_getTransformOrientationMatrix(C, mat, v3d->around); | |||||
| copy_m4_m3(mtx_tranf[i], mat); | |||||
| break; | |||||
| } | |||||
| copy_m4_m4(mtx_tranf[i], ob->obmat); | |||||
| normalize_m4(mtx_tranf[i]); | |||||
| break; | |||||
| } | |||||
| case V3D_MANIP_VIEW: | |||||
| { | |||||
| float mat[3][3]; | |||||
| copy_m3_m4(mat, rv3d->viewinv); | |||||
| normalize_m3(mat); | |||||
| copy_m4_m3(mtx_tranf[i], mat); | |||||
| break; | |||||
| } | |||||
| } | |||||
| } | |||||
| break; | |||||
| } | |||||
| default: /* V3D_MANIP_CUSTOM */ | default: /* V3D_MANIP_CUSTOM */ | ||||
| { | { | ||||
| float mat[3][3]; | float mat[3][3]; | ||||
| if (applyTransformOrientation(C, mat, NULL, v3d->twmode - V3D_MANIP_CUSTOM)) { | if (applyTransformOrientation(C, mat, NULL, v3d->twmode - V3D_MANIP_CUSTOM)) { | ||||
| copy_m4_m3(rv3d->twmat, mat); | copy_m4_m3(rv3d->twmat, mat); | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return totsel; | return totsel; | ||||
| } | } | ||||
| /* don't draw axis perpendicular to the view */ | /* don't draw axis perpendicular to the view */ | ||||
| static void test_manipulator_axis(const bContext *C) | static void test_manipulator_axis(const bContext *C) | ||||
| { | { | ||||
| RegionView3D *rv3d = CTX_wm_region_view3d(C); | RegionView3D *rv3d = CTX_wm_region_view3d(C); | ||||
| ScrArea *sa = CTX_wm_area(C); | |||||
| View3D *v3d = sa->spacedata.first; | |||||
| float view_vec[3], axis_vec[3]; | float view_vec[3], axis_vec[3]; | ||||
| float idot; | float idot; | ||||
| int i; | int i; | ||||
| const int twdrawflag_axis[3] = { | const int twdrawflag_axis[3] = { | ||||
| (MAN_TRANS_X | MAN_SCALE_X), | (MAN_TRANS_X | MAN_SCALE_X), | ||||
| (MAN_TRANS_Y | MAN_SCALE_Y), | (MAN_TRANS_Y | MAN_SCALE_Y), | ||||
| (MAN_TRANS_Z | MAN_SCALE_Z)}; | (MAN_TRANS_Z | MAN_SCALE_Z)}; | ||||
| ED_view3d_global_to_vector(rv3d, rv3d->twmat[3], view_vec); | ED_view3d_global_to_vector(rv3d, rv3d->twmat[3], view_vec); | ||||
| for (i = 0; i < 3; i++) { | for (i = 0; i < 3; i++) { | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| normalize_v3_v3(axis_vec, rv3d->twmat[i]); | normalize_v3_v3(axis_vec, rv3d->twmat[i]); | ||||
| else | |||||
| normalize_v3_v3(axis_vec, rv3d->twmattrans[i]); | |||||
| rv3d->tw_idot[i] = idot = 1.0f - fabsf(dot_v3v3(view_vec, axis_vec)); | rv3d->tw_idot[i] = idot = 1.0f - fabsf(dot_v3v3(view_vec, axis_vec)); | ||||
| if (idot < TW_AXIS_DOT_MIN) { | if (idot < TW_AXIS_DOT_MIN) { | ||||
| rv3d->twdrawflag &= ~twdrawflag_axis[i]; | rv3d->twdrawflag &= ~twdrawflag_axis[i]; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | static void manipulator_axis_order(RegionView3D *rv3d, int r_axis_order[3]) | ||||
| axis_values[0] = -dot_v3v3(rv3d->twmat[0], vec); | axis_values[0] = -dot_v3v3(rv3d->twmat[0], vec); | ||||
| axis_values[1] = -dot_v3v3(rv3d->twmat[1], vec); | axis_values[1] = -dot_v3v3(rv3d->twmat[1], vec); | ||||
| axis_values[2] = -dot_v3v3(rv3d->twmat[2], vec); | axis_values[2] = -dot_v3v3(rv3d->twmat[2], vec); | ||||
| axis_sort_v3(axis_values, r_axis_order); | axis_sort_v3(axis_values, r_axis_order); | ||||
| } | } | ||||
| static void manipulator_axis_order_custom(RegionView3D *rv3d, float transmtx[4][4], int r_axis_order[3]) | |||||
| { | |||||
| float axis_values[3]; | |||||
| float vec[3]; | |||||
| ED_view3d_global_to_vector(rv3d, transmtx[3], vec); | |||||
| axis_values[0] = -dot_v3v3(transmtx[0], vec); | |||||
| axis_values[1] = -dot_v3v3(transmtx[1], vec); | |||||
| axis_values[2] = -dot_v3v3(transmtx[2], vec); | |||||
| axis_sort_v3(axis_values, r_axis_order); | |||||
| } | |||||
| /* viewmatrix should have been set OK, also no shademode! */ | /* viewmatrix should have been set OK, also no shademode! */ | ||||
| static void draw_manipulator_axes_single(View3D *v3d, RegionView3D *rv3d, int colcode, | static void draw_manipulator_axes_single(View3D *v3d, RegionView3D *rv3d, int colcode, | ||||
| int flagx, int flagy, int flagz, int axis, | int flagx, int flagy, int flagz, int axis, | ||||
| const bool is_picksel) | const bool is_picksel) | ||||
| { | { | ||||
| switch (axis) { | switch (axis) { | ||||
| case 0: | case 0: | ||||
| /* axes */ | /* axes */ | ||||
| ▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| return (drawflags & (MAN_ROT_X | MAN_ROT_Y | MAN_ROT_Z)); | return (drawflags & (MAN_ROT_X | MAN_ROT_Y | MAN_ROT_Z)); | ||||
| } | } | ||||
| static void draw_manipulator_rotate( | static void draw_manipulator_rotate( | ||||
| View3D *v3d, RegionView3D *rv3d, const int drawflags, const int combo, | View3D *v3d, RegionView3D *rv3d, const int drawflags, const int combo, | ||||
| const bool is_moving, const bool is_picksel) | const bool is_moving, const bool is_picksel) | ||||
| { | { | ||||
| if (v3d->twmode == V3D_MANIP_MULTI_TRANSF && v3d->twrots == V3D_MANIP_NONE) | |||||
| return; | |||||
| double plane[4]; | double plane[4]; | ||||
| float matt[4][4]; | float matt[4][4]; | ||||
| float size, unitmat[4][4]; | float size, unitmat[4][4]; | ||||
| float cywid = 0.33f * 0.01f * (float)U.tw_handlesize; | float cywid = 0.33f * 0.01f * (float)U.tw_handlesize; | ||||
| float cusize = cywid * 0.65f; | float cusize = cywid * 0.65f; | ||||
| int arcs = (G.debug_value != 2); | int arcs = (G.debug_value != 2); | ||||
| const int colcode = (is_moving) ? MAN_MOVECOL : MAN_RGB; | const int colcode = (is_moving) ? MAN_MOVECOL : MAN_RGB; | ||||
| bool ortho; | bool ortho; | ||||
| /* skip drawing if all axes are locked */ | /* skip drawing if all axes are locked */ | ||||
| if (manipulator_rotate_is_visible(drawflags) == false) return; | if (manipulator_rotate_is_visible(drawflags) == false) return; | ||||
| /* Init stuff */ | /* Init stuff */ | ||||
| glDisable(GL_DEPTH_TEST); | glDisable(GL_DEPTH_TEST); | ||||
| unit_m4(unitmat); | unit_m4(unitmat); | ||||
| /* prepare for screen aligned draw */ | /* prepare for screen aligned draw */ | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| size = len_v3(rv3d->twmat[0]); | size = len_v3(rv3d->twmat[0]); | ||||
| else | |||||
| size = len_v3(rv3d->twmatrots[0]); | |||||
| glPushMatrix(); | glPushMatrix(); | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| glTranslate3fv(rv3d->twmat[3]); | glTranslate3fv(rv3d->twmat[3]); | ||||
| else | |||||
| glTranslate3fv(rv3d->twmatrots[3]); | |||||
| if (arcs) { | if (arcs) { | ||||
| /* clipplane makes nice handles, calc here because of multmatrix but with translate! */ | /* clipplane makes nice handles, calc here because of multmatrix but with translate! */ | ||||
| copy_v3db_v3fl(plane, rv3d->viewinv[2]); | copy_v3db_v3fl(plane, rv3d->viewinv[2]); | ||||
| plane[3] = -0.02f * size; // clip just a bit more | plane[3] = -0.02f * size; // clip just a bit more | ||||
| glClipPlane(GL_CLIP_PLANE0, plane); | glClipPlane(GL_CLIP_PLANE0, plane); | ||||
| } | } | ||||
| /* sets view screen aligned */ | /* sets view screen aligned */ | ||||
| Show All 30 Lines | if (is_moving) { | ||||
| glBegin(GL_LINES); | glBegin(GL_LINES); | ||||
| glVertex3f(0.0f, 0.0f, 0.0f); | glVertex3f(0.0f, 0.0f, 0.0f); | ||||
| glVertex3fv(vec); | glVertex3fv(vec); | ||||
| glEnd(); | glEnd(); | ||||
| } | } | ||||
| } | } | ||||
| glPopMatrix(); | glPopMatrix(); | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| ortho = is_orthogonal_m4(rv3d->twmat); | ortho = is_orthogonal_m4(rv3d->twmat); | ||||
| else | |||||
| ortho = is_orthogonal_m4(rv3d->twmatrots); | |||||
| /* apply the transform delta */ | /* apply the transform delta */ | ||||
| if (is_moving) { | if (is_moving) { | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| copy_m4_m4(matt, rv3d->twmat); // to copy the parts outside of [3][3] | copy_m4_m4(matt, rv3d->twmat); // to copy the parts outside of [3][3] | ||||
| else | |||||
| copy_m4_m4(matt, rv3d->twmatrots); // to copy the parts outside of [3][3] | |||||
| // XXX mul_m4_m3m4(matt, t->mat, rv3d->twmat); | // XXX mul_m4_m3m4(matt, t->mat, rv3d->twmat); | ||||
| if (ortho) { | if (ortho) { | ||||
| glMultMatrixf(matt); | glMultMatrixf(matt); | ||||
| glFrontFace(is_negative_m4(matt) ? GL_CW : GL_CCW); | glFrontFace(is_negative_m4(matt) ? GL_CW : GL_CCW); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| if (ortho) { | if (ortho) { | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) { | |||||
| glFrontFace(is_negative_m4(rv3d->twmat) ? GL_CW : GL_CCW); | glFrontFace(is_negative_m4(rv3d->twmat) ? GL_CW : GL_CCW); | ||||
| glMultMatrixf(rv3d->twmat); | glMultMatrixf(rv3d->twmat); | ||||
| } | } | ||||
| else { | |||||
| glFrontFace(is_negative_m4(rv3d->twmatrots) ? GL_CW : GL_CCW); | |||||
| glMultMatrixf(rv3d->twmatrots); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| /* axes */ | /* axes */ | ||||
| if (arcs == 0) { | if (arcs == 0) { | ||||
| if (!is_picksel) { | if (!is_picksel) { | ||||
| if ((combo & V3D_MANIP_SCALE) == 0) { | if ((combo & V3D_MANIP_SCALE) == 0) { | ||||
| /* axis */ | /* axis */ | ||||
| if ((drawflags & MAN_ROT_X) || (is_moving && (drawflags & MAN_ROT_Z))) { | if ((drawflags & MAN_ROT_X) || (is_moving && (drawflags & MAN_ROT_Z))) { | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| preOrthoFront(ortho, rv3d->twmat, 2); | preOrthoFront(ortho, rv3d->twmat, 2); | ||||
| else | |||||
| preOrthoFront(ortho, rv3d->twmatrots, 2); | |||||
| manipulator_setcolor(v3d, 'X', colcode, 255); | manipulator_setcolor(v3d, 'X', colcode, 255); | ||||
| glBegin(GL_LINES); | glBegin(GL_LINES); | ||||
| glVertex3f(0.2f, 0.0f, 0.0f); | glVertex3f(0.2f, 0.0f, 0.0f); | ||||
| glVertex3f(1.0f, 0.0f, 0.0f); | glVertex3f(1.0f, 0.0f, 0.0f); | ||||
| glEnd(); | glEnd(); | ||||
| postOrtho(ortho); | postOrtho(ortho); | ||||
| } | } | ||||
| if ((drawflags & MAN_ROT_Y) || (is_moving && (drawflags & MAN_ROT_X))) { | if ((drawflags & MAN_ROT_Y) || (is_moving && (drawflags & MAN_ROT_X))) { | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| preOrthoFront(ortho, rv3d->twmat, 0); | preOrthoFront(ortho, rv3d->twmat, 0); | ||||
| else | |||||
| preOrthoFront(ortho, rv3d->twmatrots, 0); | |||||
| manipulator_setcolor(v3d, 'Y', colcode, 255); | manipulator_setcolor(v3d, 'Y', colcode, 255); | ||||
| glBegin(GL_LINES); | glBegin(GL_LINES); | ||||
| glVertex3f(0.0f, 0.2f, 0.0f); | glVertex3f(0.0f, 0.2f, 0.0f); | ||||
| glVertex3f(0.0f, 1.0f, 0.0f); | glVertex3f(0.0f, 1.0f, 0.0f); | ||||
| glEnd(); | glEnd(); | ||||
| postOrtho(ortho); | postOrtho(ortho); | ||||
| } | } | ||||
| if ((drawflags & MAN_ROT_Z) || (is_moving && (drawflags & MAN_ROT_Y))) { | if ((drawflags & MAN_ROT_Z) || (is_moving && (drawflags & MAN_ROT_Y))) { | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| preOrthoFront(ortho, rv3d->twmat, 1); | preOrthoFront(ortho, rv3d->twmat, 1); | ||||
| else | |||||
| preOrthoFront(ortho, rv3d->twmatrots, 1); | |||||
| manipulator_setcolor(v3d, 'Z', colcode, 255); | manipulator_setcolor(v3d, 'Z', colcode, 255); | ||||
| glBegin(GL_LINES); | glBegin(GL_LINES); | ||||
| glVertex3f(0.0f, 0.0f, 0.2f); | glVertex3f(0.0f, 0.0f, 0.2f); | ||||
| glVertex3f(0.0f, 0.0f, 1.0f); | glVertex3f(0.0f, 0.0f, 1.0f); | ||||
| glEnd(); | glEnd(); | ||||
| postOrtho(ortho); | postOrtho(ortho); | ||||
| } | } | ||||
| } | } | ||||
| Show All 32 Lines | if (arcs == 0 && is_moving) { | ||||
| } | } | ||||
| } | } | ||||
| // donut arcs | // donut arcs | ||||
| if (arcs) { | if (arcs) { | ||||
| glEnable(GL_CLIP_PLANE0); | glEnable(GL_CLIP_PLANE0); | ||||
| /* Z circle */ | /* Z circle */ | ||||
| if (drawflags & MAN_ROT_Z) { | if (drawflags & MAN_ROT_Z) { | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| preOrthoFront(ortho, rv3d->twmat, 2); | preOrthoFront(ortho, rv3d->twmat, 2); | ||||
| else | |||||
| preOrthoFront(ortho, rv3d->twmatrots, 2); | |||||
| if (is_picksel) GPU_select_load_id(MAN_ROT_Z); | if (is_picksel) GPU_select_load_id(MAN_ROT_Z); | ||||
| else manipulator_setcolor(v3d, 'Z', colcode, 255); | else manipulator_setcolor(v3d, 'Z', colcode, 255); | ||||
| partial_doughnut(cusize / 4.0f, 1.0f, 0, 48, 8, 48); | partial_doughnut(cusize / 4.0f, 1.0f, 0, 48, 8, 48); | ||||
| postOrtho(ortho); | postOrtho(ortho); | ||||
| } | } | ||||
| /* X circle */ | /* X circle */ | ||||
| if (drawflags & MAN_ROT_X) { | if (drawflags & MAN_ROT_X) { | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| preOrthoFront(ortho, rv3d->twmat, 0); | preOrthoFront(ortho, rv3d->twmat, 0); | ||||
| else | |||||
| preOrthoFront(ortho, rv3d->twmatrots, 0); | |||||
| if (is_picksel) GPU_select_load_id(MAN_ROT_X); | if (is_picksel) GPU_select_load_id(MAN_ROT_X); | ||||
| else manipulator_setcolor(v3d, 'X', colcode, 255); | else manipulator_setcolor(v3d, 'X', colcode, 255); | ||||
| glRotatef(90.0, 0.0, 1.0, 0.0); | glRotatef(90.0, 0.0, 1.0, 0.0); | ||||
| partial_doughnut(cusize / 4.0f, 1.0f, 0, 48, 8, 48); | partial_doughnut(cusize / 4.0f, 1.0f, 0, 48, 8, 48); | ||||
| glRotatef(-90.0, 0.0, 1.0, 0.0); | glRotatef(-90.0, 0.0, 1.0, 0.0); | ||||
| postOrtho(ortho); | postOrtho(ortho); | ||||
| } | } | ||||
| /* Y circle */ | /* Y circle */ | ||||
| if (drawflags & MAN_ROT_Y) { | if (drawflags & MAN_ROT_Y) { | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| preOrthoFront(ortho, rv3d->twmat, 1); | preOrthoFront(ortho, rv3d->twmat, 1); | ||||
| else | |||||
| preOrthoFront(ortho, rv3d->twmatrots, 1); | |||||
| if (is_picksel) GPU_select_load_id(MAN_ROT_Y); | if (is_picksel) GPU_select_load_id(MAN_ROT_Y); | ||||
| else manipulator_setcolor(v3d, 'Y', colcode, 255); | else manipulator_setcolor(v3d, 'Y', colcode, 255); | ||||
| glRotatef(-90.0, 1.0, 0.0, 0.0); | glRotatef(-90.0, 1.0, 0.0, 0.0); | ||||
| partial_doughnut(cusize / 4.0f, 1.0f, 0, 48, 8, 48); | partial_doughnut(cusize / 4.0f, 1.0f, 0, 48, 8, 48); | ||||
| glRotatef(90.0, 1.0, 0.0, 0.0); | glRotatef(90.0, 1.0, 0.0, 0.0); | ||||
| postOrtho(ortho); | postOrtho(ortho); | ||||
| } | } | ||||
| glDisable(GL_CLIP_PLANE0); | glDisable(GL_CLIP_PLANE0); | ||||
| } | } | ||||
| if (arcs == 0) { | if (arcs == 0) { | ||||
| /* Z handle on X axis */ | /* Z handle on X axis */ | ||||
| if (drawflags & MAN_ROT_Z) { | if (drawflags & MAN_ROT_Z) { | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| preOrthoFront(ortho, rv3d->twmat, 2); | preOrthoFront(ortho, rv3d->twmat, 2); | ||||
| else | |||||
| preOrthoFront(ortho, rv3d->twmatrots, 2); | |||||
| glPushMatrix(); | glPushMatrix(); | ||||
| if (is_picksel) GPU_select_load_id(MAN_ROT_Z); | if (is_picksel) GPU_select_load_id(MAN_ROT_Z); | ||||
| else manipulator_setcolor(v3d, 'Z', colcode, 255); | else manipulator_setcolor(v3d, 'Z', colcode, 255); | ||||
| partial_doughnut(0.7f * cusize, 1.0f, 31, 33, 8, 64); | partial_doughnut(0.7f * cusize, 1.0f, 31, 33, 8, 64); | ||||
| glPopMatrix(); | glPopMatrix(); | ||||
| postOrtho(ortho); | postOrtho(ortho); | ||||
| } | } | ||||
| /* Y handle on X axis */ | /* Y handle on X axis */ | ||||
| if (drawflags & MAN_ROT_Y) { | if (drawflags & MAN_ROT_Y) { | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| preOrthoFront(ortho, rv3d->twmat, 1); | preOrthoFront(ortho, rv3d->twmat, 1); | ||||
| else | |||||
| preOrthoFront(ortho, rv3d->twmatrots, 1); | |||||
| glPushMatrix(); | glPushMatrix(); | ||||
| if (is_picksel) GPU_select_load_id(MAN_ROT_Y); | if (is_picksel) GPU_select_load_id(MAN_ROT_Y); | ||||
| else manipulator_setcolor(v3d, 'Y', colcode, 255); | else manipulator_setcolor(v3d, 'Y', colcode, 255); | ||||
| glRotatef(90.0, 1.0, 0.0, 0.0); | glRotatef(90.0, 1.0, 0.0, 0.0); | ||||
| glRotatef(90.0, 0.0, 0.0, 1.0); | glRotatef(90.0, 0.0, 0.0, 1.0); | ||||
| partial_doughnut(0.7f * cusize, 1.0f, 31, 33, 8, 64); | partial_doughnut(0.7f * cusize, 1.0f, 31, 33, 8, 64); | ||||
| glPopMatrix(); | glPopMatrix(); | ||||
| postOrtho(ortho); | postOrtho(ortho); | ||||
| } | } | ||||
| /* X handle on Z axis */ | /* X handle on Z axis */ | ||||
| if (drawflags & MAN_ROT_X) { | if (drawflags & MAN_ROT_X) { | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| preOrthoFront(ortho, rv3d->twmat, 0); | preOrthoFront(ortho, rv3d->twmat, 0); | ||||
| else | |||||
| preOrthoFront(ortho, rv3d->twmatrots, 0); | |||||
| glPushMatrix(); | glPushMatrix(); | ||||
| if (is_picksel) GPU_select_load_id(MAN_ROT_X); | if (is_picksel) GPU_select_load_id(MAN_ROT_X); | ||||
| else manipulator_setcolor(v3d, 'X', colcode, 255); | else manipulator_setcolor(v3d, 'X', colcode, 255); | ||||
| glRotatef(-90.0, 0.0, 1.0, 0.0); | glRotatef(-90.0, 0.0, 1.0, 0.0); | ||||
| glRotatef(90.0, 0.0, 0.0, 1.0); | glRotatef(90.0, 0.0, 0.0, 1.0); | ||||
| partial_doughnut(0.7f * cusize, 1.0f, 31, 33, 8, 64); | partial_doughnut(0.7f * cusize, 1.0f, 31, 33, 8, 64); | ||||
| ▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | static void drawsolidcube(float size) | ||||
| glPopMatrix(); | glPopMatrix(); | ||||
| } | } | ||||
| static void draw_manipulator_scale( | static void draw_manipulator_scale( | ||||
| View3D *v3d, RegionView3D *rv3d, const int drawflags, const int combo, const int colcode, | View3D *v3d, RegionView3D *rv3d, const int drawflags, const int combo, const int colcode, | ||||
| const bool is_moving, const bool is_picksel) | const bool is_moving, const bool is_picksel) | ||||
| { | { | ||||
| if (v3d->twmode == V3D_MANIP_MULTI_TRANSF && v3d->twscale == V3D_MANIP_NONE) | |||||
| return; | |||||
| float cywid = 0.25f * 0.01f * (float)U.tw_handlesize; | float cywid = 0.25f * 0.01f * (float)U.tw_handlesize; | ||||
| float cusize = cywid * 0.75f, dz; | float cusize = cywid * 0.75f, dz; | ||||
| int axis_order[3] = {2, 0, 1}; | int axis_order[3] = {2, 0, 1}; | ||||
| int i; | int i; | ||||
| /* when called while moving in mixed mode, do not draw when... */ | /* when called while moving in mixed mode, do not draw when... */ | ||||
| if ((drawflags & MAN_SCALE_C) == 0) return; | if ((drawflags & MAN_SCALE_C) == 0) return; | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| manipulator_axis_order(rv3d, axis_order); | manipulator_axis_order(rv3d, axis_order); | ||||
| else | |||||
| manipulator_axis_order_custom(rv3d, rv3d->twmatscale, axis_order); | |||||
| glDisable(GL_DEPTH_TEST); | glDisable(GL_DEPTH_TEST); | ||||
| /* not in combo mode */ | /* not in combo mode */ | ||||
| if ((combo & (V3D_MANIP_TRANSLATE | V3D_MANIP_ROTATE)) == 0) { | if ((combo & (V3D_MANIP_TRANSLATE | V3D_MANIP_ROTATE)) == 0) { | ||||
| float size, unitmat[4][4]; | float size, unitmat[4][4]; | ||||
| int shift = 0; // XXX | int shift = 0; // XXX | ||||
| /* center circle, do not add to selection when shift is pressed (planar constraint) */ | /* center circle, do not add to selection when shift is pressed (planar constraint) */ | ||||
| if (is_picksel && shift == 0) GPU_select_load_id(MAN_SCALE_C); | if (is_picksel && shift == 0) GPU_select_load_id(MAN_SCALE_C); | ||||
| else manipulator_setcolor(v3d, 'C', colcode, 255); | else manipulator_setcolor(v3d, 'C', colcode, 255); | ||||
| glPushMatrix(); | glPushMatrix(); | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| size = screen_aligned(rv3d, rv3d->twmat); | size = screen_aligned(rv3d, rv3d->twmat); | ||||
| else | |||||
| size = screen_aligned(rv3d, rv3d->twmatscale); | |||||
| unit_m4(unitmat); | unit_m4(unitmat); | ||||
| drawcircball(GL_LINE_LOOP, unitmat[3], 0.2f * size, unitmat); | drawcircball(GL_LINE_LOOP, unitmat[3], 0.2f * size, unitmat); | ||||
| glPopMatrix(); | glPopMatrix(); | ||||
| dz = 1.0; | dz = 1.0; | ||||
| } | } | ||||
| else { | else { | ||||
| dz = 1.0f - 4.0f * cusize; | dz = 1.0f - 4.0f * cusize; | ||||
| } | } | ||||
| if (is_moving) { | if (is_moving) { | ||||
| float matt[4][4]; | float matt[4][4]; | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| copy_m4_m4(matt, rv3d->twmat); // to copy the parts outside of [3][3] | copy_m4_m4(matt, rv3d->twmat); // to copy the parts outside of [3][3] | ||||
| else | |||||
| copy_m4_m4(matt, rv3d->twmatscale); // to copy the parts outside of [3][3] | |||||
| // XXX mul_m4_m3m4(matt, t->mat, rv3d->twmat); | // XXX mul_m4_m3m4(matt, t->mat, rv3d->twmat); | ||||
| glMultMatrixf(matt); | glMultMatrixf(matt); | ||||
| glFrontFace(is_negative_m4(matt) ? GL_CW : GL_CCW); | glFrontFace(is_negative_m4(matt) ? GL_CW : GL_CCW); | ||||
| } | } | ||||
| else { | else { | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) { | |||||
| glMultMatrixf(rv3d->twmat); | glMultMatrixf(rv3d->twmat); | ||||
| glFrontFace(is_negative_m4(rv3d->twmat) ? GL_CW : GL_CCW); | glFrontFace(is_negative_m4(rv3d->twmat) ? GL_CW : GL_CCW); | ||||
| } | } | ||||
| else { | |||||
| glMultMatrixf(rv3d->twmatscale); | |||||
| glFrontFace(is_negative_m4(rv3d->twmatscale) ? GL_CW : GL_CCW); | |||||
| } | |||||
| } | |||||
| /* axis */ | /* axis */ | ||||
| /* in combo mode, this is always drawn as first type */ | /* in combo mode, this is always drawn as first type */ | ||||
| draw_manipulator_axes(v3d, rv3d, colcode, | draw_manipulator_axes(v3d, rv3d, colcode, | ||||
| drawflags & MAN_SCALE_X, drawflags & MAN_SCALE_Y, drawflags & MAN_SCALE_Z, | drawflags & MAN_SCALE_X, drawflags & MAN_SCALE_Y, drawflags & MAN_SCALE_Z, | ||||
| axis_order, is_picksel); | axis_order, is_picksel); | ||||
| ▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | static void draw_cylinder(GLUquadricObj *qobj, float len, float width) | ||||
| glTranslatef(0.0, 0.0, -0.5f * len); | glTranslatef(0.0, 0.0, -0.5f * len); | ||||
| } | } | ||||
| static void draw_manipulator_translate( | static void draw_manipulator_translate( | ||||
| View3D *v3d, RegionView3D *rv3d, int drawflags, int combo, int colcode, | View3D *v3d, RegionView3D *rv3d, int drawflags, int combo, int colcode, | ||||
| const bool UNUSED(is_moving), const bool is_picksel) | const bool UNUSED(is_moving), const bool is_picksel) | ||||
| { | { | ||||
| if (v3d->twmode == V3D_MANIP_MULTI_TRANSF && v3d->twtrans == V3D_MANIP_NONE) | |||||
| return; | |||||
| GLUquadricObj *qobj; | GLUquadricObj *qobj; | ||||
| float cylen = 0.01f * (float)U.tw_handlesize; | float cylen = 0.01f * (float)U.tw_handlesize; | ||||
| float cywid = 0.25f * cylen, dz, size; | float cywid = 0.25f * cylen, dz, size; | ||||
| float unitmat[4][4]; | float unitmat[4][4]; | ||||
| int shift = 0; // XXX | int shift = 0; // XXX | ||||
| int axis_order[3] = {0, 1, 2}; | int axis_order[3] = {0, 1, 2}; | ||||
| int i; | int i; | ||||
| /* when called while moving in mixed mode, do not draw when... */ | /* when called while moving in mixed mode, do not draw when... */ | ||||
| if ((drawflags & MAN_TRANS_C) == 0) return; | if ((drawflags & MAN_TRANS_C) == 0) return; | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| manipulator_axis_order(rv3d, axis_order); | manipulator_axis_order(rv3d, axis_order); | ||||
| else | |||||
| manipulator_axis_order_custom(rv3d, rv3d->twmattrans, axis_order); | |||||
| // XXX if (moving) glTranslate3fv(t->vec); | // XXX if (moving) glTranslate3fv(t->vec); | ||||
| glDisable(GL_DEPTH_TEST); | glDisable(GL_DEPTH_TEST); | ||||
| /* center circle, do not add to selection when shift is pressed (planar constraint) */ | /* center circle, do not add to selection when shift is pressed (planar constraint) */ | ||||
| if (is_picksel && shift == 0) GPU_select_load_id(MAN_TRANS_C); | if (is_picksel && shift == 0) GPU_select_load_id(MAN_TRANS_C); | ||||
| else manipulator_setcolor(v3d, 'C', colcode, 255); | else manipulator_setcolor(v3d, 'C', colcode, 255); | ||||
| glPushMatrix(); | glPushMatrix(); | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| size = screen_aligned(rv3d, rv3d->twmat); | size = screen_aligned(rv3d, rv3d->twmat); | ||||
| else | |||||
| size = screen_aligned(rv3d, rv3d->twmattrans); | |||||
| unit_m4(unitmat); | unit_m4(unitmat); | ||||
| drawcircball(GL_LINE_LOOP, unitmat[3], 0.2f * size, unitmat); | drawcircball(GL_LINE_LOOP, unitmat[3], 0.2f * size, unitmat); | ||||
| glPopMatrix(); | glPopMatrix(); | ||||
| /* and now apply matrix, we move to local matrix drawing */ | /* and now apply matrix, we move to local matrix drawing */ | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| glMultMatrixf(rv3d->twmat); | glMultMatrixf(rv3d->twmat); | ||||
| else | |||||
| glMultMatrixf(rv3d->twmattrans); | |||||
| /* axis */ | /* axis */ | ||||
| GPU_select_load_id(-1); | GPU_select_load_id(-1); | ||||
| // translate drawn as last, only axis when no combo with scale, or for ghosting | // translate drawn as last, only axis when no combo with scale, or for ghosting | ||||
| if ((combo & V3D_MANIP_SCALE) == 0 || colcode == MAN_GHOST) { | if ((combo & V3D_MANIP_SCALE) == 0 || colcode == MAN_GHOST) { | ||||
| draw_manipulator_axes(v3d, rv3d, colcode, | draw_manipulator_axes(v3d, rv3d, colcode, | ||||
| drawflags & MAN_TRANS_X, drawflags & MAN_TRANS_Y, drawflags & MAN_TRANS_Z, | drawflags & MAN_TRANS_X, drawflags & MAN_TRANS_Y, drawflags & MAN_TRANS_Z, | ||||
| ▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | static void draw_manipulator_rotate_cyl( | ||||
| float cylen = 0.01f * (float)U.tw_handlesize; | float cylen = 0.01f * (float)U.tw_handlesize; | ||||
| float cywid = 0.25f * cylen; | float cywid = 0.25f * cylen; | ||||
| int axis_order[3] = {2, 0, 1}; | int axis_order[3] = {2, 0, 1}; | ||||
| int i; | int i; | ||||
| /* skip drawing if all axes are locked */ | /* skip drawing if all axes are locked */ | ||||
| if (manipulator_rotate_is_visible(drawflags) == false) return; | if (manipulator_rotate_is_visible(drawflags) == false) return; | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| manipulator_axis_order(rv3d, axis_order); | manipulator_axis_order(rv3d, axis_order); | ||||
| else | |||||
| manipulator_axis_order_custom(rv3d, rv3d->twmatrots, axis_order); | |||||
| /* prepare for screen aligned draw */ | /* prepare for screen aligned draw */ | ||||
| glPushMatrix(); | glPushMatrix(); | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| size = screen_aligned(rv3d, rv3d->twmat); | size = screen_aligned(rv3d, rv3d->twmat); | ||||
| else | |||||
| size = screen_aligned(rv3d, rv3d->twmatrots); | |||||
| glDisable(GL_DEPTH_TEST); | glDisable(GL_DEPTH_TEST); | ||||
| qobj = gluNewQuadric(); | qobj = gluNewQuadric(); | ||||
| /* Screen aligned view rot circle */ | /* Screen aligned view rot circle */ | ||||
| if (drawflags & MAN_ROT_V) { | if (drawflags & MAN_ROT_V) { | ||||
| float unitmat[4][4]; | float unitmat[4][4]; | ||||
| Show All 16 Lines | if (is_moving) { | ||||
| glEnd(); | glEnd(); | ||||
| } | } | ||||
| } | } | ||||
| glPopMatrix(); | glPopMatrix(); | ||||
| /* apply the transform delta */ | /* apply the transform delta */ | ||||
| if (is_moving) { | if (is_moving) { | ||||
| float matt[4][4]; | float matt[4][4]; | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| copy_m4_m4(matt, rv3d->twmat); // to copy the parts outside of [3][3] | copy_m4_m4(matt, rv3d->twmat); // to copy the parts outside of [3][3] | ||||
| else | |||||
| copy_m4_m4(matt, rv3d->twmatrots); // to copy the parts outside of [3][3] | |||||
| // XXX if (t->flag & T_USES_MANIPULATOR) { | // XXX if (t->flag & T_USES_MANIPULATOR) { | ||||
| // XXX mul_m4_m3m4(matt, t->mat, rv3d->twmat); | // XXX mul_m4_m3m4(matt, t->mat, rv3d->twmat); | ||||
| // XXX } | // XXX } | ||||
| glMultMatrixf(matt); | glMultMatrixf(matt); | ||||
| } | } | ||||
| else { | else { | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| glMultMatrixf(rv3d->twmat); | glMultMatrixf(rv3d->twmat); | ||||
| else | |||||
| glMultMatrixf(rv3d->twmatrots); | |||||
| } | } | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| glFrontFace(is_negative_m4(rv3d->twmat) ? GL_CW : GL_CCW); | glFrontFace(is_negative_m4(rv3d->twmat) ? GL_CW : GL_CCW); | ||||
| else | |||||
| glFrontFace(is_negative_m4(rv3d->twmatrots) ? GL_CW : GL_CCW); | |||||
| /* axis */ | /* axis */ | ||||
| if (is_picksel == false) { | if (is_picksel == false) { | ||||
| // only draw axis when combo didn't draw scale axes | // only draw axis when combo didn't draw scale axes | ||||
| if ((combo & V3D_MANIP_SCALE) == 0) { | if ((combo & V3D_MANIP_SCALE) == 0) { | ||||
| draw_manipulator_axes(v3d, rv3d, colcode, | draw_manipulator_axes(v3d, rv3d, colcode, | ||||
| drawflags & MAN_ROT_X, drawflags & MAN_ROT_Y, drawflags & MAN_ROT_Z, | drawflags & MAN_ROT_X, drawflags & MAN_ROT_Y, drawflags & MAN_ROT_Z, | ||||
| ▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | switch (v3d->around) { | ||||
| { | { | ||||
| bGPdata *gpd = CTX_data_gpencil_data(C); | bGPdata *gpd = CTX_data_gpencil_data(C); | ||||
| Object *ob = OBACT; | Object *ob = OBACT; | ||||
| if (((v3d->around == V3D_AROUND_ACTIVE) && (scene->obedit == NULL)) && | if (((v3d->around == V3D_AROUND_ACTIVE) && (scene->obedit == NULL)) && | ||||
| ((gpd == NULL) || !(gpd->flag & GP_DATA_STROKE_EDITMODE)) && | ((gpd == NULL) || !(gpd->flag & GP_DATA_STROKE_EDITMODE)) && | ||||
| (ob && !(ob->mode & OB_MODE_POSE))) | (ob && !(ob->mode & OB_MODE_POSE))) | ||||
| { | { | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| copy_v3_v3(rv3d->twmat[3], ob->obmat[3]); | copy_v3_v3(rv3d->twmat[3], ob->obmat[3]); | ||||
| else { | |||||
| copy_v3_v3(rv3d->twmattrans[3], ob->obmat[3]); | |||||
| copy_v3_v3(rv3d->twmatrots[3], ob->obmat[3]); | |||||
| copy_v3_v3(rv3d->twmatscale[3], ob->obmat[3]); | |||||
| } | |||||
| } | } | ||||
| else { | else { | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| mid_v3_v3v3(rv3d->twmat[3], scene->twmin, scene->twmax); | mid_v3_v3v3(rv3d->twmat[3], scene->twmin, scene->twmax); | ||||
| else { | |||||
| mid_v3_v3v3(rv3d->twmattrans[3], scene->twmin, scene->twmax); | |||||
| mid_v3_v3v3(rv3d->twmatrots[3], scene->twmin, scene->twmax); | |||||
| mid_v3_v3v3(rv3d->twmatscale[3], scene->twmin, scene->twmax); | |||||
| } | |||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| case V3D_AROUND_LOCAL_ORIGINS: | case V3D_AROUND_LOCAL_ORIGINS: | ||||
| case V3D_AROUND_CENTER_MEAN: | case V3D_AROUND_CENTER_MEAN: | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| copy_v3_v3(rv3d->twmat[3], scene->twcent); | copy_v3_v3(rv3d->twmat[3], scene->twcent); | ||||
| else { | |||||
| copy_v3_v3(rv3d->twmattrans[3], scene->twcent); | |||||
| copy_v3_v3(rv3d->twmatrots[3], scene->twcent); | |||||
| copy_v3_v3(rv3d->twmatscale[3], scene->twcent); | |||||
| } | |||||
| break; | break; | ||||
| case V3D_AROUND_CURSOR: | case V3D_AROUND_CURSOR: | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| copy_v3_v3(rv3d->twmat[3], ED_view3d_cursor3d_get(scene, v3d)); | copy_v3_v3(rv3d->twmat[3], ED_view3d_cursor3d_get(scene, v3d)); | ||||
| else { | |||||
| copy_v3_v3(rv3d->twmattrans[3], ED_view3d_cursor3d_get(scene, v3d)); | |||||
| copy_v3_v3(rv3d->twmatrots[3], ED_view3d_cursor3d_get(scene, v3d)); | |||||
| copy_v3_v3(rv3d->twmatscale[3], ED_view3d_cursor3d_get(scene, v3d)); | |||||
| } | |||||
| break; | break; | ||||
| } | } | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| mul_mat3_m4_fl(rv3d->twmat, ED_view3d_pixel_size(rv3d, rv3d->twmat[3]) * U.tw_size); | mul_mat3_m4_fl(rv3d->twmat, ED_view3d_pixel_size(rv3d, rv3d->twmat[3]) * U.tw_size); | ||||
| else { | |||||
| mul_mat3_m4_fl(rv3d->twmattrans, ED_view3d_pixel_size(rv3d, rv3d->twmattrans[3]) * U.tw_size); | |||||
| mul_mat3_m4_fl(rv3d->twmatrots, ED_view3d_pixel_size(rv3d, rv3d->twmatrots[3]) * U.tw_size); | |||||
| mul_mat3_m4_fl(rv3d->twmatscale, ED_view3d_pixel_size(rv3d, rv3d->twmatscale[3]) * U.tw_size); | |||||
| } | |||||
| } | } | ||||
| /* when looking through a selected camera, the manipulator can be at the | /* when looking through a selected camera, the manipulator can be at the | ||||
| * exact same position as the view, skip so we don't break selection */ | * exact same position as the view, skip so we don't break selection */ | ||||
| if (fabsf(mat4_to_scale(rv3d->twmat)) < 1e-7f) | if (fabsf(mat4_to_scale(rv3d->twmat)) < 1e-7f) | ||||
| return; | return; | ||||
| test_manipulator_axis(C); | test_manipulator_axis(C); | ||||
| drawflags = rv3d->twdrawflag; /* set in calc_manipulator_stats */ | drawflags = rv3d->twdrawflag; /* set in calc_manipulator_stats */ | ||||
| if (v3d->twflag & V3D_DRAW_MANIPULATOR) { | if (v3d->twflag & V3D_DRAW_MANIPULATOR) { | ||||
| glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | ||||
| glEnable(GL_BLEND); | glEnable(GL_BLEND); | ||||
| glLineWidth(1.0f); | glLineWidth(1.0f); | ||||
| if (v3d->twtype & V3D_MANIP_ROTATE) { | if (v3d->twtype & V3D_MANIP_ROTATE) { | ||||
| if (G.debug_value == 3) { | if (G.debug_value == 3) { | ||||
| if (G.moving & (G_TRANSFORM_OBJ | G_TRANSFORM_EDIT)) | if (G.moving & (G_TRANSFORM_OBJ | G_TRANSFORM_EDIT)) { | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| draw_manipulator_rotate_cyl(v3d, rv3d, drawflags, v3d->twtype, MAN_MOVECOL, true, is_picksel); | draw_manipulator_rotate_cyl(v3d, rv3d, drawflags, v3d->twtype, MAN_MOVECOL, true, is_picksel); | ||||
| else | else | ||||
| // The fourth variable is responsible for making sure all the transformations are drawn | |||||
| draw_manipulator_rotate_cyl(v3d, rv3d, drawflags, (v3d->twtrans != 5) | (v3d->twrots != 5) * 2 | (v3d->twscale != 5) * 4, MAN_MOVECOL, true, is_picksel); | |||||
| } | |||||
| else { | |||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| draw_manipulator_rotate_cyl(v3d, rv3d, drawflags, v3d->twtype, MAN_RGB, false, is_picksel); | draw_manipulator_rotate_cyl(v3d, rv3d, drawflags, v3d->twtype, MAN_RGB, false, is_picksel); | ||||
| else | |||||
| draw_manipulator_rotate_cyl(v3d, rv3d, drawflags, (v3d->twtrans != 5) | (v3d->twrots != 5) * 2 | (v3d->twscale != 5) * 4, MAN_RGB, false, is_picksel); | |||||
| } | |||||
| } | } | ||||
| else { | else { | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) { | |||||
| draw_manipulator_rotate(v3d, rv3d, drawflags, v3d->twtype, false, is_picksel); | draw_manipulator_rotate(v3d, rv3d, drawflags, v3d->twtype, false, is_picksel); | ||||
| } | } | ||||
| else { | |||||
| draw_manipulator_rotate(v3d, rv3d, drawflags, (v3d->twtrans != 5) | (v3d->twrots != 5) * 2 | (v3d->twscale != 5) * 4, false, is_picksel); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| if (v3d->twtype & V3D_MANIP_SCALE) { | if (v3d->twtype & V3D_MANIP_SCALE) { | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| draw_manipulator_scale(v3d, rv3d, drawflags, v3d->twtype, MAN_RGB, false, is_picksel); | draw_manipulator_scale(v3d, rv3d, drawflags, v3d->twtype, MAN_RGB, false, is_picksel); | ||||
| else | |||||
| draw_manipulator_scale(v3d, rv3d, drawflags, (v3d->twtrans != 5) | (v3d->twrots != 5) * 2 | (v3d->twscale != 5) * 4, MAN_RGB, false, is_picksel); | |||||
| } | } | ||||
| if (v3d->twtype & V3D_MANIP_TRANSLATE) { | if (v3d->twtype & V3D_MANIP_TRANSLATE) { | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| draw_manipulator_translate(v3d, rv3d, drawflags, v3d->twtype, MAN_RGB, false, is_picksel); | draw_manipulator_translate(v3d, rv3d, drawflags, v3d->twtype, MAN_RGB, false, is_picksel); | ||||
| else | |||||
| draw_manipulator_translate(v3d, rv3d, drawflags, (v3d->twtrans != 5) | (v3d->twrots != 5) * 2 | (v3d->twscale != 5) * 4, MAN_RGB, false, is_picksel); | |||||
| } | } | ||||
| glDisable(GL_BLEND); | glDisable(GL_BLEND); | ||||
| } | } | ||||
| } | } | ||||
| static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const int mval[2], float hotspot) | static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const int mval[2], float hotspot) | ||||
| { | { | ||||
| Show All 24 Lines | static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const int mval[2], float hotspot) | ||||
| if (do_passes) | if (do_passes) | ||||
| GPU_select_begin(buffer, 64, &rect, GPU_SELECT_NEAREST_FIRST_PASS, 0); | GPU_select_begin(buffer, 64, &rect, GPU_SELECT_NEAREST_FIRST_PASS, 0); | ||||
| else | else | ||||
| GPU_select_begin(buffer, 64, &rect, GPU_SELECT_ALL, 0); | GPU_select_begin(buffer, 64, &rect, GPU_SELECT_ALL, 0); | ||||
| /* do the drawing */ | /* do the drawing */ | ||||
| if (v3d->twtype & V3D_MANIP_ROTATE) { | if (v3d->twtype & V3D_MANIP_ROTATE) { | ||||
| if (G.debug_value == 3) draw_manipulator_rotate_cyl(v3d, rv3d, MAN_ROT_C & rv3d->twdrawflag, v3d->twtype, MAN_RGB, false, is_picksel); | if (G.debug_value == 3) draw_manipulator_rotate_cyl(v3d, rv3d, MAN_ROT_C & rv3d->twdrawflag, v3d->twtype, MAN_RGB, false, is_picksel); | ||||
| else draw_manipulator_rotate(v3d, rv3d, MAN_ROT_C & rv3d->twdrawflag, v3d->twtype, false, is_picksel); | else { | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) { | |||||
| draw_manipulator_rotate(v3d, rv3d, MAN_ROT_C & rv3d->twdrawflag, v3d->twtype, false, is_picksel); | |||||
| } | |||||
| else { | |||||
| draw_manipulator_rotate(v3d, rv3d, MAN_ROT_C & rv3d->twdrawflag, (v3d->twtrans != 5) | (v3d->twrots != 5) * 2 | (v3d->twscale != 5) * 4, false, is_picksel); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| if (v3d->twtype & V3D_MANIP_SCALE) | if (v3d->twtype & V3D_MANIP_SCALE) { | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) { | |||||
| draw_manipulator_scale(v3d, rv3d, MAN_SCALE_C & rv3d->twdrawflag, v3d->twtype, MAN_RGB, false, is_picksel); | draw_manipulator_scale(v3d, rv3d, MAN_SCALE_C & rv3d->twdrawflag, v3d->twtype, MAN_RGB, false, is_picksel); | ||||
| if (v3d->twtype & V3D_MANIP_TRANSLATE) | } | ||||
| else { | |||||
| draw_manipulator_scale(v3d, rv3d, MAN_SCALE_C & rv3d->twdrawflag, (v3d->twtrans != 5) | (v3d->twrots != 5) * 2 | (v3d->twscale != 5) * 4, MAN_RGB, false, is_picksel); | |||||
| } | |||||
| } | |||||
| if (v3d->twtype & V3D_MANIP_TRANSLATE) { | |||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| draw_manipulator_translate(v3d, rv3d, MAN_TRANS_C & rv3d->twdrawflag, v3d->twtype, MAN_RGB, false, is_picksel); | draw_manipulator_translate(v3d, rv3d, MAN_TRANS_C & rv3d->twdrawflag, v3d->twtype, MAN_RGB, false, is_picksel); | ||||
| else | |||||
| draw_manipulator_translate(v3d, rv3d, MAN_TRANS_C & rv3d->twdrawflag, (v3d->twtrans != 5) | (v3d->twrots != 5) * 2 | (v3d->twscale != 5) * 4, MAN_RGB, false, is_picksel); | |||||
| } | |||||
| hits = GPU_select_end(); | hits = GPU_select_end(); | ||||
| if (do_passes) { | if (do_passes) { | ||||
| GPU_select_begin(buffer, 64, &rect, GPU_SELECT_NEAREST_SECOND_PASS, hits); | GPU_select_begin(buffer, 64, &rect, GPU_SELECT_NEAREST_SECOND_PASS, hits); | ||||
| /* do the drawing */ | /* do the drawing */ | ||||
| if (v3d->twtype & V3D_MANIP_ROTATE) { | if (v3d->twtype & V3D_MANIP_ROTATE) { | ||||
| if (G.debug_value == 3) draw_manipulator_rotate_cyl(v3d, rv3d, MAN_ROT_C & rv3d->twdrawflag, v3d->twtype, MAN_RGB, false, is_picksel); | if (G.debug_value == 3) draw_manipulator_rotate_cyl(v3d, rv3d, MAN_ROT_C & rv3d->twdrawflag, v3d->twtype, MAN_RGB, false, is_picksel); | ||||
| else draw_manipulator_rotate(v3d, rv3d, MAN_ROT_C & rv3d->twdrawflag, v3d->twtype, false, is_picksel); | else { | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| draw_manipulator_rotate(v3d, rv3d, MAN_ROT_C & rv3d->twdrawflag, v3d->twtype, false, is_picksel); | |||||
| else | |||||
| draw_manipulator_rotate(v3d, rv3d, MAN_ROT_C & rv3d->twdrawflag, (v3d->twtrans != 5) | (v3d->twrots != 5) * 2 | (v3d->twscale != 5) * 4, false, is_picksel); | |||||
| } | |||||
| } | } | ||||
| if (v3d->twtype & V3D_MANIP_SCALE) | if (v3d->twtype & V3D_MANIP_SCALE) { | ||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| draw_manipulator_scale(v3d, rv3d, MAN_SCALE_C & rv3d->twdrawflag, v3d->twtype, MAN_RGB, false, is_picksel); | draw_manipulator_scale(v3d, rv3d, MAN_SCALE_C & rv3d->twdrawflag, v3d->twtype, MAN_RGB, false, is_picksel); | ||||
| if (v3d->twtype & V3D_MANIP_TRANSLATE) | else | ||||
| draw_manipulator_scale(v3d, rv3d, MAN_SCALE_C & rv3d->twdrawflag, (v3d->twtrans != 5) | (v3d->twrots != 5) * 2 | (v3d->twscale != 5) * 4, MAN_RGB, false, is_picksel); | |||||
| } | |||||
| if (v3d->twtype & V3D_MANIP_TRANSLATE) { | |||||
| if (!(v3d->twmode == V3D_MANIP_MULTI_TRANSF)) | |||||
| draw_manipulator_translate(v3d, rv3d, MAN_TRANS_C & rv3d->twdrawflag, v3d->twtype, MAN_RGB, false, is_picksel); | draw_manipulator_translate(v3d, rv3d, MAN_TRANS_C & rv3d->twdrawflag, v3d->twtype, MAN_RGB, false, is_picksel); | ||||
| else | |||||
| draw_manipulator_translate(v3d, rv3d, MAN_TRANS_C & rv3d->twdrawflag, (v3d->twtrans != 5) | (v3d->twrots != 5) * 2 | (v3d->twscale != 5) * 4, MAN_RGB, false, is_picksel); | |||||
| } | |||||
| GPU_select_end(); | GPU_select_end(); | ||||
| } | } | ||||
| view3d_winmatrix_set(ar, v3d, NULL); | view3d_winmatrix_set(ar, v3d, NULL); | ||||
| mul_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat); | mul_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat); | ||||
| if (hits == 1) return buffer[3]; | if (hits == 1) return buffer[3]; | ||||
| ▲ Show 20 Lines • Show All 197 Lines • Show Last 20 Lines | |||||
I see compiler warnings in all lines using mtx_tranf. It is an array of float*, where all the following lines of code assume float[4][4]. I'm not sure if there's a truly elegant way of handling this, but this slightly convoluted variable declaration allows the code to build without warnings or having to use casts:
Later, the calls to the copy matrix functions will then need to dereference the pointers in the array: