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/editors/space_view3d | |
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/editors/space_view3d')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 33 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_utils.c | 7 |
2 files changed, 33 insertions, 7 deletions
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 9adcd4c264a..c84e8d9da20 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -2712,7 +2712,10 @@ static int view3d_all_exec(bContext *C, wmOperator *op) zero_v3(min); zero_v3(max); zero_v3(cursor->location); - unit_qt(cursor->rotation); + unit_qt(cursor->rotation_quaternion); + zero_v3(cursor->rotation_euler); + ARRAY_SET_ITEMS(cursor->rotation_axis, 0.0f, 1.0f, 0.0f); + cursor->rotation_angle = 0.0f; } else { INIT_MINMAX(min, max); @@ -4762,10 +4765,30 @@ void ED_view3d_cursor3d_update( View3DCursor *cursor_curr = &scene->cursor; View3DCursor cursor_prev = *cursor_curr; - ED_view3d_cursor3d_position_rotation( - C, mval, - use_depth, orientation, - cursor_curr->location, cursor_curr->rotation); + { + float quat[4], quat_prev[4]; + BKE_scene_cursor_rot_to_quat(cursor_curr, quat); + copy_qt_qt(quat_prev, quat); + ED_view3d_cursor3d_position_rotation( + C, mval, + use_depth, orientation, + cursor_curr->location, quat); + + if (!equals_v4v4(quat_prev, quat)) { + if ((cursor_curr->rotation_mode == ROT_MODE_AXISANGLE) && + RV3D_VIEW_IS_AXIS(rv3d->view)) + { + float tmat[3][3], cmat[3][3]; + quat_to_mat3(tmat, quat); + negate_v3_v3(cursor_curr->rotation_axis, tmat[2]); + axis_angle_to_mat3(cmat, cursor_curr->rotation_axis, 0.0f); + cursor_curr->rotation_angle = angle_signed_on_axis_v3v3_v3(cmat[0], tmat[0], cursor_curr->rotation_axis); + } + else { + BKE_scene_cursor_quat_to_rot(cursor_curr, quat, true); + } + } + } /* offset the cursor lock to avoid jumping to new offset */ if (v3d->ob_centre_cursor) { diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c index 1d8f7e2606c..8a343281bf1 100644 --- a/source/blender/editors/space_view3d/view3d_utils.c +++ b/source/blender/editors/space_view3d/view3d_utils.c @@ -45,6 +45,7 @@ #include "BKE_context.h" #include "BKE_object.h" #include "BKE_screen.h" +#include "BKE_scene.h" #include "DEG_depsgraph.h" #include "DEG_depsgraph_query.h" @@ -88,13 +89,15 @@ void ED_view3d_background_color_get(const Scene *scene, const View3D *v3d, float void ED_view3d_cursor3d_calc_mat3(const Scene *scene, float mat[3][3]) { const View3DCursor *cursor = &scene->cursor; - quat_to_mat3(mat, cursor->rotation); + BKE_scene_cursor_rot_to_mat3(cursor, mat); } void ED_view3d_cursor3d_calc_mat4(const Scene *scene, float mat[4][4]) { const View3DCursor *cursor = &scene->cursor; - quat_to_mat4(mat, cursor->rotation); + float mat3[3][3]; + BKE_scene_cursor_rot_to_mat3(cursor, mat3); + copy_m4_m3(mat, mat3); copy_v3_v3(mat[3], cursor->location); } |