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 | |
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')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 33 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_utils.c | 7 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 30 |
3 files changed, 60 insertions, 10 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); } diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 9da07e0cd06..90ddee99f9c 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -405,15 +405,39 @@ static void createTransCursor_view3d(TransInfo *t) td->ob = NULL; unit_m3(td->mtx); - quat_to_mat3(td->axismtx, cursor->rotation); + BKE_scene_cursor_rot_to_mat3(cursor, td->axismtx); normalize_m3(td->axismtx); pseudoinverse_m3_m3(td->smtx, td->mtx, PSEUDOINVERSE_EPSILON); td->loc = cursor->location; copy_v3_v3(td->iloc, cursor->location); - td->ext->quat = cursor->rotation; - copy_qt_qt(td->ext->iquat, cursor->rotation); + if (cursor->rotation_mode > 0) { + td->ext->rot = cursor->rotation_euler; + td->ext->rotAxis = NULL; + td->ext->rotAngle = NULL; + td->ext->quat = NULL; + + copy_v3_v3(td->ext->irot, cursor->rotation_euler); + } + else if (cursor->rotation_mode == ROT_MODE_AXISANGLE) { + td->ext->rot = NULL; + td->ext->rotAxis = cursor->rotation_axis; + td->ext->rotAngle = &cursor->rotation_angle; + td->ext->quat = NULL; + + td->ext->irotAngle = cursor->rotation_angle; + copy_v3_v3(td->ext->irotAxis, cursor->rotation_axis); + } + else { + td->ext->rot = NULL; + td->ext->rotAxis = NULL; + td->ext->rotAngle = NULL; + td->ext->quat = cursor->rotation_quaternion; + + copy_qt_qt(td->ext->iquat, cursor->rotation_quaternion); + } + td->ext->rotOrder = cursor->rotation_mode; } /** \} */ |