diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/include/ED_view3d.h | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 31 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_fly.c | 4 |
3 files changed, 34 insertions, 3 deletions
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index b303d00b6fd..b111295fa26 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -298,6 +298,8 @@ bool ED_view3d_lock(struct RegionView3D *rv3d); uint64_t ED_view3d_datamask(struct Scene *scene, struct View3D *v3d); uint64_t ED_view3d_screen_datamask(struct bScreen *screen); +bool ED_view3d_offset_lock_check(struct View3D *v3d, struct RegionView3D *rv3d); + /* camera lock functions */ bool ED_view3d_camera_lock_check(struct View3D *v3d, struct RegionView3D *rv3d); /* copy the camera to the view before starting a view transformation */ diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 643e08ab405..44950655ae1 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -86,6 +86,27 @@ /* for ndof prints */ // #define DEBUG_NDOF_MOTION +static void view3d_offset_lock_report(ReportList *reports) +{ + BKE_report(reports, RPT_WARNING, "View offset is locked"); +} + +bool ED_view3d_offset_lock_check(struct View3D *v3d, struct RegionView3D *rv3d) +{ + return (rv3d->persp != RV3D_CAMOB) && (v3d->ob_centre_cursor || v3d->ob_centre); +} + +#define VIEW3D_OP_OFS_LOCK_TEST(C, op) \ + { \ + View3D *v3d_tmp = CTX_wm_view3d(C); \ + RegionView3D *rv3d_tmp = CTX_wm_region_view3d(C); \ + if (ED_view3d_offset_lock_check(v3d_tmp, rv3d_tmp)) { \ + view3d_offset_lock_report((op)->reports); \ + return OPERATOR_CANCELLED; \ + } \ + } (void)0 + + /* ********************** view3d_edit: view manipulations ********************* */ bool ED_view3d_camera_lock_check(View3D *v3d, RegionView3D *rv3d) @@ -1286,7 +1307,7 @@ void VIEW3D_OT_ndof_orbit_zoom(struct wmOperatorType *ot) /* -- "pan" navigation * -- zoom or dolly? */ -static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) +static int ndof_pan_invoke(bContext *C, wmOperator *op, const wmEvent *event) { if (event->type != NDOF_MOTION) return OPERATOR_CANCELLED; @@ -1295,6 +1316,8 @@ static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *e RegionView3D *rv3d = CTX_wm_region_view3d(C); wmNDOFMotionData *ndof = (wmNDOFMotionData *) event->customdata; + VIEW3D_OP_OFS_LOCK_TEST(C, op); + ED_view3d_camera_lock_init(v3d, rv3d); rv3d->rot_angle = 0.f; /* we're panning here! so erase any leftover rotation from other operators */ @@ -1586,6 +1609,8 @@ static int viewmove_invoke(bContext *C, wmOperator *op, const wmEvent *event) { ViewOpsData *vod; + VIEW3D_OP_OFS_LOCK_TEST(C, op); + /* makes op->customdata */ viewops_data_create(C, op, event); vod = op->customdata; @@ -2164,6 +2189,8 @@ static int viewdolly_invoke(bContext *C, wmOperator *op, const wmEvent *event) { ViewOpsData *vod; + VIEW3D_OP_OFS_LOCK_TEST(C, op); + /* makes op->customdata */ viewops_data_create(C, op, event); vod = op->customdata; @@ -3482,6 +3509,8 @@ static int viewpan_exec(bContext *C, wmOperator *op) float zfac; int pandir; + VIEW3D_OP_OFS_LOCK_TEST(C, op); + pandir = RNA_enum_get(op->ptr, "type"); ED_view3d_camera_lock_init(v3d, rv3d); diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 1720a98c54d..4c267905834 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -304,8 +304,8 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent return false; } - if (fly->v3d->ob_centre) { - BKE_report(op->reports, RPT_ERROR, "Cannot fly when the view is locked to an object"); + if (ED_view3d_offset_lock_check(fly->v3d, fly->rv3d)) { + BKE_report(op->reports, RPT_ERROR, "Cannot fly when the view offset is locked"); return false; } |