diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-02-25 16:58:35 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-02-25 17:37:49 +0300 |
commit | 86c0ee80209cdd52e4b360ffcf854144922ac2e6 (patch) | |
tree | 722f7ddcfaa702cf834d4fe2b8d63f1a2638398c /source/blender/draw/intern/draw_view.c | |
parent | 213ac7b1aceea3b5a210e86a07402d4415c9a6b6 (diff) |
3D View: support for editing cursor rotation
Add buttons for editing the cursor rotation as well as rotation modes,
similar to object and pose bones.
Diffstat (limited to 'source/blender/draw/intern/draw_view.c')
-rw-r--r-- | source/blender/draw/intern/draw_view.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c index 2426e98ec84..9bc4e7e8470 100644 --- a/source/blender/draw/intern/draw_view.c +++ b/source/blender/draw/intern/draw_view.c @@ -201,12 +201,18 @@ void DRW_draw_cursor(void) if (is_cursor_visible(draw_ctx, scene, view_layer)) { int co[2]; + + /* Get cursor data into quaternion form */ const View3DCursor *cursor = &scene->cursor; + if (ED_view3d_project_int_global( ar, cursor->location, co, V3D_PROJ_TEST_NOP | V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK) { RegionView3D *rv3d = ar->regiondata; + float cursor_quat[4]; + BKE_scene_cursor_rot_to_quat(cursor, cursor_quat); + /* Draw nice Anti Aliased cursor. */ GPU_line_width(1.0f); glEnable(GL_BLEND); @@ -214,7 +220,12 @@ void DRW_draw_cursor(void) float eps = 1e-5f; rv3d->viewquat[0] = -rv3d->viewquat[0]; - const bool is_aligned = compare_v4v4(cursor->rotation, rv3d->viewquat, eps); + bool is_aligned = compare_v4v4(cursor_quat, rv3d->viewquat, eps); + if (is_aligned == false) { + float tquat[4]; + rotation_between_quats_to_quat(tquat, rv3d->viewquat, cursor_quat); + is_aligned = tquat[0] - eps < -1.0f; + } rv3d->viewquat[0] = -rv3d->viewquat[0]; /* Draw lines */ @@ -241,7 +252,7 @@ void DRW_draw_cursor(void) for (int axis = 0; axis < 3; axis++) { float axis_vec[3] = {0}; axis_vec[axis] = scale; - mul_qt_v3(cursor->rotation, axis_vec); + mul_qt_v3(cursor_quat, axis_vec); CURSOR_EDGE(axis_vec, axis, +); CURSOR_EDGE(axis_vec, axis, -); } |