diff options
author | Mike Erwin <significant.bit@gmail.com> | 2011-07-30 09:23:10 +0400 |
---|---|---|
committer | Mike Erwin <significant.bit@gmail.com> | 2011-07-30 09:23:10 +0400 |
commit | 632f59c7bce051f359e57bf872fb624cb6643d87 (patch) | |
tree | a99aba293ef7f5221726093562a41e3b3c8d8627 /source/blender/editors/space_view3d | |
parent | aec91c0cf530d637a15c95cf1e4d0e27a7660a4c (diff) |
improved visual rotation guide
Diffstat (limited to 'source/blender/editors/space_view3d')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 51 |
1 files changed, 43 insertions, 8 deletions
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 2b863bf794c..6e3f6549ba3 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -681,7 +681,7 @@ static void draw_rotation_guide(RegionView3D *rv3d) float o[3]; // center of rotation float end[3]; // endpoints for drawing - float color[4] = {1,1,0,1}; // bright yellow so it stands out during development + float color[4] = {0.f ,0.4235f, 1.f, 1.f}; // bright blue so it matches device LEDs negate_v3_v3(o, rv3d->ofs); @@ -699,7 +699,7 @@ static void draw_rotation_guide(RegionView3D *rv3d) mul_v3_v3fl(scaled_axis, rv3d->rot_axis, scale); glBegin(GL_LINE_STRIP); - color[3] = 0; // more transparent toward the ends + color[3] = 0.f; // more transparent toward the ends glColor4fv(color); add_v3_v3v3(end, o, scaled_axis); glVertex3fv(end); @@ -711,16 +711,52 @@ static void draw_rotation_guide(RegionView3D *rv3d) glColor4fv(color); glVertex3fv(o); - color[3] = 0; + color[3] = 0.f; glColor4fv(color); sub_v3_v3v3(end, o, scaled_axis); glVertex3fv(end); glEnd(); - color[3] = 1; // solid dot + // -- draw ring around rotation center -- + { + #define ROT_AXIS_DETAIL 13 + const float s = 0.05f * scale; + const float step = 2.f * M_PI / ROT_AXIS_DETAIL; + float angle; + int i; + + float q[4]; // rotate ring so it's perpendicular to axis + const int upright = fabsf(rv3d->rot_axis[2]) >= 0.95f; + if (!upright) + { + const float up[3] = {0.f, 0.f, 1.f}; + float vis_angle, vis_axis[3]; + + cross_v3_v3v3(vis_axis, up, rv3d->rot_axis); + vis_angle = acosf(dot_v3v3(up, rv3d->rot_axis)); + axis_angle_to_quat(q, vis_axis, vis_angle); + } + + color[3] = 0.25f; // somewhat faint + glColor4fv(color); + glBegin(GL_LINE_LOOP); + for (i = 0, angle = 0.f; i < ROT_AXIS_DETAIL; ++i, angle += step) + { + float p[3] = { s * cosf(angle), s * sinf(angle), 0.f }; + + if (!upright) + mul_qt_v3(q, p); + + add_v3_v3(p, o); + glVertex3fv(p); + } + glEnd(); + } + + color[3] = 1.f; // solid dot } else - color[3] = 0.5; // see-through dot + color[3] = 0.5f; // see-through dot // -- draw rotation center -- glColor4fv(color); @@ -2680,10 +2716,9 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) BDR_drawSketch(C); } -//#if 0 // not yet... - if (U.ndof_flag & NDOF_SHOW_GUIDE) + if ((U.ndof_flag & NDOF_SHOW_GUIDE) && (rv3d->viewlock != RV3D_LOCKED) && (rv3d->persp != RV3D_CAMOB)) + // TODO: draw something else (but not this) during fly mode draw_rotation_guide(rv3d); -//#endif ED_region_pixelspace(ar); |