diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 263 |
1 files changed, 130 insertions, 133 deletions
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index e11c3012281..abcb5495d39 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -1300,59 +1300,58 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *op, const wmEvent *event) if (event->type != NDOF_MOTION) { return OPERATOR_CANCELLED; } - else { - const Depsgraph *depsgraph = CTX_data_depsgraph(C); - ViewOpsData *vod; - View3D *v3d; - RegionView3D *rv3d; - char xform_flag = 0; - const wmNDOFMotionData *ndof = event->customdata; + const Depsgraph *depsgraph = CTX_data_depsgraph(C); + ViewOpsData *vod; + View3D *v3d; + RegionView3D *rv3d; + char xform_flag = 0; - viewops_data_alloc(C, op); - viewops_data_create( - C, op, event, - viewops_flag_from_args((U.uiflag & USER_ORBIT_SELECTION) != 0, false)); - vod = op->customdata; + const wmNDOFMotionData *ndof = event->customdata; - ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->ar); + viewops_data_alloc(C, op); + viewops_data_create( + C, op, event, + viewops_flag_from_args((U.uiflag & USER_ORBIT_SELECTION) != 0, false)); + vod = op->customdata; - v3d = vod->v3d; - rv3d = vod->rv3d; + ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->ar); - /* off by default, until changed later this function */ - rv3d->rot_angle = 0.0f; + v3d = vod->v3d; + rv3d = vod->rv3d; - ED_view3d_camera_lock_init_ex(depsgraph, v3d, rv3d, false); + /* off by default, until changed later this function */ + rv3d->rot_angle = 0.0f; - if (ndof->progress != P_FINISHING) { - const bool has_rotation = NDOF_HAS_ROTATE; - /* if we can't rotate, fallback to translate (locked axis views) */ - const bool has_translate = NDOF_HAS_TRANSLATE && (rv3d->viewlock & RV3D_LOCKED); - const bool has_zoom = (ndof->tvec[2] != 0.0f) && !rv3d->is_persp; + ED_view3d_camera_lock_init_ex(depsgraph, v3d, rv3d, false); - if (has_translate || has_zoom) { - view3d_ndof_pan_zoom(ndof, vod->sa, vod->ar, has_translate, has_zoom); - xform_flag |= HAS_TRANSLATE; - } + if (ndof->progress != P_FINISHING) { + const bool has_rotation = NDOF_HAS_ROTATE; + /* if we can't rotate, fallback to translate (locked axis views) */ + const bool has_translate = NDOF_HAS_TRANSLATE && (rv3d->viewlock & RV3D_LOCKED); + const bool has_zoom = (ndof->tvec[2] != 0.0f) && !rv3d->is_persp; - if (has_rotation) { - view3d_ndof_orbit(ndof, vod->sa, vod->ar, vod, true); - xform_flag |= HAS_ROTATE; - } + if (has_translate || has_zoom) { + view3d_ndof_pan_zoom(ndof, vod->sa, vod->ar, has_translate, has_zoom); + xform_flag |= HAS_TRANSLATE; } - ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d); - if (xform_flag) { - ED_view3d_camera_lock_autokey(v3d, rv3d, C, xform_flag & HAS_ROTATE, xform_flag & HAS_TRANSLATE); + if (has_rotation) { + view3d_ndof_orbit(ndof, vod->sa, vod->ar, vod, true); + xform_flag |= HAS_ROTATE; } + } - ED_region_tag_redraw(vod->ar); + ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d); + if (xform_flag) { + ED_view3d_camera_lock_autokey(v3d, rv3d, C, xform_flag & HAS_ROTATE, xform_flag & HAS_TRANSLATE); + } - viewops_data_free(C, op); + ED_region_tag_redraw(vod->ar); - return OPERATOR_FINISHED; - } + viewops_data_free(C, op); + + return OPERATOR_FINISHED; } void VIEW3D_OT_ndof_orbit(struct wmOperatorType *ot) @@ -1381,95 +1380,94 @@ static int ndof_orbit_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev if (event->type != NDOF_MOTION) { return OPERATOR_CANCELLED; } - else { - const Depsgraph *depsgraph = CTX_data_depsgraph(C); - ViewOpsData *vod; - View3D *v3d; - RegionView3D *rv3d; - char xform_flag = 0; - const wmNDOFMotionData *ndof = event->customdata; + const Depsgraph *depsgraph = CTX_data_depsgraph(C); + ViewOpsData *vod; + View3D *v3d; + RegionView3D *rv3d; + char xform_flag = 0; - viewops_data_alloc(C, op); - viewops_data_create( - C, op, event, - viewops_flag_from_args((U.uiflag & USER_ORBIT_SELECTION) != 0, false)); + const wmNDOFMotionData *ndof = event->customdata; - vod = op->customdata; + viewops_data_alloc(C, op); + viewops_data_create( + C, op, event, + viewops_flag_from_args((U.uiflag & USER_ORBIT_SELECTION) != 0, false)); - ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->ar); + vod = op->customdata; - v3d = vod->v3d; - rv3d = vod->rv3d; + ED_view3d_smooth_view_force_finish(C, vod->v3d, vod->ar); - /* off by default, until changed later this function */ - rv3d->rot_angle = 0.0f; + v3d = vod->v3d; + rv3d = vod->rv3d; - ED_view3d_camera_lock_init_ex(depsgraph, v3d, rv3d, false); + /* off by default, until changed later this function */ + rv3d->rot_angle = 0.0f; - if (ndof->progress == P_FINISHING) { - /* pass */ - } - else if ((rv3d->persp == RV3D_ORTHO) && RV3D_VIEW_IS_AXIS(rv3d->view)) { - /* if we can't rotate, fallback to translate (locked axis views) */ - const bool has_translate = NDOF_HAS_TRANSLATE; - const bool has_zoom = (ndof->tvec[2] != 0.0f) && ED_view3d_offset_lock_check(v3d, rv3d); - - if (has_translate || has_zoom) { - view3d_ndof_pan_zoom(ndof, vod->sa, vod->ar, has_translate, true); - xform_flag |= HAS_TRANSLATE; - } - } - else if ((U.ndof_flag & NDOF_MODE_ORBIT) || - ED_view3d_offset_lock_check(v3d, rv3d)) - { - const bool has_rotation = NDOF_HAS_ROTATE; - const bool has_zoom = (ndof->tvec[2] != 0.0f); + ED_view3d_camera_lock_init_ex(depsgraph, v3d, rv3d, false); - if (has_zoom) { - view3d_ndof_pan_zoom(ndof, vod->sa, vod->ar, false, has_zoom); - xform_flag |= HAS_TRANSLATE; - } + if (ndof->progress == P_FINISHING) { + /* pass */ + } + else if ((rv3d->persp == RV3D_ORTHO) && RV3D_VIEW_IS_AXIS(rv3d->view)) { + /* if we can't rotate, fallback to translate (locked axis views) */ + const bool has_translate = NDOF_HAS_TRANSLATE; + const bool has_zoom = (ndof->tvec[2] != 0.0f) && ED_view3d_offset_lock_check(v3d, rv3d); - if (has_rotation) { - view3d_ndof_orbit(ndof, vod->sa, vod->ar, vod, true); - xform_flag |= HAS_ROTATE; - } + if (has_translate || has_zoom) { + view3d_ndof_pan_zoom(ndof, vod->sa, vod->ar, has_translate, true); + xform_flag |= HAS_TRANSLATE; } - else { /* free/explore (like fly mode) */ - const bool has_rotation = NDOF_HAS_ROTATE; - const bool has_translate = NDOF_HAS_TRANSLATE; - const bool has_zoom = (ndof->tvec[2] != 0.0f) && !rv3d->is_persp; - - float dist_backup; + } + else if ((U.ndof_flag & NDOF_MODE_ORBIT) || + ED_view3d_offset_lock_check(v3d, rv3d)) + { + const bool has_rotation = NDOF_HAS_ROTATE; + const bool has_zoom = (ndof->tvec[2] != 0.0f); - if (has_translate || has_zoom) { - view3d_ndof_pan_zoom(ndof, vod->sa, vod->ar, has_translate, has_zoom); - xform_flag |= HAS_TRANSLATE; - } + if (has_zoom) { + view3d_ndof_pan_zoom(ndof, vod->sa, vod->ar, false, has_zoom); + xform_flag |= HAS_TRANSLATE; + } - dist_backup = rv3d->dist; - ED_view3d_distance_set(rv3d, 0.0f); + if (has_rotation) { + view3d_ndof_orbit(ndof, vod->sa, vod->ar, vod, true); + xform_flag |= HAS_ROTATE; + } + } + else { /* free/explore (like fly mode) */ + const bool has_rotation = NDOF_HAS_ROTATE; + const bool has_translate = NDOF_HAS_TRANSLATE; + const bool has_zoom = (ndof->tvec[2] != 0.0f) && !rv3d->is_persp; - if (has_rotation) { - view3d_ndof_orbit(ndof, vod->sa, vod->ar, vod, false); - xform_flag |= HAS_ROTATE; - } + float dist_backup; - ED_view3d_distance_set(rv3d, dist_backup); + if (has_translate || has_zoom) { + view3d_ndof_pan_zoom(ndof, vod->sa, vod->ar, has_translate, has_zoom); + xform_flag |= HAS_TRANSLATE; } - ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d); - if (xform_flag) { - ED_view3d_camera_lock_autokey(v3d, rv3d, C, xform_flag & HAS_ROTATE, xform_flag & HAS_TRANSLATE); - } + dist_backup = rv3d->dist; + ED_view3d_distance_set(rv3d, 0.0f); - ED_region_tag_redraw(vod->ar); + if (has_rotation) { + view3d_ndof_orbit(ndof, vod->sa, vod->ar, vod, false); + xform_flag |= HAS_ROTATE; + } - viewops_data_free(C, op); + ED_view3d_distance_set(rv3d, dist_backup); + } - return OPERATOR_FINISHED; + ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d); + if (xform_flag) { + ED_view3d_camera_lock_autokey(v3d, rv3d, C, xform_flag & HAS_ROTATE, xform_flag & HAS_TRANSLATE); } + + ED_region_tag_redraw(vod->ar); + + viewops_data_free(C, op); + + return OPERATOR_FINISHED; } void VIEW3D_OT_ndof_orbit_zoom(struct wmOperatorType *ot) @@ -1498,43 +1496,42 @@ static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *e if (event->type != NDOF_MOTION) { return OPERATOR_CANCELLED; } - else { - const Depsgraph *depsgraph = CTX_data_depsgraph(C); - View3D *v3d = CTX_wm_view3d(C); - RegionView3D *rv3d = CTX_wm_region_view3d(C); - const wmNDOFMotionData *ndof = event->customdata; - char xform_flag = 0; - const bool has_translate = NDOF_HAS_TRANSLATE; - const bool has_zoom = (ndof->tvec[2] != 0.0f) && !rv3d->is_persp; + const Depsgraph *depsgraph = CTX_data_depsgraph(C); + View3D *v3d = CTX_wm_view3d(C); + RegionView3D *rv3d = CTX_wm_region_view3d(C); + const wmNDOFMotionData *ndof = event->customdata; + char xform_flag = 0; - /* we're panning here! so erase any leftover rotation from other operators */ - rv3d->rot_angle = 0.0f; + const bool has_translate = NDOF_HAS_TRANSLATE; + const bool has_zoom = (ndof->tvec[2] != 0.0f) && !rv3d->is_persp; - if (!(has_translate || has_zoom)) - return OPERATOR_CANCELLED; + /* we're panning here! so erase any leftover rotation from other operators */ + rv3d->rot_angle = 0.0f; - ED_view3d_camera_lock_init_ex(depsgraph, v3d, rv3d, false); + if (!(has_translate || has_zoom)) + return OPERATOR_CANCELLED; - if (ndof->progress != P_FINISHING) { - ScrArea *sa = CTX_wm_area(C); - ARegion *ar = CTX_wm_region(C); + ED_view3d_camera_lock_init_ex(depsgraph, v3d, rv3d, false); - if (has_translate || has_zoom) { - view3d_ndof_pan_zoom(ndof, sa, ar, has_translate, has_zoom); - xform_flag |= HAS_TRANSLATE; - } - } + if (ndof->progress != P_FINISHING) { + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); - ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d); - if (xform_flag) { - ED_view3d_camera_lock_autokey(v3d, rv3d, C, false, xform_flag & HAS_TRANSLATE); + if (has_translate || has_zoom) { + view3d_ndof_pan_zoom(ndof, sa, ar, has_translate, has_zoom); + xform_flag |= HAS_TRANSLATE; } + } - ED_region_tag_redraw(CTX_wm_region(C)); - - return OPERATOR_FINISHED; + ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d); + if (xform_flag) { + ED_view3d_camera_lock_autokey(v3d, rv3d, C, false, xform_flag & HAS_TRANSLATE); } + + ED_region_tag_redraw(CTX_wm_region(C)); + + return OPERATOR_FINISHED; } void VIEW3D_OT_ndof_pan(struct wmOperatorType *ot) |